Skip to content

Commit

Permalink
feat: Make SAML dialog aware that it might be configured via env (#7606)
Browse files Browse the repository at this point in the history
Same as the OIDC changes we merged yesterday, this makes the frontend
ready for disabling SAML configuration page, if the SAML_ environment
variables are set.

---------

Co-authored-by: Nuno Góis <[email protected]>
  • Loading branch information
chriswk and nunogois authored Jul 17, 2024
1 parent 949a5f0 commit d397819
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
8 changes: 4 additions & 4 deletions frontend/src/component/admin/auth/OidcAuth/OidcAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ export const OidcAuth = () => {
condition={Boolean(oidcConfiguredThroughEnv)}
show={
<Alert sx={{ mb: 2 }} severity='warning'>
OIDC setup is currently controlled via
environment variables. Please see the{' '}
OIDC is currently configured via environment
variables. Please refer to the{' '}
<a
href='https://www.unleash-hosted.com/docs/enterprise-authentication'
target='_blank'
rel='noreferrer'
>
documentation
</a>{' '}
to learn how to set the correct environment
variables
for detailed instructions on how to set up OIDC
using these variables.
</Alert>
}
/>
Expand Down
35 changes: 29 additions & 6 deletions frontend/src/component/admin/auth/SamlAuth/SamlAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { formatUnknownError } from 'utils/formatUnknownError';
import { removeEmptyStringFields } from 'utils/removeEmptyStringFields';
import { SsoGroupSettings } from '../SsoGroupSettings';
import type { IRole } from 'interfaces/role';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';

const initialState = {
enabled: false,
Expand All @@ -40,6 +41,7 @@ type State = typeof initialState & {
export const SamlAuth = () => {
const { setToastData, setToastApiError } = useToast();
const { uiConfig } = useUiConfig();
const { samlConfiguredThroughEnv } = uiConfig;
const [data, setData] = useState<State>(initialState);
const { config } = useAuthSettings('saml');
const { updateSettings, errors, loading } = useAuthSettingsApi('saml');
Expand Down Expand Up @@ -98,6 +100,24 @@ export const SamlAuth = () => {
<>
<Grid container sx={{ mb: 3 }}>
<Grid item md={12}>
<ConditionallyRender
condition={Boolean(samlConfiguredThroughEnv)}
show={
<Alert sx={{ mb: 2 }} severity='warning'>
SAML is currently configured via environment
variables. Please refer to the{' '}
<a
href='https://www.unleash-hosted.com/docs/enterprise-authentication'
target='_blank'
rel='noreferrer'
>
documentation
</a>{' '}
for detailed instructions on how to set up SAML
using these variables.
</Alert>
}
/>
<Alert severity='info'>
Please read the{' '}
<a
Expand Down Expand Up @@ -128,6 +148,7 @@ export const SamlAuth = () => {
value={data.enabled}
name='enabled'
checked={data.enabled}
disabled={samlConfiguredThroughEnv}
/>
}
label={data.enabled ? 'Enabled' : 'Disabled'}
Expand All @@ -145,7 +166,7 @@ export const SamlAuth = () => {
label='Entity ID'
name='entityId'
value={data.entityId}
disabled={!data.enabled}
disabled={!data.enabled || samlConfiguredThroughEnv}
style={{ width: '400px' }}
variant='outlined'
size='small'
Expand All @@ -167,7 +188,7 @@ export const SamlAuth = () => {
label='Single Sign-On URL'
name='signOnUrl'
value={data.signOnUrl}
disabled={!data.enabled}
disabled={!data.enabled || samlConfiguredThroughEnv}
style={{ width: '400px' }}
variant='outlined'
size='small'
Expand All @@ -189,7 +210,7 @@ export const SamlAuth = () => {
label='X.509 Certificate'
name='certificate'
value={data.certificate}
disabled={!data.enabled}
disabled={!data.enabled || samlConfiguredThroughEnv}
style={{ width: '100%' }}
InputProps={{
style: {
Expand Down Expand Up @@ -221,7 +242,7 @@ export const SamlAuth = () => {
label='Single Sign-out URL'
name='signOutUrl'
value={data.signOutUrl}
disabled={!data.enabled}
disabled={!data.enabled || samlConfiguredThroughEnv}
style={{ width: '400px' }}
variant='outlined'
size='small'
Expand All @@ -244,7 +265,7 @@ export const SamlAuth = () => {
label='X.509 Certificate'
name='spCertificate'
value={data.spCertificate}
disabled={!data.enabled}
disabled={!data.enabled || samlConfiguredThroughEnv}
style={{ width: '100%' }}
InputProps={{
style: {
Expand All @@ -265,20 +286,22 @@ export const SamlAuth = () => {
ssoType='SAML'
data={data}
setValue={setValue}
disabled={samlConfiguredThroughEnv}
/>

<AutoCreateForm
data={data}
setValue={setValue}
onUpdateRole={onUpdateRole}
disabled={samlConfiguredThroughEnv}
/>
<Grid container spacing={3}>
<Grid item md={5}>
<Button
variant='contained'
color='primary'
type='submit'
disabled={loading}
disabled={loading || samlConfiguredThroughEnv}
>
Save
</Button>{' '}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/interfaces/uiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface IUiConfig {
frontendApiOrigins?: string[];
resourceLimits: ResourceLimitsSchema;
oidcConfiguredThroughEnv?: boolean;
samlConfiguredThroughEnv?: boolean;
}

export interface IProclamationToast {
Expand Down

0 comments on commit d397819

Please sign in to comment.