Skip to content

Commit

Permalink
ensure JWT signing key consistency
Browse files Browse the repository at this point in the history
Signed-off-by: merlinz01 <na@notaccessible.xyz>
  • Loading branch information
merlinz01 committed Oct 4, 2024
1 parent 06b2812 commit bab1646
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ export const PROXY_ROLE: string = 'x-proxy-roles';
export const PROXY_ADMIN_ROLE: string = 'admin';

export const JWT_ADMIN_ROLE: string = 'admin';
export const JWT_SIGNING_KEY: string = '99011df6ef40e4a2cd9cd6ccb2d649e0';
5 changes: 3 additions & 2 deletions test/jest_integration/jwt_multiauth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
OPENSEARCH_DASHBOARDS_SERVER_PASSWORD,
ADMIN_USER,
JWT_ADMIN_ROLE,
JWT_SIGNING_KEY,
} from '../constant';
import wreck from '@hapi/wreck';
import { SignJWT } from 'jose';
Expand Down Expand Up @@ -103,7 +104,7 @@ describe('start OpenSearch Dashboards server', () => {
challenge: false,
type: 'jwt',
config: {
signing_key: 'OTkwMTFkZjZlZjQwZTRhMmNkOWNkNmNjYjJkNjQ5ZTAK',
signing_key: btoa(JWT_SIGNING_KEY),
jwt_header: 'Authorization',
jwt_url_parameter: 'token',
jwt_clock_skew_tolerance_seconds: 30,
Expand Down Expand Up @@ -160,7 +161,7 @@ describe('start OpenSearch Dashboards server', () => {
sub: ADMIN_USER,
})
.setProtectedHeader({ alg: 'HS256' })
.sign(new TextEncoder().encode('99011df6ef40e4a2cd9cd6ccb2d649e0'));
.sign(new TextEncoder().encode(JWT_SIGNING_KEY));
await wreck.get(`http://localhost:5601/app/home?token=${adminJWT}#`, {
rejectUnauthorized: true,
headers: {
Expand Down

0 comments on commit bab1646

Please sign in to comment.