Repository navigation
feat(auth): accept "Sign in with µLearn" tokens, auth admin console, authserver-owned passwords - #3251
Merged
Conversation
- Introduced onboarding completeness logic in `utils/onboarding.py` to determine if a user has completed onboarding based on roles and domain count. - Implemented session revocation mechanism in `utils/session_revocation.py` to invalidate sessions upon credential changes, addressing audit finding F3. - Added comprehensive tests for onboarding logic in `utils/test_onboarding.py` to ensure correct behavior across various scenarios. - Created tests for token verification in `utils/test_token_verification.py`, covering both legacy HS256 and new RS256 formats. - Developed token verification logic in `utils/token_verification.py` to handle dual-format tokens, ensuring secure validation and normalization of claims.
…with OAuth client management and session revocation
# Conflicts: # mulearnbackend/celery.py
Contributor
|
- Enhanced ProvisionMemberAPI to handle concurrent signups by wrapping user creation in a transaction, ensuring atomicity and preventing half-provisioned members. - Removed the check_schema_drift.py script and its associated tests, as well as the conftest.py file, streamlining the project structure. - Updated requirements-dev.txt to explicitly include PyJWT and cryptography versions for token verification. - Added JWTUtils.is_logged_in method to check if a request carries a valid token, improving permission handling. - Improved _JWKSCache to manage key fetching and caching more effectively, ensuring that tokens remain verifiable during authserver outages. - Added comprehensive tests for the new JWKS cache behavior, ensuring robustness against key rotation and authserver unavailability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Lets the backend accept the new "Sign in with µLearn" tokens from authserver (RS256 JWTs, checked locally against authserver's public keys), alongside the old login tokens. Current users and the current dashboard keep working unchanged.
It also adds the admin console for the new login, moves password changes to authserver, and gives authserver a protected API to create members at signup.
Pairs with authserver
feat/new-auth. Deploy both together.Main changes
Token checking (
utils/token_verification.py,utils/permission.py)kid, so key rotation needs no restart), plusiss,aud(mulearn-api) andexp.mulearn.readfor reads,mulearn.writefor changes. Partner tokens (nomulearn.*scope) are refused.auth_migration.log:legacy_hs256/oidc_rs256), so we can see when the old login is no longer used.Protected identity API for authserver (
/api/v1/protected/identity/provision-member/, needsPROTECTED_API_KEY)User info (
/api/v1/dashboard/user/info/)onboardingfield:{"state": "COMPLETE" | "INCOMPLETE", "missing": [...], "exempt": bool}, so the dashboard knows when to send new users to onboarding.Password change (
/api/v1/dashboard/profile/change-password/)user.passwordhere. Returns 503 if authserver is down.Auth admin console (
/api/v1/dashboard/auth-admin/, admins only)AUTH_*action types.Hourly token cleanup (
mu_celery/auth_token_cleanup_cron.py)Old signup (kept for now)
RegisterDataAPIstill works, and now logs a counter (mulearn.legacy_signup) so we know when it's safe to remove.Other
db/user.py: declares the existingdeleted_at/deleted_bycolumns (not enforced).scripts/check_schema_drift.py(with tests) and a CI workflow.dev. The only conflict wasmulearnbackend/celery.py, and both Celery jobs are kept.Also in this branch (from
feat/sign-in-with-mulearn, not auth-related):achievement_views.pywraps achievement creation and template generation intry/except. Reviewers: note that it returnsstr(e)to the client.Testing
utf8mb4(the old signup has the same bug).pyteston the whole repo shows 4 collection errors inlearningcircle,mentorandprojectstests. These already happen ondev(several folders are namedtests) and aren't caused by this PR.