DJANGOLEARN_IR Telegram 1095
هندل کردن Open Redirect Attack توی جنگو با RedirectURLMixin

این Open Redirect Attack چیه؟ کلمه این رو گذاشتم اولش راست چین بشه 😁

وقتی شما کاربر رو به URL بیرونی ریدایرکت می‌کنید بدون بررسی، یه attacker می‌تونه ازش سوء استفاده کنه:
https://yoursite.com/login/?next=http://hack.com
کاربر فکر می‌کنه داره به سایت شما میره، ولی بعد از login به سایت مهاجم هدایت می‌شه. این می‌تونه phishing یا سرقت اطلاعات session کاربر رو ممکن کنه. (من بلد نیستم چطوری میتونه، خودتون سرچ کنید)

میکسین ع RedirectURLMixin توی جنگو (django.contrib.auth.views) جلوی این حرکت رو می گیره. (یکی از کارهاش اینه)

چی کار می‌کنه؟

با میکسین ع RedirectURLMixin می تونیم بررسی کنیم که این URL جزو hostهای مجاز هست.
یه مثال ساده براش:
class AAA(RedirectURLMixin, View):
redirect_field_name = "next"

def get(self, request, *args, **kwargs):
url = self.get_redirect_url()
if url:
return redirect(url)
return redirect("/")

اون get_redirect_url یکی از متدهای این میکسین ع

حالا من اگه آدرس رو اینجوری بدم:
http://127.0.0.1:8000/profiles/aaa/?next=https://djangolearn.ir/
ریدارکت میشه به صفحه اصلی سایت خودتون نه سایت جنگولرن 😁

راستی از نسخه 4.1 به بعد این میکسین جایگزین SuccessURLAllowedHostsMixin شده:

The undocumented django.contrib.auth.views.SuccessURLAllowedHostsMixin mixin is replaced by RedirectURLMixin.

لایک نداشت این پست؟
32👍11😁1



tgoop.com/djangolearn_ir/1095
Create:
Last Update:

هندل کردن Open Redirect Attack توی جنگو با RedirectURLMixin

این Open Redirect Attack چیه؟ کلمه این رو گذاشتم اولش راست چین بشه 😁

وقتی شما کاربر رو به URL بیرونی ریدایرکت می‌کنید بدون بررسی، یه attacker می‌تونه ازش سوء استفاده کنه:
https://yoursite.com/login/?next=http://hack.com
کاربر فکر می‌کنه داره به سایت شما میره، ولی بعد از login به سایت مهاجم هدایت می‌شه. این می‌تونه phishing یا سرقت اطلاعات session کاربر رو ممکن کنه. (من بلد نیستم چطوری میتونه، خودتون سرچ کنید)

میکسین ع RedirectURLMixin توی جنگو (django.contrib.auth.views) جلوی این حرکت رو می گیره. (یکی از کارهاش اینه)

چی کار می‌کنه؟

با میکسین ع RedirectURLMixin می تونیم بررسی کنیم که این URL جزو hostهای مجاز هست.
یه مثال ساده براش:

class AAA(RedirectURLMixin, View):
redirect_field_name = "next"

def get(self, request, *args, **kwargs):
url = self.get_redirect_url()
if url:
return redirect(url)
return redirect("/")

اون get_redirect_url یکی از متدهای این میکسین ع

حالا من اگه آدرس رو اینجوری بدم:
http://127.0.0.1:8000/profiles/aaa/?next=https://djangolearn.ir/
ریدارکت میشه به صفحه اصلی سایت خودتون نه سایت جنگولرن 😁

راستی از نسخه 4.1 به بعد این میکسین جایگزین SuccessURLAllowedHostsMixin شده:

The undocumented django.contrib.auth.views.SuccessURLAllowedHostsMixin mixin is replaced by RedirectURLMixin.

لایک نداشت این پست؟

BY جنگولرن


Share with your friend now:
tgoop.com/djangolearn_ir/1095

View MORE
Open in Telegram


Telegram News

Date: |

Hashtags are a fast way to find the correct information on social media. To put your content out there, be sure to add hashtags to each post. We have two intelligent tips to give you: Ng, who had pleaded not guilty to all charges, had been detained for more than 20 months. His channel was said to have contained around 120 messages and photos that incited others to vandalise pro-government shops and commit criminal damage targeting police stations. Content is editable within two days of publishing With Bitcoin down 30% in the past week, some crypto traders have taken to Telegram to “voice” their feelings. Activate up to 20 bots
from us


Telegram جنگولرن
FROM American