mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
feat: OIDC redirect flag (#8944)
This commit is contained in:
parent
87d03e8270
commit
9de96c8004
@ -6,13 +6,26 @@ import LockRounded from '@mui/icons-material/LockRounded';
|
|||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import type { IAuthOptions } from 'hooks/api/getters/useAuth/useAuthEndpoint';
|
import type { IAuthOptions } from 'hooks/api/getters/useAuth/useAuthEndpoint';
|
||||||
import { SSO_LOGIN_BUTTON } from 'utils/testIds';
|
import { SSO_LOGIN_BUTTON } from 'utils/testIds';
|
||||||
|
import useQueryParams from 'hooks/useQueryParams';
|
||||||
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
|
|
||||||
interface IAuthOptionProps {
|
interface IAuthOptionProps {
|
||||||
options?: IAuthOptions[];
|
options?: IAuthOptions[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addOrOverwriteRedirect(path: string, redirectValue: string): string {
|
||||||
|
const [basePath, queryString = ''] = path.split('?');
|
||||||
|
const params = new URLSearchParams(queryString);
|
||||||
|
params.set('redirect', redirectValue);
|
||||||
|
return `${basePath}?${params.toString()}`;
|
||||||
|
}
|
||||||
|
|
||||||
const AuthOptions = ({ options }: IAuthOptionProps) => {
|
const AuthOptions = ({ options }: IAuthOptionProps) => {
|
||||||
const { classes: themeStyles } = useThemeStyles();
|
const { classes: themeStyles } = useThemeStyles();
|
||||||
|
const oidcRedirectEnabled = useUiFlag('oidcRedirect');
|
||||||
|
const query = useQueryParams();
|
||||||
|
const redirectPath = (oidcRedirectEnabled && query.get('redirect')) || '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{options?.map((o) => (
|
{options?.map((o) => (
|
||||||
@ -27,7 +40,11 @@ const AuthOptions = ({ options }: IAuthOptionProps) => {
|
|||||||
color='primary'
|
color='primary'
|
||||||
data-loading
|
data-loading
|
||||||
variant='outlined'
|
variant='outlined'
|
||||||
href={o.path}
|
href={
|
||||||
|
redirectPath
|
||||||
|
? addOrOverwriteRedirect(o.path, redirectPath)
|
||||||
|
: o.path
|
||||||
|
}
|
||||||
size='small'
|
size='small'
|
||||||
data-testid={`${SSO_LOGIN_BUTTON}-${o.type}`}
|
data-testid={`${SSO_LOGIN_BUTTON}-${o.type}`}
|
||||||
style={{
|
style={{
|
||||||
|
@ -94,6 +94,7 @@ export type UiFlags = {
|
|||||||
showUserDeviceCount?: boolean;
|
showUserDeviceCount?: boolean;
|
||||||
flagOverviewRedesign?: boolean;
|
flagOverviewRedesign?: boolean;
|
||||||
licensedUsers?: boolean;
|
licensedUsers?: boolean;
|
||||||
|
oidcRedirect?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IVersionInfo {
|
export interface IVersionInfo {
|
||||||
|
@ -61,7 +61,8 @@ export type IFlagKey =
|
|||||||
| 'memorizeStats'
|
| 'memorizeStats'
|
||||||
| 'licensedUsers'
|
| 'licensedUsers'
|
||||||
| 'streaming'
|
| 'streaming'
|
||||||
| 'etagVariant';
|
| 'etagVariant'
|
||||||
|
| 'oidcRedirect';
|
||||||
|
|
||||||
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
|
||||||
|
|
||||||
@ -290,6 +291,10 @@ const flags: IFlags = {
|
|||||||
feature_enabled: false,
|
feature_enabled: false,
|
||||||
enabled: false,
|
enabled: false,
|
||||||
},
|
},
|
||||||
|
oidcRedirect: parseEnvVarBoolean(
|
||||||
|
process.env.UNLEASH_EXPERIMENTAL_OIDC_REDIRECT,
|
||||||
|
false,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultExperimentalOptions: IExperimentalOptions = {
|
export const defaultExperimentalOptions: IExperimentalOptions = {
|
||||||
|
Loading…
Reference in New Issue
Block a user