mirror of
https://github.com/bitwarden/jslib
synced 2025-12-15 15:53:51 +00:00
CSA-2 SSO user interaction token (#780)
* Adding token processing for SSO redirect * Update preValidate return type * Remove unreachable code Co-authored-by: Carlos J. Muentes <cmuentes@bitwarden.com> Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
This commit is contained in:
committed by
GitHub
parent
0d658ba26d
commit
911cf794f4
@@ -6,6 +6,7 @@ import {
|
||||
OrganizationConnectionConfigApis,
|
||||
OrganizationConnectionResponse,
|
||||
} from "jslib-common/models/response/organizationConnectionResponse";
|
||||
import { SsoPreValidateResponse } from "jslib-common/models/response/ssoPreValidateResponse";
|
||||
|
||||
import { PolicyType } from "../enums/policyType";
|
||||
import { SetKeyConnectorKeyRequest } from "../models/request/account/setKeyConnectorKeyRequest";
|
||||
@@ -688,7 +689,7 @@ export abstract class ApiService {
|
||||
fetch: (request: Request) => Promise<Response>;
|
||||
nativeFetch: (request: Request) => Promise<Response>;
|
||||
|
||||
preValidateSso: (identifier: string) => Promise<boolean>;
|
||||
preValidateSso: (identifier: string) => Promise<SsoPreValidateResponse>;
|
||||
|
||||
postCreateSponsorship: (
|
||||
sponsorshipOrgId: string,
|
||||
|
||||
10
common/src/models/response/ssoPreValidateResponse.ts
Normal file
10
common/src/models/response/ssoPreValidateResponse.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { BaseResponse } from "./baseResponse";
|
||||
|
||||
export class SsoPreValidateResponse extends BaseResponse {
|
||||
token: string;
|
||||
|
||||
constructor(response: any) {
|
||||
super(response);
|
||||
this.token = this.getResponseProperty("Token");
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
OrganizationConnectionConfigApis,
|
||||
OrganizationConnectionResponse,
|
||||
} from "jslib-common/models/response/organizationConnectionResponse";
|
||||
import { SsoPreValidateResponse } from "jslib-common/models/response/ssoPreValidateResponse";
|
||||
|
||||
import { ApiService as ApiServiceAbstraction } from "../abstractions/api.service";
|
||||
import { EnvironmentService } from "../abstractions/environment.service";
|
||||
@@ -2295,7 +2296,7 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
return fetch(request);
|
||||
}
|
||||
|
||||
async preValidateSso(identifier: string): Promise<boolean> {
|
||||
async preValidateSso(identifier: string): Promise<SsoPreValidateResponse> {
|
||||
if (identifier == null || identifier === "") {
|
||||
throw new Error("Organization Identifier was not provided.");
|
||||
}
|
||||
@@ -2318,7 +2319,8 @@ export class ApiService implements ApiServiceAbstraction {
|
||||
);
|
||||
|
||||
if (response.status === 200) {
|
||||
return true;
|
||||
const body = await response.json();
|
||||
return new SsoPreValidateResponse(body);
|
||||
} else {
|
||||
const error = await this.handleError(response, false, true);
|
||||
return Promise.reject(error);
|
||||
|
||||
Reference in New Issue
Block a user