Giter Club home page Giter Club logo

Comments (19)

aaugustin avatar aaugustin commented on July 29, 2024 1

It's technically possible to add this feature to the middleware.

I'm wondering if it needs to be configurable or if we should just make a choice here.

That choice is a tradeoff between page load time (an extra redirect) and URL cleanliness.

Currently django-sesame supports running without django.contrib.sessions (theoretically — I never tested it and I don't expect anyone to do that). We shouldn't redirect in that case.

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024 1

I pushed version 1.4 to PyPI with this feature.

from django-sesame.

jacebrowning avatar jacebrowning commented on July 29, 2024

I can't imagine many scenarios where I'd want to keep the token in the URL.

I'm building an app (nothing sensitive and well within the security caveats) that will generate unique event URLs to be shared via text/chat/etc. and take advantage of the password-less login provided by this package. If the token remains in the URL, it increases the chances that someone will share a URL that inadvertently logs in as that user.

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

Agreed, that's why I'm thinking it could be the default behavior (with no option to change it).

That would require modifying this block:

# If the sessions framework is enabled and the token is valid,
# persist the login in session.
if hasattr(request, 'session') and user is not None:
login(request, user)

to add something like:

    # deconstruct URL
    # remove url_auth_token parameter
    # reconstruct URL
    # redirect

from django-sesame.

jacebrowning avatar jacebrowning commented on July 29, 2024

👍 That flow is very similar to what I've implemented in another app to achieve this effect.

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

PR welcome :-)

NB - you'll need to tweak __call__ as well.

from django-sesame.

jacebrowning avatar jacebrowning commented on July 29, 2024

Should the token be removed from the URL if authentication fails?

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

Good question! Probably not?

from django-sesame.

jacebrowning avatar jacebrowning commented on July 29, 2024

I think I agree. The PR I submitted keeps the token on failed auth.

from django-sesame.

paterlinimatias avatar paterlinimatias commented on July 29, 2024

Unfortunately this is not working for safari, as it is against setting cookies in 302 redirects.

When someone wraps the url with the token (for example to make a bit.ly short url, or an automated url defense software ) it fails in safari (both ios and desktop.)

from django-sesame.

paterlinimatias avatar paterlinimatias commented on July 29, 2024

is there any chance for you to make this optional ?

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

This sounds like a side-effect of the over-zealous "Protection Against First Party Bounce Trackers" in ITP 2.0.

Do all redirects happen on the same domain? Or do you change first-party domain e.g. from https://example.com/ to https://www.example.com/?

from django-sesame.

paterlinimatias avatar paterlinimatias commented on July 29, 2024

The domain was different, which Is probably the case when you do url shortening, same goes for url defenders.

Unfortunately this failed for us in the middle of a huge demo when the guys tried using it with their corporate email (which uses proof point.com)

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

To be honest I'd rather implement something that works well for most users rather expect them to learn the intricacies of ITP and determine that they may need to tweak a setting.
`
Perhaps we could redirect only in circumstances that are deemed "ITP-safe", for example when there is no referrer from a different domain — there should be one from proofpoint.com in your example.

from django-sesame.

paterlinimatias avatar paterlinimatias commented on July 29, 2024

I think that's fair enough.

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

For the record, there've been several discussions of ITP on the django-developers mailing-list. Apparently there are many use cases where ITP is over-zealous and blocks perfectly legitimate behavior.

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

Probably we should just sniff the user agent disable the redirection on Safari... It isn't critical to django-sesame's functionality.

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

That would have been a good plan if it had been possible to detect Safari reliably with its user agent...

from django-sesame.

aaugustin avatar aaugustin commented on July 29, 2024

Does #22 work for you? Don't forget to pip install ua-parser, else it won't do anything.

I didn't make ua-parser a mandatory dependency because I'm not comfortable adding 0.2-0.5s to the boot time of every app that uses django-sesame just because Safari is annoying.

from django-sesame.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.