-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[PM-9723] Refresh: LoginViaAuthRequestComponent #11545
base: main
Are you sure you want to change the base?
[PM-9723] Refresh: LoginViaAuthRequestComponent #11545
Conversation
…(), and buildAuthRequestLoginCredentials()
…eqDeletedOrDenied()
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #11545 +/- ##
==========================================
- Coverage 33.48% 33.42% -0.07%
==========================================
Files 2846 2850 +4
Lines 89196 89399 +203
Branches 17002 17038 +36
==========================================
+ Hits 29867 29878 +11
- Misses 56976 57168 +192
Partials 2353 2353 ☔ View full report in Codecov by Sentry. |
New Issues
Fixed Issues
|
…already authed via SSO
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.
Excellent work. No major issues - just a few comments below:
libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts
Show resolved
Hide resolved
…ing legacy LoginViaAuthRequestV1Components
* *********************************** | ||
* Admin Auth Request Flows | ||
* *********************************** | ||
* | ||
* Flow 1: Authed SSO TD user who has a masterKey in memory requests admin approval. | ||
* | ||
* SSO TD user who has a masterKey in memory authenticates via SSO > navigates to /login-initiated > clicks "Request admin approval" | ||
* > navigates to /admin-approval-requested which creates an AdminAuthRequest > receives approval from device with authRequestPublicKey(masterKey) | ||
* > decrypts masterKey > decrypts userKey > establishes trust (if required) > proceeds to vault | ||
* | ||
* Flow 2: Authed SSO TD user who does NOT have a masterKey in memory requests admin approval. | ||
* | ||
* SSO TD user who does NOT have a masterKey in memory authenticates via SSO > navigates to /login-initiated > clicks "Request admin approval" | ||
* > navigates to /admin-approval-requested which creates an AdminAuthRequest > receives approval from device with authRequestPublicKey(userKey) | ||
* > decrypts userKey > establishes trust (if required) > proceeds to vault |
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.
Am I correct in understanding that "Flow 1" here is not actually a flow? That is, when dealing with an Admin Auth Request, we are always receiving an encrypted UserKey, not a MasterKey, meaning Flow 1 is not truly a flow?
If I am correct, then I would re-write this section as one flow in total, making no mention of having a MasterKey in memory or not. Which would look like:
***********************************
Admin Auth Request Flows
***********************************
Flow 1: Authed SSO TD user requests admin approval.
SSO TD user authenticates via SSO > navigates to /login-initiated > clicks "Request admin approval"
> navigates to /admin-approval-requested which creates an AdminAuthRequest
> receives approval from device with authRequestPublicKey(userKey) > decrypts userKey
> establishes trust (if required) > proceeds to vault
const userHasAuthenticatedViaSSO = this.authStatus === AuthenticationStatus.Locked; | ||
|
||
if (userHasAuthenticatedViaSSO) { | ||
// Get the auth request from the server | ||
// User is authenticated, therefore the endpoint does not require an access code. | ||
const authRequestResponse = await this.authRequestApiService.getAuthRequest(requestId); | ||
|
||
if (authRequestResponse.requestApproved) { | ||
// Handles Standard Flows 3-4 and Admin Flows 1-2 | ||
await this.handleAuthenticatedFlows(authRequestResponse); | ||
} | ||
} else { | ||
// Get the auth request from the server | ||
// User is unauthenticated, therefore the endpoint requires an access code for user verification. | ||
const authRequestResponse = await this.authRequestApiService.getAuthResponse( | ||
requestId, | ||
this.authRequest.accessCode, | ||
); | ||
|
||
if (authRequestResponse.requestApproved) { | ||
// Handles Standard Flows 1-2 | ||
await this.handleUnauthenticatedFlows(authRequestResponse, requestId); | ||
} | ||
} |
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.
Instead of checking the State
to determine the codepath, as we did in the legacy component, I'm using the AuthStatus as this allows me to consolidate two things:
- Getting the auth request from the server using the correct authenticated/unauthenticated endpoint.
- Note that this now means Standard Flows 3-4, which are both authed, will now grab the auth request from
getAuthRequest()
(authed endpoint) instead of fromgetAuthResponse()
(unauthed endpoint). Those flows were previously using the unauthed endpoint because even though they are authed flows, the caseState.StandardAuthRequest
sent them to the unauthed endpoint.
- Note that this now means Standard Flows 3-4, which are both authed, will now grab the auth request from
- Handling the actual flow with a method name that distinguishes authenticated vs unauthenticated flows.
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-9723
📔 Objective
Creates a refreshed and consolidated
LoginViaAuthRequestComponent
for use on all visual clients, which will be used when theUnauthenticatedExtensionUIRefresh
is on.Standard Auth Request Flows
Flow 1: Unauthed user requests approval from device; Approving device has a masterKey in memory.
/login-with-device
which creates a StandardAuthRequest >receives approval from a device with authRequestPublicKey(masterKey) > decrypts masterKey > decrypts userKey >
proceed to vault
Flow 2: Unauthed user requests approval from device; Approving device does NOT have a masterKey in memory.
Unauthed user clicks "Login with device" > navigates to
/login-with-device
which creates a StandardAuthRequest > receives approval from a device with authRequestPublicKey(userKey) > decrypts userKey > proceeds to vaultNote: this flow is an uncommon scenario and relates to TDE off-boarding. The following describes how a user could get into this flow:
Flow 3: Authed SSO TD user requests approval from device; Approving device has a masterKey in memory.
/login-initiated
> clicks "Approve from your other device" > navigates to/login-with-device
which creates a StandardAuthRequest > receives approval from device with authRequestPublicKey(masterKey) > decrypts masterKey > decrypts userKey > establishes trust (if required) > proceeds to vaultFlow 4: Authed SSO TD user requests approval from device; Approving device does NOT have a masterKey in memory.
/login-initiated
> clicks "Approve from your other device" > navigates to/login-with-device
which creates a StandardAuthRequest > receives approval from device with authRequestPublicKey(userKey) > decrypts userKey > establishes trust (if required) > proceeds to vaultAdmin Auth Request Flows
Flow 1: Authed SSO TD user who has a masterKey in memory requests admin approval.
/login-initiated
> clicks "Request admin approval" > navigates to/admin-approval-requested
which creates an AdminAuthRequest > receives approval from device with authRequestPublicKey(masterKey) > decrypts masterKey > decrypts userKey > establishes trust (if required) > proceeds to vaultFlow 2: Authed SSO TD user who does NOT have a masterKey in memory requests admin approval.
/login-initiated
> clicks "Request admin approval" > navigates to/admin-approval-requested
which creates an AdminAuthRequest > receives approval from device with authRequestPublicKey(userKey) > decrypts userKey > establishes trust (if required) > proceeds to vaultSummary Table
[active route]
[/login]
/login-with-device
[/login]
/login-with-device
[/login-initiated]
/login-with-device
[/login-initiated]
/login-with-device
[/login-initiated]
/admin-approval-requested
[/login-initiated]
/admin-approval-requested
Note 1: The phrase "in memory" here is important. It is possible for a user to have a master password for their account, but not have a masterKey IN MEMORY for a specific device. For example, if a user registers an account with a master password, then joins an SSO TD org, then logs in to a device via SSO and admin auth request, they are now logged into that device but that device does not have masterKey IN MEMORY.
📸 Screenshots
Standard Auth Request Flow 1
Unauthed user requests approval from device; Approving device has a
masterKey
in memory.standard-flow-1.mov
Standard Auth Request Flow 2
Unauthed user requests approval from device; Approving device does NOT have a
masterKey
in memory.Note: this flow is an uncommon scenario and relates to TDE off-boarding. The following describes how a user could get into this flow:
masterKey
in memory.2a. Changes the member decryption options from "Trusted devices" to "Master password" AND
2b. Turns off the "Require single sign-on authentication" policy
masterKey
in memory (see step 1 above).standard-flow-2.mov
Standard Auth Request Flow 3
Authed SSO TD user requests approval from device; Approving device has a
masterKey
in memory.standard-flow-3.mov
Standard Auth Request Flow 4
Authed SSO TD user requests approval from device; Approving device does NOT have a
masterKey
in memory.standard-flow-4.mov
Admin Auth Request Flow 2
Authed SSO TD user requests admin approval.
admin-flow-2.mov
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes