-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add SSO support #1053
Merged
Merged
Add SSO support #1053
Conversation
This file contains 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
02ab5c8
to
6b3a794
Compare
6b3a794
to
c88f301
Compare
duranb
requested changes
Dec 11, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set AUTH_TYPE
to "none", but it still redirects me to the CAM login. Also, after logging in to CAM, I wasn't redirected back to aerie-ui. I think whatever is doing the redirect is not including the goto
return url to CAM
7925455
to
5825847
Compare
a23dac9
to
9a94b89
Compare
duranb
reviewed
Dec 13, 2023
cf52541
to
f5fb845
Compare
duranb
reviewed
Dec 15, 2023
359d094
to
0009275
Compare
prevents `user` being typed as possibly undefined, which svelte-check didn't like
"NoAuthAdapter" now fulfills the use case where no auth is desired
95eb41a
to
76fb36d
Compare
JosephVolosin
pushed a commit
that referenced
this pull request
Aug 20, 2024
* add new `reqGateway` function that passes cookies * Rework auth hook logic to support SSO * Add support for new gateway auth endpoints. This commit also removes the auth redirection logic from the UI, since this is handled by the gateway instead, which will return a redirect if deemed necessary. * fix lint errors * update tests for new login flow * add referrer to validation requests * fix redirection logic * decode URI encoded cookies * add ability to start local UI with https * add ability to specify local host domain * run prettier * throw redirect instead of returning prevents `user` being typed as possibly undefined, which svelte-check didn't like * remove `PUBLIC_LOGIN_PAGE` "NoAuthAdapter" now fulfills the use case where no auth is desired * add example env vars for local HTTPS + domain dev * add new `PUBLIC_AUTH_TYPE` env var * switch auth flow based on new env var * run prettier * change auth type env var to boolean * document new sso env var * refactor nullish assign * fix test env vars * restore feature parity with logout reason * add error handling to cookie parsing * fix role switching with SSO flow * add env var mock to login tests * fix redirection loop by replacing `isDataRequest` conditional * fix redirect loop * fix logout cookie setting race condition --------- Co-authored-by: bduran <[email protected]>
JosephVolosin
pushed a commit
that referenced
this pull request
Oct 21, 2024
* add new `reqGateway` function that passes cookies * Rework auth hook logic to support SSO * Add support for new gateway auth endpoints. This commit also removes the auth redirection logic from the UI, since this is handled by the gateway instead, which will return a redirect if deemed necessary. * fix lint errors * update tests for new login flow * add referrer to validation requests * fix redirection logic * decode URI encoded cookies * add ability to start local UI with https * add ability to specify local host domain * run prettier * throw redirect instead of returning prevents `user` being typed as possibly undefined, which svelte-check didn't like * remove `PUBLIC_LOGIN_PAGE` "NoAuthAdapter" now fulfills the use case where no auth is desired * add example env vars for local HTTPS + domain dev * add new `PUBLIC_AUTH_TYPE` env var * switch auth flow based on new env var * run prettier * change auth type env var to boolean * document new sso env var * refactor nullish assign * fix test env vars * restore feature parity with logout reason * add error handling to cookie parsing * fix role switching with SSO flow * add env var mock to login tests * fix redirection loop by replacing `isDataRequest` conditional * fix redirect loop * fix logout cookie setting race condition --------- Co-authored-by: bduran <[email protected]>
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.
closes NASA-AMMOS/aerie#1100
This PR significantly reworks the
hooks.server.ts
logic to support SSO in addition to the/login
page. Using a new environment variablePUBLIC_AUTH_SSO_ENABLED
, the top level hook auth flow is now as follows:handleJWTAuth
handleJWTAuth
is just a refactored version of the existing auth flow:event.locals.user
using existing JWT cookie (by hitting Gateway's/auth/session
)/login
handleSSOAuth
handleSSOAuth
is a new flow that supports SSO auth by forwarding cookies to new Gateway endpoints, which will check SSO token validity (e.g. CAM token) and return JWTs or redirections accordingly:/auth/validateSSO
, which will run an auth provider specific SSO validationAuth:
headers as usual.Logout
The UI also switches on this
PUBLIC_AUTH_SSO_ENABLED
env var during logout, where it'll either call the Gateway's/auth/logoutSSO
(which invalidates the SSO token using the auth provider), or just clear the JWT and redirect to/
.On the next page load, the UI will run through the auth flow in
hooks.server.ts
, which will correctly redirect us to either/login
or the SSO login page, depending onPUBLIC_AUTH_SSO_ENABLED
.This design allows the UI to remain auth provider agnostic. The Gateway can then be extended to support other auth providers (e.g. https://aws.amazon.com/cognito).
The corresponding Gateway PR (NASA-AMMOS/aerie-gateway#51) defines these new auth endpoints, as well as lists the testing steps and possible env var configurations.