Skip to content

Commit

Permalink
Adds hardcoded credentials for anonymous user
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Mar 11, 2024
1 parent 199683c commit cbdf7a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 1 addition & 5 deletions server/auth/types/authentication_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export abstract class AuthenticationType implements IAuthenticationType {
let authInfo: any | undefined;

if (this.config.auth.anonymous_auth_enabled) {
const anonymousAuthHeaders = { _auth_request_type_: 'anonymous' };
const anonymousAuthHeaders = { _auth_request_type_: 'anonymous', authorization: 'Basic b3BlbmRpc3Ryb19zZWN1cml0eV9hbm9ueW1vdXM6b3BlbmRpc3Ryb19zZWN1cml0eV9hbm9ueW1vdXM=' };
Object.assign(authHeaders, anonymousAuthHeaders);
}

Expand Down Expand Up @@ -159,10 +159,6 @@ export abstract class AuthenticationType implements IAuthenticationType {
if (request.url.pathname && request.url.pathname.startsWith('/bundles/')) {
return toolkit.notHandled();
}
console.log('Request is unauthorized');
console.log(request.url);
console.log(request.route);

// send to auth workflow
return this.handleUnauthedRequest(request, response, toolkit);
}
Expand Down
10 changes: 9 additions & 1 deletion server/auth/types/basic/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ export class BasicAuthRoutes {
}
context.security_plugin.logger.info('The Redirect Path is ' + redirectUrl);
try {
// user = await this.securityClient.authenticateWithHeaders(request, {
// _auth_request_type_: 'anonymous',
// });
// opendistro_security_anonymous:opendistro_security_anonymous
const authHeader = "b3BlbmRpc3Ryb19zZWN1cml0eV9hbm9ueW1vdXM6b3BlbmRpc3Ryb19zZWN1cml0eV9hbm9ueW1vdXM=";
user = await this.securityClient.authenticateWithHeaders(request, {
_auth_request_type_: 'anonymous',
authorization: `Basic ${authHeader}`,
});
} catch (error) {
context.security_plugin.logger.error(
Expand All @@ -214,6 +219,7 @@ export class BasicAuthRoutes {

if (user.multitenancy_enabled) {
request.headers._auth_request_type_ = 'anonymous';
request.headers.authorization = 'Basic b3BlbmRpc3Ryb19zZWN1cml0eV9hbm9ueW1vdXM6b3BlbmRpc3Ryb19zZWN1cml0eV9hbm9ueW1vdXM=';
const selectTenant = resolveTenant({
request,
username: user.username,
Expand All @@ -232,6 +238,8 @@ export class BasicAuthRoutes {
return response.redirected({
headers: {
location: `${redirectUrl}`,
_auth_request_type_: "anonymous",
authorization: "Basic b3BlbmRpc3Ryb19zZWN1cml0eV9hbm9ueW1vdXM6b3BlbmRpc3Ryb19zZWN1cml0eV9hbm9ueW1vdXM="
},
});
} else {
Expand Down

0 comments on commit cbdf7a6

Please sign in to comment.