1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 19:53:43 +00:00

Modifications made to support SSO in Browser

This commit is contained in:
Matt Smith
2020-08-11 15:25:07 -05:00
parent 679c7780e0
commit 1d0b549123
11 changed files with 163 additions and 17 deletions

View File

@@ -3,6 +3,9 @@
<div class="logo-image"></div>
<p class="lead text-center">{{'loginOrCreateNewAccount' | i18n}}</p>
<a class="btn primary block" routerLink="/login"><b>{{'login' | i18n}}</b></a>
<a (click)="launchSsoBrowser()" class="btn block">
<i class="fa fa-bank" aria-hidden="true"></i> {{'enterpriseSingleSignOn' | i18n}}
</a>
<a class="btn block" routerLink="/register">{{'createAccount' | i18n}}</a>
</div>
</div>

View File

@@ -1,7 +1,45 @@
import { Component } from '@angular/core';
import { CryptoFunctionService } from 'jslib/abstractions/cryptoFunction.service';
import { EnvironmentService } from 'jslib/abstractions/environment.service';
import { PlatformUtilsService } from '../../../jslib/src/abstractions/platformUtils.service';
import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration.service';
import { Utils } from 'jslib/misc/utils';
@Component({
selector: 'app-home',
templateUrl: 'home.component.html',
})
export class HomeComponent { }
export class HomeComponent {
constructor(
protected platformUtilsService: PlatformUtilsService, private passwordGenerationService : PasswordGenerationService,
private cryptoFunctionService: CryptoFunctionService, private environmentService: EnvironmentService) { }
async launchSsoBrowser() {
// Generate necessary sso params
const passwordOptions: any = {
type: 'password',
length: 64,
uppercase: true,
lowercase: true,
numbers: true,
special: false,
};
const state = await this.passwordGenerationService.generatePassword(passwordOptions);
let ssoCodeVerifier = await this.passwordGenerationService.generatePassword(passwordOptions);
const codeVerifierHash = await this.cryptoFunctionService.hash(ssoCodeVerifier, 'sha256');
const codeChallenge = Utils.fromBufferToUrlB64(codeVerifierHash);
const webUrl = 'https://localhost:8080';
const clientId = 'browser';
const ssoRedirectUri = 'https://localhost:8080/sso-connector.html';
// Launch browser
this.platformUtilsService.launchUri(webUrl + '/#/sso?clientId=' + clientId +
'&redirectUri=' + encodeURIComponent(ssoRedirectUri) +
'&state=' + state + '&codeChallenge=' + codeChallenge +
'&codeVerifier=' + ssoCodeVerifier);
}
}