Skip to content

[FR] Multiple tokens and scopes for API access per user #2326

Closed

Description

@matmair

Problem
We currently do not support access scopes (see Github) for tokens and only one token per user.

Suggested solution
Tying a token to a user is fine, you just should never show the token again after initial creation. Also, tokens give users no option to make restrictions for tokens so there must be 100% trust in the device and app a token gets added to.

Needed:

  • multiple tokens per user
  • maschine identifiable token format (GH token format -> detection through GitHub sec team)
  • scopes per token
  • new flows that never exposes a token to an API or UI after creation
  • token creation endpoint
  • scope endpoint needs to be checked

Describe alternatives you've considered
The current solution with very limited app selection by core contributors should be fine.

Examples of other systems
Github, Gitlab, Nextcloud

Do you want to develop this?
Yes

Activity

  1. added
    enhancement
    api
    plugin
    and removed
    plugin
    on Nov 18, 2021
  2. added this to the 0.7.0 milestone on Nov 18, 2021
  3. self-assigned this
    on Nov 18, 2021
  4. added
    security
    on Nov 18, 2021
  5. SchrodingersGat commented on Nov 18, 2021

    @SchrodingersGat
    Member

    @matmair very good point.

    The mobile app will need to be updated too, it makes use of the persistent tokens

  6. matmair commented on Nov 18, 2021

    @matmair
    MemberAuthor

    @SchrodingersGat the flow should not change too much. I have never used the app but I think it should be fine.
    In a further step, a modern web-based auth workflow would be great.

    • a webview popup to the inventree instance opens
    • the user logs in (with basic auth, SSO, MFA or whatever)
    • grants the app all needed privileges
    • the webview closes and returns the app token to the token

    This is how OAuth flows handle auth. I like it because it is very seamless to the user, the app never gets credentials and new auth methods/flows are only implemented in web. When requirements change the token gets revoked and the app just calls up the auth flow again. thoughts @SchrodingersGat ?

  7. modified the milestones: 0.7.0, 0.8.0 on Apr 5, 2022
  8. modified the milestones: 0.8.0, 0.9.0 on Jun 6, 2022
  9. 11 remaining items

  10. added this to the horizon milestone on Jul 18, 2023
  11. matmair commented on Oct 3, 2023

    @matmair
    MemberAuthor

    Looks good

  12. SchrodingersGat commented on Oct 4, 2023

    @SchrodingersGat
    Member

    One limitation of the library linked above is the tokens are not internally linked to users.

    This post might be a good reference, it extends the model we are already using:

    https://idiomaticprogrammers.com/post/how-to-implement-auto-expiring-token-in-django-rest-framework/

  13. matmair commented on Oct 4, 2023

    @matmair
    MemberAuthor

    Looks interesting - we could use this with some simple additions.
    I will mark this for Hacktober and tackle it after the end of the event if no one is interested in implementing.

  14. SchrodingersGat commented on Oct 4, 2023

    @SchrodingersGat
    Member

    I have a WIP underway for this :)

  15. moved this from Todo to In Progress in User Interface Redesignon Oct 4, 2023
  16. modified the milestones: horizon, 0.13.0 on Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apienhancementsecurity

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions