Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Revert "Replace _opendistro route with _plugins"" #1038

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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