-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sso): [PM-8114] implement SSO component UI refresh
Consolidates existing SSO components into a single unified component in libs/auth, matching the new design system. This implementation: - Creates a new shared SsoComponent with extracted business logic - Adds feature flag support for unauth-ui-refresh - Updates page styling including new icons and typography - Preserves web client claimed domain logic - Maintains backwards compatibility with legacy views PM-8114 --------- Co-authored-by: Jared Snider <[email protected]> Co-authored-by: Jared Snider <[email protected]>
- Loading branch information
1 parent
bfa9cf3
commit 0df7b53
Showing
33 changed files
with
1,005 additions
and
45 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
apps/browser/src/auth/popup/login/extension-sso-component.service.spec.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { TestBed } from "@angular/core/testing"; | ||
import { mock, MockProxy } from "jest-mock-extended"; | ||
import { BehaviorSubject } from "rxjs"; | ||
|
||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; | ||
import { | ||
EnvironmentService, | ||
Environment, | ||
} from "@bitwarden/common/platform/abstractions/environment.service"; | ||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; | ||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; | ||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; | ||
|
||
import { BrowserApi } from "../../../platform/browser/browser-api"; | ||
|
||
import { ExtensionSsoComponentService } from "./extension-sso-component.service"; | ||
|
||
describe("ExtensionSsoComponentService", () => { | ||
let service: ExtensionSsoComponentService; | ||
const baseUrl = "https://vault.bitwarden.com"; | ||
|
||
let syncService: MockProxy<SyncService>; | ||
let authService: MockProxy<AuthService>; | ||
let environmentService: MockProxy<EnvironmentService>; | ||
let i18nService: MockProxy<I18nService>; | ||
let logService: MockProxy<LogService>; | ||
|
||
beforeEach(() => { | ||
syncService = mock<SyncService>(); | ||
authService = mock<AuthService>(); | ||
environmentService = mock<EnvironmentService>(); | ||
i18nService = mock<I18nService>(); | ||
logService = mock<LogService>(); | ||
environmentService.environment$ = new BehaviorSubject<Environment>({ | ||
getWebVaultUrl: () => baseUrl, | ||
} as Environment); | ||
|
||
TestBed.configureTestingModule({ | ||
providers: [ | ||
{ provide: SyncService, useValue: syncService }, | ||
{ provide: AuthService, useValue: authService }, | ||
{ provide: EnvironmentService, useValue: environmentService }, | ||
{ provide: I18nService, useValue: i18nService }, | ||
{ provide: LogService, useValue: logService }, | ||
ExtensionSsoComponentService, | ||
], | ||
}); | ||
|
||
service = TestBed.inject(ExtensionSsoComponentService); | ||
|
||
jest.spyOn(BrowserApi, "reloadOpenWindows").mockImplementation(); | ||
}); | ||
|
||
it("creates the service", () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
|
||
describe("closeWindow", () => { | ||
it("closes window", async () => { | ||
const windowSpy = jest.spyOn(window, "close").mockImplementation(); | ||
|
||
await service.closeWindow?.(); | ||
|
||
expect(windowSpy).toHaveBeenCalled(); | ||
}); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
apps/browser/src/auth/popup/login/extension-sso-component.service.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Injectable } from "@angular/core"; | ||
|
||
import { DefaultSsoComponentService, SsoComponentService } from "@bitwarden/auth/angular"; | ||
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; | ||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; | ||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; | ||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; | ||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; | ||
|
||
/** | ||
* This service is used to handle the SSO login process for the browser extension. | ||
*/ | ||
@Injectable() | ||
export class ExtensionSsoComponentService | ||
extends DefaultSsoComponentService | ||
implements SsoComponentService | ||
{ | ||
constructor( | ||
protected syncService: SyncService, | ||
protected authService: AuthService, | ||
protected environmentService: EnvironmentService, | ||
protected i18nService: I18nService, | ||
protected logService: LogService, | ||
) { | ||
super(); | ||
} | ||
|
||
/** | ||
* Closes the popup window after a successful login. | ||
*/ | ||
async closeWindow() { | ||
window.close(); | ||
} | ||
} |
File renamed without changes.
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
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
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
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
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
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
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
File renamed without changes.
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
36 changes: 36 additions & 0 deletions
36
apps/web/src/app/auth/core/services/login/web-sso-component.service.spec.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { TestBed } from "@angular/core/testing"; | ||
import { mock, MockProxy } from "jest-mock-extended"; | ||
|
||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; | ||
|
||
import { WebSsoComponentService } from "./web-sso-component.service"; | ||
|
||
describe("WebSsoComponentService", () => { | ||
let service: WebSsoComponentService; | ||
let i18nService: MockProxy<I18nService>; | ||
|
||
beforeEach(() => { | ||
i18nService = mock<I18nService>(); | ||
|
||
TestBed.configureTestingModule({ | ||
providers: [WebSsoComponentService, { provide: I18nService, useValue: i18nService }], | ||
}); | ||
service = TestBed.inject(WebSsoComponentService); | ||
}); | ||
|
||
it("creates the service", () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
|
||
describe("setDocumentCookies", () => { | ||
it("sets ssoHandOffMessage cookie with translated message", () => { | ||
const mockMessage = "Test SSO Message"; | ||
i18nService.t.mockReturnValue(mockMessage); | ||
|
||
service.setDocumentCookies?.(); | ||
|
||
expect(document.cookie).toContain(`ssoHandOffMessage=${mockMessage}`); | ||
expect(i18nService.t).toHaveBeenCalledWith("ssoHandOff"); | ||
}); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
apps/web/src/app/auth/core/services/login/web-sso-component.service.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Injectable } from "@angular/core"; | ||
|
||
import { DefaultSsoComponentService, SsoComponentService } from "@bitwarden/auth/angular"; | ||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; | ||
|
||
/** | ||
* This service is used to handle the SSO login process for the web client. | ||
*/ | ||
@Injectable() | ||
export class WebSsoComponentService | ||
extends DefaultSsoComponentService | ||
implements SsoComponentService | ||
{ | ||
constructor(private i18nService: I18nService) { | ||
super(); | ||
} | ||
|
||
setDocumentCookies() { | ||
document.cookie = `ssoHandOffMessage=${this.i18nService.t("ssoHandOff")};SameSite=strict`; | ||
} | ||
} |
File renamed without changes.
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
Oops, something went wrong.