Skip to content

Commit

Permalink
Revert "Revert "Replace _opendistro route with _plugins (opensearch-p…
Browse files Browse the repository at this point in the history
…roject#895)" (opensearch-project#1035)"

This reverts commit c456883362610c61fcc5d54b2974d7a5c6327c1d.

Signed-off-by: Vasile Negru <[email protected]>
Signed-off-by: Vasile Negru <[email protected]>
  • Loading branch information
Vasile Negru committed Aug 8, 2022
1 parent 766a07e commit 257d9ea
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions server/auth/types/saml/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@
*/

import { schema } from '@osd/config-schema';
import {
IRouter,
SessionStorageFactory,
OpenSearchDashboardsRequest,
} from '../../../../../../src/core/server';
import { IRouter, SessionStorageFactory } from '../../../../../../src/core/server';
import { SecuritySessionCookie } from '../../../session/security_cookie';
import { SecurityPluginConfigType } from '../../..';
import { SecurityClient } from '../../../backend/opensearch_security_client';
import { API_AUTH_LOGOUT } from '../../../../common';
import { CoreSetup } from '../../../../../../src/core/server';
import { validateNextUrl } from '../../../utils/next_url';
import { AuthType } from '../../../../common/index';

export class SamlAuthRoutes {
constructor(
private readonly router: IRouter,
// @ts-ignore: unused variable
private readonly config: SecurityPluginConfigType,
private readonly sessionStorageFactory: SessionStorageFactory<SecuritySessionCookie>,
private readonly securityClient: SecurityClient,
Expand All @@ -38,7 +35,7 @@ export class SamlAuthRoutes {
public setupRoutes() {
this.router.get(
{
path: `/auth/saml/login`,
path: '/auth/saml/login',
validate: {
query: schema.object({
nextUrl: schema.maybe(
Expand Down Expand Up @@ -84,7 +81,7 @@ export class SamlAuthRoutes {

this.router.post(
{
path: `/_opendistro/_security/saml/acs`,
path: '/_plugins/_security/saml/acs',
validate: {
body: schema.any(),
},
Expand Down Expand Up @@ -139,7 +136,7 @@ export class SamlAuthRoutes {
credentials: {
authHeaderValue: credentials.authorization,
},
authType: 'saml', // TODO: create constant
authType: AuthType.SAML,
expiryTime,
};
this.sessionStorageFactory.asScoped(request).set(cookie);
Expand All @@ -160,7 +157,7 @@ export class SamlAuthRoutes {

this.router.post(
{
path: `/_opendistro/_security/saml/acs/idpinitiated`,
path: '/_plugins/_security/saml/acs/idpinitiated',
validate: {
body: schema.any(),
},
Expand All @@ -169,7 +166,7 @@ export class SamlAuthRoutes {
},
},
async (context, request, response) => {
const acsEndpoint = `${this.coreSetup.http.basePath.serverBasePath}/_opendistro/_security/saml/acs/idpinitiated`;
const acsEndpoint = `${this.coreSetup.http.basePath.serverBasePath}/_plugins/_security/saml/acs/idpinitiated`;
try {
const credentials = await this.securityClient.authToken(
undefined,
Expand Down Expand Up @@ -197,7 +194,7 @@ export class SamlAuthRoutes {
credentials: {
authHeaderValue: credentials.authorization,
},
authType: 'saml', // TODO: create constant
authType: AuthType.SAML,
expiryTime,
};
this.sessionStorageFactory.asScoped(request).set(cookie);
Expand All @@ -217,7 +214,7 @@ export class SamlAuthRoutes {

this.router.get(
{
path: `/auth/logout`,
path: API_AUTH_LOGOUT,
validate: false,
},
async (context, request, response) => {
Expand Down

0 comments on commit 257d9ea

Please sign in to comment.