mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-02 01:17:58 +02:00
parent
095d4d7074
commit
f55ea5f387
@ -80,7 +80,6 @@ export const adminRoutes: INavigationMenuItem[] = [
|
|||||||
{
|
{
|
||||||
path: '/admin/cors',
|
path: '/admin/cors',
|
||||||
title: 'CORS origins',
|
title: 'CORS origins',
|
||||||
flag: 'embedProxyFrontend',
|
|
||||||
menu: { adminSettings: true },
|
menu: { adminSettings: true },
|
||||||
group: 'access',
|
group: 'access',
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
|
||||||
import { useEnvironments } from 'hooks/api/getters/useEnvironments/useEnvironments';
|
import { useEnvironments } from 'hooks/api/getters/useEnvironments/useEnvironments';
|
||||||
import type { IApiTokenCreate } from 'hooks/api/actions/useApiTokensApi/useApiTokensApi';
|
import type { IApiTokenCreate } from 'hooks/api/actions/useApiTokensApi/useApiTokensApi';
|
||||||
import { TokenType } from 'interfaces/token';
|
import { TokenType } from 'interfaces/token';
|
||||||
@ -14,10 +13,8 @@ import type { SelectOption } from './TokenTypeSelector/TokenTypeSelector';
|
|||||||
export type ApiTokenFormErrorType = 'tokenName' | 'projects';
|
export type ApiTokenFormErrorType = 'tokenName' | 'projects';
|
||||||
export const useApiTokenForm = (project?: string) => {
|
export const useApiTokenForm = (project?: string) => {
|
||||||
const { environments } = useEnvironments();
|
const { environments } = useEnvironments();
|
||||||
const { uiConfig } = useUiConfig();
|
|
||||||
const initialEnvironment = environments?.find((e) => e.enabled)?.name;
|
const initialEnvironment = environments?.find((e) => e.enabled)?.name;
|
||||||
|
|
||||||
const hasCreateTokenPermission = useHasRootAccess(CREATE_CLIENT_API_TOKEN);
|
|
||||||
const hasCreateProjectTokenPermission = useHasRootAccess(
|
const hasCreateProjectTokenPermission = useHasRootAccess(
|
||||||
CREATE_PROJECT_API_TOKEN,
|
CREATE_PROJECT_API_TOKEN,
|
||||||
project,
|
project,
|
||||||
@ -29,24 +26,18 @@ export const useApiTokenForm = (project?: string) => {
|
|||||||
label: `Server-side SDK (${TokenType.CLIENT})`,
|
label: `Server-side SDK (${TokenType.CLIENT})`,
|
||||||
title: 'Connect server-side SDK or Unleash Proxy/Edge',
|
title: 'Connect server-side SDK or Unleash Proxy/Edge',
|
||||||
enabled:
|
enabled:
|
||||||
hasCreateTokenPermission || hasCreateProjectTokenPermission,
|
useHasRootAccess(CREATE_CLIENT_API_TOKEN) ||
|
||||||
|
hasCreateProjectTokenPermission,
|
||||||
},
|
},
|
||||||
];
|
{
|
||||||
|
|
||||||
const hasCreateFrontendAccess = useHasRootAccess(CREATE_FRONTEND_API_TOKEN);
|
|
||||||
const hasCreateFrontendTokenAccess = useHasRootAccess(
|
|
||||||
CREATE_PROJECT_API_TOKEN,
|
|
||||||
project,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (uiConfig.flags.embedProxyFrontend) {
|
|
||||||
apiTokenTypes.splice(1, 0, {
|
|
||||||
key: TokenType.FRONTEND,
|
key: TokenType.FRONTEND,
|
||||||
label: `Client-side SDK (${TokenType.FRONTEND})`,
|
label: `Client-side SDK (${TokenType.FRONTEND})`,
|
||||||
title: 'Connect web and mobile SDK directly to Unleash',
|
title: 'Connect web and mobile SDK directly to Unleash',
|
||||||
enabled: hasCreateFrontendAccess || hasCreateFrontendTokenAccess,
|
enabled:
|
||||||
});
|
useHasRootAccess(CREATE_FRONTEND_API_TOKEN) ||
|
||||||
}
|
hasCreateProjectTokenPermission,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
const firstAccessibleType = apiTokenTypes.find((t) => t.enabled)?.key;
|
const firstAccessibleType = apiTokenTypes.find((t) => t.enabled)?.key;
|
||||||
|
|
||||||
|
@ -54,7 +54,6 @@ export type UiFlags = {
|
|||||||
T?: boolean;
|
T?: boolean;
|
||||||
UNLEASH_CLOUD?: boolean;
|
UNLEASH_CLOUD?: boolean;
|
||||||
UG?: boolean;
|
UG?: boolean;
|
||||||
embedProxyFrontend?: boolean;
|
|
||||||
maintenanceMode?: boolean;
|
maintenanceMode?: boolean;
|
||||||
messageBanner?: Variant;
|
messageBanner?: Variant;
|
||||||
banner?: Variant;
|
banner?: Variant;
|
||||||
|
@ -208,9 +208,6 @@ export default class FrontendAPIController extends Controller {
|
|||||||
req: ApiUserRequest,
|
req: ApiUserRequest,
|
||||||
res: Response<FrontendApiFeaturesSchema>,
|
res: Response<FrontendApiFeaturesSchema>,
|
||||||
) {
|
) {
|
||||||
if (!this.config.flagResolver.isEnabled('embedProxy')) {
|
|
||||||
throw new NotFoundError();
|
|
||||||
}
|
|
||||||
const toggles =
|
const toggles =
|
||||||
await this.services.frontendApiService.getFrontendApiFeatures(
|
await this.services.frontendApiService.getFrontendApiFeatures(
|
||||||
req.user,
|
req.user,
|
||||||
@ -231,10 +228,6 @@ export default class FrontendAPIController extends Controller {
|
|||||||
req: ApiUserRequest<unknown, unknown, ClientMetricsSchema>,
|
req: ApiUserRequest<unknown, unknown, ClientMetricsSchema>,
|
||||||
res: Response,
|
res: Response,
|
||||||
) {
|
) {
|
||||||
if (!this.config.flagResolver.isEnabled('embedProxy')) {
|
|
||||||
throw new NotFoundError();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.config.flagResolver.isEnabled('disableMetrics')) {
|
if (this.config.flagResolver.isEnabled('disableMetrics')) {
|
||||||
res.sendStatus(204);
|
res.sendStatus(204);
|
||||||
return;
|
return;
|
||||||
@ -254,9 +247,6 @@ export default class FrontendAPIController extends Controller {
|
|||||||
req: ApiUserRequest<unknown, unknown, FrontendApiClientSchema>,
|
req: ApiUserRequest<unknown, unknown, FrontendApiClientSchema>,
|
||||||
res: Response<string>,
|
res: Response<string>,
|
||||||
) {
|
) {
|
||||||
if (!this.config.flagResolver.isEnabled('embedProxy')) {
|
|
||||||
throw new NotFoundError();
|
|
||||||
}
|
|
||||||
// Client registration is not yet supported by @unleash/proxy,
|
// Client registration is not yet supported by @unleash/proxy,
|
||||||
// but proxy clients may still expect a 200 from this endpoint.
|
// but proxy clients may still expect a 200 from this endpoint.
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
|
@ -64,9 +64,7 @@ const apiAccessMiddleware = (
|
|||||||
(apiUser.type === CLIENT &&
|
(apiUser.type === CLIENT &&
|
||||||
!isClientApi(req) &&
|
!isClientApi(req) &&
|
||||||
!isEdgeMetricsApi(req)) ||
|
!isEdgeMetricsApi(req)) ||
|
||||||
(apiUser.type === FRONTEND && !isProxyApi(req)) ||
|
(apiUser.type === FRONTEND && !isProxyApi(req))
|
||||||
(apiUser.type === FRONTEND &&
|
|
||||||
!flagResolver.isEnabled('embedProxy'))
|
|
||||||
) {
|
) {
|
||||||
res.status(403).send({
|
res.status(403).send({
|
||||||
message: TOKEN_TYPE_ERROR_MESSAGE,
|
message: TOKEN_TYPE_ERROR_MESSAGE,
|
||||||
|
@ -9,8 +9,6 @@ export type IFlagKey =
|
|||||||
| 'encryptEmails'
|
| 'encryptEmails'
|
||||||
| 'enableLicense'
|
| 'enableLicense'
|
||||||
| 'enableLicenseChecker'
|
| 'enableLicenseChecker'
|
||||||
| 'embedProxy'
|
|
||||||
| 'embedProxyFrontend'
|
|
||||||
| 'responseTimeWithAppNameKillSwitch'
|
| 'responseTimeWithAppNameKillSwitch'
|
||||||
| 'maintenanceMode'
|
| 'maintenanceMode'
|
||||||
| 'messageBanner'
|
| 'messageBanner'
|
||||||
@ -77,14 +75,6 @@ const flags: IFlags = {
|
|||||||
anonymiseEventLog: false,
|
anonymiseEventLog: false,
|
||||||
enableLicense: false,
|
enableLicense: false,
|
||||||
enableLicenseChecker: false,
|
enableLicenseChecker: false,
|
||||||
embedProxy: parseEnvVarBoolean(
|
|
||||||
process.env.UNLEASH_EXPERIMENTAL_EMBED_PROXY,
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
embedProxyFrontend: parseEnvVarBoolean(
|
|
||||||
process.env.UNLEASH_EXPERIMENTAL_EMBED_PROXY_FRONTEND,
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
responseTimeWithAppNameKillSwitch: parseEnvVarBoolean(
|
responseTimeWithAppNameKillSwitch: parseEnvVarBoolean(
|
||||||
process.env.UNLEASH_RESPONSE_TIME_WITH_APP_NAME_KILL_SWITCH,
|
process.env.UNLEASH_RESPONSE_TIME_WITH_APP_NAME_KILL_SWITCH,
|
||||||
false,
|
false,
|
||||||
|
@ -36,8 +36,6 @@ process.nextTick(async () => {
|
|||||||
experimental: {
|
experimental: {
|
||||||
// externalResolver: unleash,
|
// externalResolver: unleash,
|
||||||
flags: {
|
flags: {
|
||||||
embedProxy: true,
|
|
||||||
embedProxyFrontend: true,
|
|
||||||
anonymiseEventLog: false,
|
anonymiseEventLog: false,
|
||||||
responseTimeWithAppNameKillSwitch: false,
|
responseTimeWithAppNameKillSwitch: false,
|
||||||
outdatedSdksBanner: true,
|
outdatedSdksBanner: true,
|
||||||
|
@ -24,12 +24,6 @@ export function createTestConfig(config?: IUnleashOptions): IUnleashConfig {
|
|||||||
clientFeatureCaching: {
|
clientFeatureCaching: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
experimental: {
|
|
||||||
flags: {
|
|
||||||
embedProxy: true,
|
|
||||||
embedProxyFrontend: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
publicFolder: path.join(__dirname, '../examples'),
|
publicFolder: path.join(__dirname, '../examples'),
|
||||||
};
|
};
|
||||||
const options = mergeAll<IUnleashOptions>([testConfig, config || {}]);
|
const options = mergeAll<IUnleashOptions>([testConfig, config || {}]);
|
||||||
|
Loading…
Reference in New Issue
Block a user