-
Notifications
You must be signed in to change notification settings - Fork 6
Add Twake and custom SSO #359
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
Conversation
OIDC url is different that base url we use for usual bitwarden compatible routes so we need to be able to save this OIDC url in environment service.
This login success page will be used as redirect_uri for SSO login. It asks to open the extension to finish the login because it cannot be done automatically.
This home view now display UI for : - login with Twake SSO (implementation starting in this PR) - login directly to the stack by asking Cozy URL (already implemented) - login with external SSO by asking a company email (to be implemented)
Forward instance and OIDC code returned by OIDC login success page
If on login view we have instance and OIDC code : - Forward code argument from login view to login request method - If code argument is present, do a different login request method
const redirectUri = getLoginSuccessPageUri(extensionUri); | ||
|
||
BrowserApi.createNewTab( | ||
`https://oauthcallback.cozy.works/oidc/bitwarden/twake?redirect_uri=${redirectUri}`, // TODO: update URL with production environment |
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.
Maybe I should find a simple way to switch between environment here 🤔 like clicking multiple times on the logo or something like this
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 propose something here 74683dd
For external SSO, we need to fetch the OIDC login uri at a fixed location that can be infered from the email address of the user. We implement a first way with .well-known. We may implement a DoH way later.
In production, we need oauthcallback.mycozy.cloud. To test, we may need other stack environment. So here I implement a simple way to change this environment by clicking on a logo.
this.logoClickCount++; | ||
|
||
if (this.logoClickCount >= 6) { | ||
const rest = this.logoClickCount % 3; | ||
|
||
if (rest === 0) { | ||
this.baseUri = DEV_STACK_OAUTHCALLBACK_URI; | ||
} else if (rest === 1) { | ||
this.baseUri = INT_STACK_OAUTHCALLBACK_URI; | ||
} else if (rest === 2) { | ||
this.baseUri = PROD_STACK_OAUTHCALLBACK_URI; | ||
} | ||
|
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'm not sure about this part, we change the environment based on the number of clicks we do on the application logo?
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.
Exactly
Login button
Open Twake SSO for Twake SaaS users.
Company login by email
Asks for email and start an autodiscovery mechanism fetching a .well-known file at a known URL to load the SSO of the company.
Company login by url
Good old direct login using instance URL kept for self hosted users and as last resort.
Todo :