Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): Add admin & early access flags based on orgs membership #1365

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

nsarrazin
Copy link
Collaborator

@nsarrazin nsarrazin commented Jul 26, 2024

This PR adds a check on the login callback, so that if a user is part of a specific hub org they will get access to early access or admin features automatically.

This can be used to feature flag new features or give moderation rights automatically without going through the DB.

Caveat is that the check only occurs on login, so flags are only updated on log-in, not when reusing a session. I think this is an OK tradeoff and if we need to force update flags on someone we can always either do it manually or force a logout by deleting matching sessions.

@nsarrazin nsarrazin added enhancement New feature or request back This issue is related to the Svelte backend or the DB labels Jul 26, 2024
@nsarrazin
Copy link
Collaborator Author

nsarrazin commented Jul 26, 2024

cc @coyotte508

I tried to keep it simple, no rush at all but let me know if you think this makes sense as an implementation! 😄

Copy link
Member

@coyotte508 coyotte508 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice!

For the caveat, maybe we can switch to oauth-based sessions now that we have refresh tokens on HF. (so that we always have a valid oauth token)

Or if it's HF-only, we can use the /api/users/.../overview endpoint

@julien-c
Copy link
Member

what would be the impact on the measurement of DAUs?

maybe we can switch to oauth-based sessions

@coyotte508
Copy link
Member

what would be the impact on the measurement of DAUs?

maybe we can switch to oauth-based sessions

I don't think any?

The user would be redirected to signin once, which would be seemless most likely

The sessions currently expire after two weeks of inactivity, and the oauth refresh tokens last 3 months, so we could renew the refresh token after one month and there would be no perceived difference

@nsarrazin
Copy link
Collaborator Author

Opened #1377 to track the idea of using refresh tokens for the auth flow, will merge this PR for now as I think it can be tackled separately!

@nsarrazin nsarrazin merged commit a3f5e2a into main Jul 29, 2024
4 checks passed
@nsarrazin nsarrazin deleted the feat/auth-org-flags branch July 29, 2024 11:23
@nsarrazin nsarrazin mentioned this pull request Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back This issue is related to the Svelte backend or the DB enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants