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:
parent
468b923bda
commit
449167b17d
@ -3,6 +3,7 @@ export interface IExperimentalOptions {
|
||||
clientFeatureMemoize?: IExperimentalToggle;
|
||||
userGroups?: boolean;
|
||||
anonymiseEventLog?: boolean;
|
||||
embedProxy?: boolean;
|
||||
}
|
||||
|
||||
export interface IExperimentalToggle {
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ process.nextTick(async () => {
|
||||
metricsV2: { enabled: true },
|
||||
anonymiseEventLog: false,
|
||||
userGroups: true,
|
||||
embedProxy: true,
|
||||
},
|
||||
authentication: {
|
||||
initApiTokens: [
|
||||
|
@ -24,6 +24,7 @@ export function createTestConfig(config?: IUnleashOptions): IUnleashConfig {
|
||||
},
|
||||
experimental: {
|
||||
userGroups: true,
|
||||
embedProxy: true,
|
||||
},
|
||||
};
|
||||
const options = mergeAll<IUnleashOptions>([testConfig, config]);
|
||||
|
Loading…
Reference in New Issue
Block a user