1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

refactor: add an experimental flag for the embedded proxy

This commit is contained in:
olav 2022-08-16 14:05:29 +02:00
parent 468b923bda
commit 449167b17d
5 changed files with 14 additions and 3 deletions

View File

@ -3,6 +3,7 @@ export interface IExperimentalOptions {
clientFeatureMemoize?: IExperimentalToggle;
userGroups?: boolean;
anonymiseEventLog?: boolean;
embedProxy?: boolean;
}
export interface IExperimentalToggle {

View File

@ -17,7 +17,8 @@ const apiAccessMiddleware = (
{
getLogger,
authentication,
}: Pick<IUnleashConfig, 'getLogger' | 'authentication'>,
experimental,
}: Pick<IUnleashConfig, 'getLogger' | 'authentication' | 'experimental'>,
{ apiTokenService }: any,
): any => {
const logger = getLogger('/middleware/api-token.ts');
@ -40,7 +41,8 @@ const apiAccessMiddleware = (
if (apiUser) {
if (
(apiUser.type === CLIENT && !isClientApi(req)) ||
(apiUser.type === PROXY && !isProxyApi(req))
(apiUser.type === PROXY && !isProxyApi(req)) ||
(apiUser.type === PROXY && !experimental.embedProxy)
) {
res.status(403).send({ message: TOKEN_TYPE_ERROR_MESSAGE });
return;

View File

@ -27,7 +27,13 @@ class IndexRouter extends Controller {
);
this.use('/api/admin', new AdminApi(config, services).router);
this.use('/api/client', new ClientApi(config, services).router);
this.use('/api/frontend', new ProxyController(config, services).router);
if (config.experimental.embedProxy) {
this.use(
'/api/frontend',
new ProxyController(config, services).router,
);
}
}
}

View File

@ -34,6 +34,7 @@ process.nextTick(async () => {
metricsV2: { enabled: true },
anonymiseEventLog: false,
userGroups: true,
embedProxy: true,
},
authentication: {
initApiTokens: [

View File

@ -24,6 +24,7 @@ export function createTestConfig(config?: IUnleashOptions): IUnleashConfig {
},
experimental: {
userGroups: true,
embedProxy: true,
},
};
const options = mergeAll<IUnleashOptions>([testConfig, config]);