1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat: OIDC redirect flag (#8944)

This commit is contained in:
Mateusz Kwasniewski 2024-12-10 09:07:00 +01:00 committed by GitHub
parent 87d03e8270
commit 9de96c8004
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 2 deletions

View File

@ -6,13 +6,26 @@ import LockRounded from '@mui/icons-material/LockRounded';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import type { IAuthOptions } from 'hooks/api/getters/useAuth/useAuthEndpoint';
import { SSO_LOGIN_BUTTON } from 'utils/testIds';
import useQueryParams from 'hooks/useQueryParams';
import { useUiFlag } from 'hooks/useUiFlag';
interface IAuthOptionProps {
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 { classes: themeStyles } = useThemeStyles();
const oidcRedirectEnabled = useUiFlag('oidcRedirect');
const query = useQueryParams();
const redirectPath = (oidcRedirectEnabled && query.get('redirect')) || '';
return (
<>
{options?.map((o) => (
@ -27,7 +40,11 @@ const AuthOptions = ({ options }: IAuthOptionProps) => {
color='primary'
data-loading
variant='outlined'
href={o.path}
href={
redirectPath
? addOrOverwriteRedirect(o.path, redirectPath)
: o.path
}
size='small'
data-testid={`${SSO_LOGIN_BUTTON}-${o.type}`}
style={{

View File

@ -94,6 +94,7 @@ export type UiFlags = {
showUserDeviceCount?: boolean;
flagOverviewRedesign?: boolean;
licensedUsers?: boolean;
oidcRedirect?: boolean;
};
export interface IVersionInfo {

View File

@ -61,7 +61,8 @@ export type IFlagKey =
| 'memorizeStats'
| 'licensedUsers'
| 'streaming'
| 'etagVariant';
| 'etagVariant'
| 'oidcRedirect';
export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;
@ -290,6 +291,10 @@ const flags: IFlags = {
feature_enabled: false,
enabled: false,
},
oidcRedirect: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_OIDC_REDIRECT,
false,
),
};
export const defaultExperimentalOptions: IExperimentalOptions = {