Giter Club home page Giter Club logo

Comments (8)

awalias avatar awalias commented on May 23, 2024 1

I don't think it's possible for us to force expire an access token? I think we just have to wait for it to expire 🤷‍♂️

from auth.

icecream78 avatar icecream78 commented on May 23, 2024

@awalias what to do in situations when user already got token and after that admin blocked him? do we need handle this case or it's OK and lets wait while his token expire?

from auth.

icecream78 avatar icecream78 commented on May 23, 2024

@awalias maybe better make route like /admin/users/{user_id}/disable and /admin/users/{user_id}/enable and switch method from POST to PATCH? In my opinion, it seems to be more better choice. What do you think?
Sorry for such questions but it's better to ask them before task implementing rather then after finishing it

from auth.

awalias avatar awalias commented on May 23, 2024

I wonder whether we should extend the existing POST /user endpoint with enable/disable functionality:

image

and make a new route for UserUpdate that is only accessible by Admin Users

what do you think? It will enable admins to change other data about a user (and can add more in the future)

from auth.

awalias avatar awalias commented on May 23, 2024

but I also like your solution 🤔

from auth.

icecream78 avatar icecream78 commented on May 23, 2024

Your approach is more scalable in future than mine. OK, I'll implement admin's analog of UserUpdate method=)

from auth.

mstade avatar mstade commented on May 23, 2024

I don't think it's possible for us to force expire an access token? I think we just have to wait for it to expire 🤷‍♂️

This is not necessarily true, and largely depends on how you verify the validity of tokens. Aside from checking the signature, and indeed even before checking the signature, you might want to check the sub (or other relevant claim) against a blacklist to see if the token should be disallowed.

The tricky bit is of course how you make sure your blacklist is accurate and up to date. It may not be palatable to look it up in the DB on every request, but on the other hand if you don't look it up on every request, there's a good chance you'll have a race condition where a request comes in and makes it all the way before the blacklist is propagated to wherever tokens are checked. To be fair though, depending on where in the flow you're checking the validity of a token you may well end up with a race condition anyway.

The way I've done this in the past is to have a mechanism for blacklisting tokens based on one or a combination of claims, e.g. for individual users it may be the sub claim, for groups of users it may be something else, a custom claim like grp or even individual role permissions like role. Maybe it's a combination of things, maybe a user should have general access, but lost admin privileges so any token with sub=1234 and role='admin' should be rejected. This blacklist lives at the API gateway, and that's the source of truth. Anything that gets passed the gateway is assumed to be valid (though signatures may still be checked, just not blacklist rules,) and anything behind the gateway only accepts requests coming from the gateway. Any request coming from another source is dropped without further consideration.

It's a decent compromise which allows for blocking tokens even if their expiration time is quite far in to the future. Blacklist rules generally don't expire, so care has to be taken to make it performant, and that of course largely depends on how complicated the rules can get. If all you're doing is field comparison it's a pretty fast lookup, but if you start doing fancy stuff like regex checks or multiple field comparisons you have to be real careful to make sure the expensive checks happen as late as possible, and the cheap checks act as circuit breakers first.

from auth.

github-actions avatar github-actions commented on May 23, 2024

🎉 This issue has been resolved in version 2.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

from auth.

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.