JS2-Gateway Authentication and User Infrastructure Explained #33
Closed
Knguyen-dev
started this conversation in
General
Replies: 1 comment
-
|
Not needed anymore, everything is in #38. Also it's more clear and it's a big improvement in #38 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
JS2-Gateway Authentication and User Infrastructure
Explaining CILogon
What is CILogon
OIDC (OpenID Connect) allows users to log in through third-party identity providers (like Google), but most major providers require you to register and sometimes pay. CILogon is a free identity platform designed for researchers, universities, and federally recognized institutions. What makes CILogon special is that it supports over 5,000 identity providers, including:
This allows users to log in with either common accounts (e.g. Google) or their institutional credentials.
Note: To use CILogon, your app must be affiliated with an approved institution (like a university or research org).
Scopes and Claims
When you authenticate with CILogon, you typically request the openid scope.Minimal claims guaranteed under openid:
sub: Unique user ID across the provideriss: The issuer (CILogon)Optional scopes:
email: May provide user’s email (if available)org.cilogon.userinfo: Adds CILogon-specific claims:idp: Identity provider’s unique ID (e.g., Google, IU)idp_name: Human-readable name of the providerThese optional claims may not always be present — always handle missing fields gracefully. Our app does this, so that's fine.
Database Design and Infrastructure
While JS2 uses containers, it doesn't have a PostgreSQL container. The application connects to an external database that's hosted on IU's servers (Big Red 200). Here's the flow:
In
database.py, we connect to our external database:This is run automatically on container start since we do a little trick by importing the code, which runs it.
In
models.pywe define our database model. Let me explain the context behind the database setup:Auth. Infrastructure
Authentication Flow and User Journey:
Let's map out the user journey. The user goes to the application, they hit the sign-in button. This redirects them to our first API route in the process
/auth.auth_me (
/auth):https://cilogon.org/authorizeendpoint where the user can authenticate using whatever IDP they want.profileto get the user's name. We wantemailsince that's pretty important for communication. And we want theorg.cilogon.userinfobecause that can give us the institution that they authenticated with.auth_callback flow (
/callback):Now that the user has been redirected, the
AuthProvidercomponent will run an effect that hits the/auth/meendpoint. This starts the last chain in our OIDC authentication process.auth_me (
/auth/me) flow:user_authobject containing all the info we have recorded about them. So return a response with thisuser_authobject.The client will receive the user's information, update the states, and then the user should officially be logged in. If the user ever wants to logout, then we just hit the auth_logout (
/auth/logout) route, delete their cookie, and redirect them to the home page saying they logged out.Onboarding Flow
After registering for the first time, a user will need to get onboarded. This just means that they have to confirm their information with us, and after that they're all set.
OnboardingCheckwill see that they're not onboarded yet and redirect them to the/onboardingroute./api/user/onboardendpoint.complete_onboarding (
/api/user/onboard)Admin Dashboard and Approval Flow
The admin dashboard is useful for whether we want to update the user. Essentially, an admin would hit a button to update the user, toggling their admin rights, approval status, etc. This hits the update_user (
/api/admin/users/:userId) route:auth_utils.py, and it ensures that the user making the request is an admin. It goes through getting the user from the access token cookie and ensuring the user is an admin in our app.admin_rights, then we don't update it.Email Services
The last thing I want to talk about is the email services. Emails are mainly sent when a user is registered and needs to be approved. Here are the various emails we send out:
Beta Was this translation helpful? Give feedback.
All reactions