Skip to content

Commit

Permalink
Revert "Replace _opendistro route with _plugins (#895)" (#1035) (#1036)
Browse files Browse the repository at this point in the history
This reverts commit e4e4032.

(cherry picked from commit cc5b763)

Co-authored-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
  • Loading branch information
1 parent 85e4a01 commit 89a8560
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions server/auth/types/saml/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,21 @@
*/

import { schema } from '@osd/config-schema';
import { IRouter, SessionStorageFactory } from '../../../../../../src/core/server';
import {
IRouter,
SessionStorageFactory,
OpenSearchDashboardsRequest,
} 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 @@ -35,7 +38,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 @@ -81,7 +84,7 @@ export class SamlAuthRoutes {

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

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

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

0 comments on commit 89a8560

Please sign in to comment.