Skip to content

Commit

Permalink
chore: new hosted auth handler
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogois committed Dec 30, 2024
1 parent 71eb6b1 commit 33ac286
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 46 deletions.
53 changes: 8 additions & 45 deletions frontend/src/component/admin/auth/AuthSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Alert, Tab, Tabs } from '@mui/material';
import { Tab, Tabs } from '@mui/material';
import { PageContent } from 'component/common/PageContent/PageContent';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
Expand All @@ -15,7 +15,6 @@ import { TabPanel } from 'component/common/TabNav/TabPanel/TabPanel';
import { usePageTitle } from 'hooks/usePageTitle';

export const AuthSettings = () => {
const { authenticationType } = useUiConfig().uiConfig;
const { uiConfig, isEnterprise } = useUiConfig();

const tabs = [
Expand All @@ -35,17 +34,14 @@ export const AuthSettings = () => {
label: 'Google',
component: <GoogleAuth />,
},
{
label: 'SCIM',
component: <ScimSettings />,
},
].filter(
(item) => uiConfig.flags?.googleAuthEnabled || item.label !== 'Google',
);

if (isEnterprise()) {
tabs.push({
label: 'SCIM',
component: <ScimSettings />,
});
}

const [activeTab, setActiveTab] = useState(0);
usePageTitle(`Single sign-on: ${tabs[activeTab].label}`);

Expand All @@ -56,7 +52,7 @@ export const AuthSettings = () => {
withTabs
header={
<ConditionallyRender
condition={authenticationType === 'enterprise'}
condition={isEnterprise()}
show={
<Tabs
value={activeTab}
Expand Down Expand Up @@ -85,41 +81,7 @@ export const AuthSettings = () => {
}
>
<ConditionallyRender
condition={authenticationType === 'open-source'}
show={<PremiumFeature feature='sso' />}
/>
<ConditionallyRender
condition={authenticationType === 'demo'}
show={
<Alert severity='warning'>
You are running Unleash in demo mode. You have
to use the Enterprise edition in order configure
Single Sign-on.
</Alert>
}
/>
<ConditionallyRender
condition={authenticationType === 'custom'}
show={
<Alert severity='warning'>
You have decided to use custom authentication
type. You have to use the Enterprise edition in
order configure Single Sign-on from the user
interface.
</Alert>
}
/>
<ConditionallyRender
condition={authenticationType === 'hosted'}
show={
<Alert severity='info'>
Your Unleash instance is managed by the Unleash
team.
</Alert>
}
/>
<ConditionallyRender
condition={authenticationType === 'enterprise'}
condition={isEnterprise()}
show={
<div>
{tabs.map((tab, index) => (
Expand All @@ -133,6 +95,7 @@ export const AuthSettings = () => {
))}
</div>
}
elseShow={<PremiumFeature feature='sso' />}
/>
</PageContent>
</PermissionGuard>
Expand Down
7 changes: 6 additions & 1 deletion src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export type IFlagKey =
| 'streaming'
| 'etagVariant'
| 'oidcRedirect'
| 'deltaApi';
| 'deltaApi'
| 'newHostedAuthHandler';

export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>;

Expand Down Expand Up @@ -295,6 +296,10 @@ const flags: IFlags = {
process.env.UNLEASH_EXPERIMENTAL_DELTA_API,
false,
),
newHostedAuthHandler: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_NEW_HOSTED_AUTH_HANDLER,
false,
),
};

export const defaultExperimentalOptions: IExperimentalOptions = {
Expand Down
6 changes: 6 additions & 0 deletions src/lib/types/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ export interface IVersionOption {
export enum IAuthType {
OPEN_SOURCE = 'open-source',
DEMO = 'demo',
/**
* Self-hosted by the customer. Should eventually be renamed to better reflect this.
*/
ENTERPRISE = 'enterprise',
/**
* Hosted by Unleash.
*/
HOSTED = 'hosted',
CUSTOM = 'custom',
NONE = 'none',
Expand Down

0 comments on commit 33ac286

Please sign in to comment.