mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
feat: remove bearer token middleware flag (#6934)
## About the changes Removes the bearer token middleware flag for GA
This commit is contained in:
parent
d6d4d5372f
commit
2400ffc67e
@ -78,7 +78,6 @@ exports[`should create default config 1`] = `
|
||||
"anonymiseEventLog": false,
|
||||
"applicationOverviewNewQuery": false,
|
||||
"automatedActions": false,
|
||||
"bearerTokenMiddleware": false,
|
||||
"caseInsensitiveInOperators": false,
|
||||
"celebrateUnleash": false,
|
||||
"collectTrafficDataUsage": false,
|
||||
|
@ -16,11 +16,6 @@ describe('bearerTokenMiddleware', () => {
|
||||
beforeEach(() => {
|
||||
config = createTestConfig({
|
||||
getLogger,
|
||||
experimental: {
|
||||
flags: {
|
||||
bearerTokenMiddleware: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@ -64,14 +59,9 @@ describe('bearerTokenMiddleware', () => {
|
||||
expect(req.headers.authorization).toBe(exampleSignalToken);
|
||||
});
|
||||
|
||||
it('should always run for signal endpoint, regardless of the flag', () => {
|
||||
it('should always run for signal endpoint, without base path', () => {
|
||||
const configWithBearerTokenMiddlewareFlagDisabled = createTestConfig({
|
||||
getLogger,
|
||||
experimental: {
|
||||
flags: {
|
||||
bearerTokenMiddleware: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const middleware = bearerTokenMiddleware(
|
||||
@ -88,17 +78,12 @@ describe('bearerTokenMiddleware', () => {
|
||||
expect(req.headers.authorization).toBe(exampleSignalToken);
|
||||
});
|
||||
|
||||
it('should always run for signal endpoint, regardless of the flag, supporting instance path', () => {
|
||||
it('should always run for signal endpoint, regardless of the flag, with base path', () => {
|
||||
const configWithBearerTokenMiddlewareFlagDisabled = createTestConfig({
|
||||
getLogger,
|
||||
server: {
|
||||
baseUriPath: '/some-test-instance',
|
||||
},
|
||||
experimental: {
|
||||
flags: {
|
||||
bearerTokenMiddleware: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const middleware = bearerTokenMiddleware(
|
||||
|
@ -2,27 +2,15 @@ import type { Request, Response, NextFunction } from 'express';
|
||||
import type { IUnleashConfig } from '../types';
|
||||
|
||||
export const bearerTokenMiddleware = ({
|
||||
server,
|
||||
getLogger,
|
||||
flagResolver,
|
||||
}: Pick<IUnleashConfig, 'server' | 'getLogger' | 'flagResolver'>) => {
|
||||
}: Pick<IUnleashConfig, 'getLogger'>) => {
|
||||
const logger = getLogger('/middleware/bearer-token-middleware.ts');
|
||||
logger.debug('Enabling bearer token middleware');
|
||||
const baseUriPath = server.baseUriPath || '';
|
||||
|
||||
return (req: Request, _: Response, next: NextFunction) => {
|
||||
if (
|
||||
req.path.startsWith(`${baseUriPath}/api/signal-endpoint/`) ||
|
||||
flagResolver.isEnabled('bearerTokenMiddleware')
|
||||
) {
|
||||
const authHeader = req.headers.authorization;
|
||||
const authHeader = req.headers.authorization;
|
||||
|
||||
if (authHeader) {
|
||||
req.headers.authorization = authHeader.replace(
|
||||
/^Bearer\s+/i,
|
||||
'',
|
||||
);
|
||||
}
|
||||
if (authHeader) {
|
||||
req.headers.authorization = authHeader.replace(/^Bearer\s+/i, '');
|
||||
}
|
||||
next();
|
||||
};
|
||||
|
@ -53,7 +53,6 @@ export type IFlagKey =
|
||||
| 'displayEdgeBanner'
|
||||
| 'projectOverviewRefactor'
|
||||
| 'disableShowContextFieldSelectionValues'
|
||||
| 'bearerTokenMiddleware'
|
||||
| 'projectOverviewRefactorFeedback'
|
||||
| 'featureLifecycle'
|
||||
| 'projectListFilterMyProjects'
|
||||
@ -261,10 +260,6 @@ const flags: IFlags = {
|
||||
.UNLEASH_EXPERIMENTAL_DISABLE_SHOW_CONTEXT_FIELD_SELECTION_VALUES,
|
||||
false,
|
||||
),
|
||||
bearerTokenMiddleware: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_BEARER_TOKEN_MIDDLEWARE,
|
||||
false,
|
||||
),
|
||||
projectOverviewRefactorFeedback: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENTAL_PROJECT_OVERVIEW_REFACTOR_FEEDBACK,
|
||||
false,
|
||||
|
Loading…
Reference in New Issue
Block a user