Skip to content

Commit

Permalink
Enforce authentication on api/status route by default (#943)
Browse files Browse the repository at this point in the history
Signed-off-by: cliu123 <lc12251109@gmail.com>

Co-authored-by: Darshit Chanpura <35282393+DarshitChanpura@users.noreply.github.com>
  • Loading branch information
cliu123 and DarshitChanpura committed Apr 14, 2022
1 parent d9ae155 commit 6d6c5b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ export const configSchema = schema.object({
}),
anonymous_auth_enabled: schema.boolean({ defaultValue: false }),
unauthenticated_routes: schema.arrayOf(schema.string(), {
defaultValue: ['/api/status', '/api/reporting/stats'],
defaultValue: ['/api/reporting/stats'],
}),
forbidden_usernames: schema.arrayOf(schema.string(), { defaultValue: [] }),
logout_url: schema.string({ defaultValue: '' }),
}),
basicauth: schema.object({
enabled: schema.boolean({ defaultValue: true }),
unauthenticated_routes: schema.arrayOf(schema.string(), { defaultValue: ['/api/status'] }),
unauthenticated_routes: schema.arrayOf(schema.string(), { defaultValue: [] }),
forbidden_usernames: schema.arrayOf(schema.string(), { defaultValue: [] }),
header_trumps_session: schema.boolean({ defaultValue: false }),
alternative_login: schema.object({
Expand Down
12 changes: 12 additions & 0 deletions test/jest_integration/basic_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,16 @@ describe('start OpenSearch Dashboards server', () => {

expect(response.status).toEqual(302);
});

it('enforce authentication on api/status route', async () => {
const response = await osdTestServer.request.get(root, '/api/status');
expect(response.status).toEqual(401);
});

it('can access api/status route with admin credential', async () => {
const response = await osdTestServer.request
.get(root, '/api/status')
.set(AUTHORIZATION_HEADER_NAME, ADMIN_CREDENTIALS);
expect(response.status).toEqual(200);
});
});

0 comments on commit 6d6c5b7

Please sign in to comment.