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: |

The group’s featured image is of a Pepe frog yelling, often referred to as the “REEEEEEE” meme. Pepe the Frog was created back in 2005 by Matt Furie and has since become an internet symbol for meme culture and “degen” culture. The SUCK Channel on Telegram, with a message saying some content has been removed by the police. Photo: Telegram screenshot. Judge Hui described Ng as inciting others to “commit a massacre” with three posts teaching people to make “toxic chlorine gas bombs,” target police stations, police quarters and the city’s metro stations. This offence was “rather serious,” the court said. Earlier, crypto enthusiasts had created a self-described “meme app” dubbed “gm” app wherein users would greet each other with “gm” or “good morning” messages. However, in September 2021, the gm app was down after a hacker reportedly gained access to the user data. Write your hashtags in the language of your target audience.
from us


Telegram جنگولرن
FROM American