Skip to content

Commit

Permalink
Addresses feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Apr 1, 2024
1 parent 366f413 commit 4317901
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion public/apps/login/test/login-page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ describe('Login page', () => {
const config: ClientConfigType = {
ui: configUI,
auth: {
type: [AuthType.BASIC, 'openid', AuthType.SAML],
type: [AuthType.BASIC, AuthType.OPEN_ID, AuthType.SAML],
logout_url: API_AUTH_LOGOUT,
},
};
Expand Down
20 changes: 10 additions & 10 deletions server/auth/types/saml/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ export class SamlAuthRoutes {
}

try {
const credentials = await this.securityClient.authToken(
const credentials = await this.securityClient.authToken({
requestId,
request.body.SAMLResponse,
undefined,
SAML_AUTH_REQUEST_TYPE
);
samlResponse: request.body.SAMLResponse,
acsEndpoint: undefined,
authRequestType: SAML_AUTH_REQUEST_TYPE,
});
const user = await this.securityClient.authenticateWithHeader(
request,
'authorization',
Expand Down Expand Up @@ -215,12 +215,12 @@ export class SamlAuthRoutes {
async (context, request, response) => {
const acsEndpoint = `${this.coreSetup.http.basePath.serverBasePath}/_opendistro/_security/saml/acs/idpinitiated`;
try {
const credentials = await this.securityClient.authToken(
undefined,
request.body.SAMLResponse,
const credentials = await this.securityClient.authToken({
requestId: undefined,
samlResponse: request.body.SAMLResponse,
acsEndpoint,
SAML_AUTH_REQUEST_TYPE
);
authRequestType: SAML_AUTH_REQUEST_TYPE,
});
const user = await this.securityClient.authenticateWithHeader(
request,
'authorization',
Expand Down
19 changes: 13 additions & 6 deletions server/backend/opensearch_security_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ export class SecurityClient {
throw new Error(`Invalid SAML configuration.`);
}

public async authToken(
requestId: string | undefined,
samlResponse: any,
acsEndpoint: any | undefined = undefined,
authRequestType: string | undefined
) {
public async authToken({
requestId,
samlResponse,
acsEndpoint = undefined,
authRequestType,
}: AuthTokenParams) {
const body = {
RequestId: requestId,
SAMLResponse: samlResponse,
Expand All @@ -244,3 +244,10 @@ export class SecurityClient {
}
}
}

interface AuthTokenParams {
requestId?: string;
samlResponse: any;
acsEndpoint?: any;
authRequestType?: string;
}

0 comments on commit 4317901

Please sign in to comment.