Skip to content

Commit

Permalink
Add Proxy Auth to Multi Auth Options
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crawford <[email protected]>
  • Loading branch information
stephen-crawford committed Jul 31, 2024
1 parent bbae201 commit ed1fdde
Showing 1 changed file with 52 additions and 1 deletion.
53 changes: 52 additions & 1 deletion test/jest_integration/proxy_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ import {
PROXY_USER,
PROXY_ROLE,
PROXY_ADMIN_ROLE,
AUTHORIZATION_HEADER_NAME,
AUTHORIZATION_HEADER_NAME, ADMIN_CREDENTIALS,

Check failure on line 27 in test/jest_integration/proxy_auth.test.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Insert `⏎·`

Check failure on line 27 in test/jest_integration/proxy_auth.test.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Insert `␍⏎·`
} from '../constant';
import wreck from '@hapi/wreck';

describe('start OpenSearch Dashboards server', () => {
let root: Root;
let config;

beforeAll(async () => {
root = osdTestServer.createRootWithSettings(
Expand Down Expand Up @@ -68,6 +70,55 @@ describe('start OpenSearch Dashboards server', () => {
);
await root.setup();
await root.start();

Check failure on line 72 in test/jest_integration/proxy_auth.test.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (ubuntu-latest)

Delete `⏎`

Check failure on line 72 in test/jest_integration/proxy_auth.test.ts

View workflow job for this annotation

GitHub Actions / Run unit tests (windows-latest)

Delete `␍⏎`


const getConfigResponse = await wreck.get(
'https://localhost:9200/_plugins/_security/api/securityconfig',
{
rejectUnauthorized: false,
headers: {
authorization: ADMIN_CREDENTIALS,
},
}
);
const responseBody = (getConfigResponse.payload as Buffer).toString();
config = JSON.parse(responseBody).config;
const proxyConfig = {
http_enabled: true,
transport_enabled: true,
order: 0,
http_authenticator: {
challenge: false,
type: 'proxy',
config: {
user_header: 'x-proxy-user',
roles_header: 'x-proxy-roles',
},
},
authentication_backend: {
type: 'noop',
config: {},
},
};
try {
config.dynamic!.authc!.proxy_auth_domain = proxyConfig;
config.dynamic!.authc!.basic_internal_auth_domain.http_authenticator.challenge = false;
config.dynamic!.http!.anonymous_auth_enabled = false;
config.dynamic!.http!.xff!.enabled = true;
config.dynamic!.http!.xff!.internalProxies = '.*';
config.dynamic!.http!.xff!.remoteIpHeader = 'x-forwarded-for';
await wreck.put('https://localhost:9200/_plugins/_security/api/securityconfig/config', {
payload: config,
rejectUnauthorized: false,
headers: {
'Content-Type': 'application/json',
authorization: ADMIN_CREDENTIALS,
},
});
} catch (error) {
console.log('Got an error while updating security config!!', error.stack);
fail(error);
}
});

afterAll(async () => {
Expand Down

0 comments on commit ed1fdde

Please sign in to comment.