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

[Backport 2.x] Revert "Replace _opendistro route with _plugins" #1036

Merged
merged 1 commit into from
Jul 20, 2022
Merged
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: 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