Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const OPENID_AUTH_LOGIN_WITH_FRAGMENT = '/auth/openid/captureUrlFragment'
export const SAML_AUTH_LOGIN = '/auth/saml/login';
export const SAML_AUTH_LOGIN_WITH_FRAGMENT = '/auth/saml/captureUrlFragment';
export const ANONYMOUS_AUTH_LOGIN = '/auth/anonymous';
export const AUTH_TYPE_PARAM = 'auth_type';

export const OPENID_AUTH_LOGOUT = '/auth/openid/logout';
export const SAML_AUTH_LOGOUT = '/auth/saml/logout';
Expand Down
2 changes: 1 addition & 1 deletion server/auth/types/basic/basic_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class BasicAuthentication extends AuthenticationType {
request,
this.coreSetup.http.basePath.serverBasePath
);
if (this.config.auth.anonymous_auth_enabled) {
if (this.config.auth.anonymous_auth_enabled && !this.config.auth.multiple_auth_enabled) {
const redirectLocation = `${this.coreSetup.http.basePath.serverBasePath}${ANONYMOUS_AUTH_LOGIN}?${nextUrlParam}`;
return response.redirected({
headers: {
Expand Down
10 changes: 1 addition & 9 deletions server/auth/types/multiple/multi_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { OpenSearchDashboardsResponse } from '../../../../../../src/core/server/http/router';
import { SecurityPluginConfigType } from '../../..';
import { AuthenticationType } from '../authentication_type';
import { ANONYMOUS_AUTH_LOGIN, AuthType, LOGIN_PAGE_URI } from '../../../../common';
import { AuthType, LOGIN_PAGE_URI } from '../../../../common';
import { composeNextUrlQueryParam } from '../../../utils/next_url';
import { MultiAuthRoutes } from './routes';
import { SecuritySessionCookie } from '../../../session/security_cookie';
Expand Down Expand Up @@ -166,14 +166,6 @@ export class MultipleAuthentication extends AuthenticationType {
this.coreSetup.http.basePath.serverBasePath
);

if (this.config.auth.anonymous_auth_enabled) {
const redirectLocation = `${this.coreSetup.http.basePath.serverBasePath}${ANONYMOUS_AUTH_LOGIN}?${nextUrlParam}`;
return response.redirected({
headers: {
location: `${redirectLocation}`,
},
});
}
return response.redirected({
headers: {
location: `${this.coreSetup.http.basePath.serverBasePath}${LOGIN_PAGE_URI}?${nextUrlParam}`,
Expand Down
1 change: 1 addition & 0 deletions server/auth/types/saml/saml_auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export class SamlAuthentication extends AuthenticationType {
toolkit: AuthToolkit
): IOpenSearchDashboardsResponse | AuthResult {
if (this.isPageRequest(request)) {
console.log('redirectSAMlCapture');
return this.redirectSAMlCapture(request, toolkit);
} else {
return response.unauthorized();
Expand Down
6 changes: 5 additions & 1 deletion server/backend/opensearch_security_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { ILegacyClusterClient, OpenSearchDashboardsRequest } from '../../../../src/core/server';
import { User } from '../auth/user';
import { TenancyConfigSettings } from '../../public/apps/configuration/panels/tenancy-config/types';
import { AUTH_TYPE_PARAM, AuthType } from '../../common';

export class SecurityClient {
constructor(private readonly esClient: ILegacyClusterClient) {}
Expand Down Expand Up @@ -182,7 +183,9 @@ export class SecurityClient {
public async getSamlHeader(request: OpenSearchDashboardsRequest) {
try {
// response is expected to be an error
await this.esClient.asScoped(request).callAsCurrentUser('opensearch_security.authinfo');
await this.esClient.asScoped(request).callAsCurrentUser('opensearch_security.authinfo', {
[AUTH_TYPE_PARAM]: AuthType.SAML,
});
} catch (error: any) {
// the error looks like
// wwwAuthenticateDirective:
Expand Down Expand Up @@ -230,6 +233,7 @@ export class SecurityClient {
try {
return await this.esClient.asScoped().callAsCurrentUser('opensearch_security.authtoken', {
body,
[AUTH_TYPE_PARAM]: AuthType.SAML,
});
} catch (error: any) {
console.log(error);
Expand Down