Repository navigation
Feat/mcdi auth - #83
Closed
ademboukabes wants to merge 12 commits into
Closed
ademboukabes wants to merge 12 commits into
ademboukabes wants to merge 12 commits into
Conversation
…uth and account linking
…bility This commit restores the legacy mobile email/password and OTP login/registration endpoints and service methods, ensuring backward compatibility alongside the new MCDI SSO flow. Also includes minor test file formatting.
…ntend setup Co-authored-by: adem boukabes <142881379+ademboukabes@users.noreply.github.com>
…ui-7696c83a Build the senior multAI workspace interface
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch had an error being deployed
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.
Description
This PR migrates the authentication system of
multAIfrom a custom email/password + OTP flow to the MicroClub Digital Identity (MCDI) OAuth Single Sign-On (SSO). MCDI is the centralized identity provider used across MicroClub services, and this integration allows multAI users to authenticate using their existing MCDI accounts instead of managing separate credentials.Context
Previously, the backend handled authentication entirely on its own: users would register with an email and password, verify via a one-time password (OTP) sent by email, and then log in with their credentials. With this PR, the backend now supports authenticating through MCDI's OAuth2 flow, where the frontend redirects the user to MCDI's login page, receives an authorization code, and sends it to our backend to exchange it for a valid session.
Both the old method (email/password/OTP) and the new method (MCDI SSO) coexist in the codebase. The old method is kept intact because it is still used during development and testing, and may serve as a fallback for the mobile app in the future.
What was added
New service:
McdiService(app/service/mcdi.py)logoutmethod that revokes the MCDI token on the identity provider side.New endpoint:
POST /mobile/auth/mcdi/exchange(app/router/mobile/auth.py)McdiService.New endpoint: staff/web MCDI authentication (
app/router/web/auth.py,app/deps/cookie_auth.py)Updated
AuthService/UsersService(app/service/users.py)mcdi_exchangemethod that orchestrates the full flow: token exchange, profile fetch, user lookup/creation, and session creation.mcdi_servicedependency is optional, so services that do not need MCDI (e.g., background workers) are not affected.mobile_login,mobile_register,mobile_register_resend_otp,verify_mobile_register) remain unchanged and fully functional.Updated database layer (
db/generated/user.py)create_usernow accepts optional parameters (e.g.,discord_id) to support creating users from MCDI profiles where no password is provided.What was NOT changed
/login,/register,/register/resend,/register/verify) are untouched. They work exactly as before.discord_idcolumn on the users table is used for MCDI account linking.Testing
tests/unit/test_mcdi_auth.pycovering:Configuration
The following environment variables must be set for MCDI to work (already present in
.env.example):MCDI_CLIENT_IDMCDI_CLIENT_SECRETMCDI_REDIRECT_URIMCDI_SERVER_IDThis PR targets the
developbranch.