From aeeb08ea5af484ab694643ca08ea6b2762bd9b76 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Sat, 16 May 2020 20:38:02 +0200 Subject: [PATCH] Feature/custom oauth saml names (#31) * using saml and oauth2 customAuthNames in login * add saml and oauth2 customAuthNames to backend config * changed default name of oauth button Signed-off-by: Philip Molares --- public/backend-config.json | 10 ++++++---- .../landing/pages/login/auth/via-oauth2.tsx | 2 +- src/components/landing/pages/login/login.tsx | 18 ++++++++++++++++-- src/redux/backend-config/reducers.ts | 4 +++- src/redux/backend-config/types.ts | 2 ++ 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/public/backend-config.json b/public/backend-config.json index c016dc1db..3f025a875 100644 --- a/public/backend-config.json +++ b/public/backend-config.json @@ -7,13 +7,15 @@ "gitlab": true, "dropbox": true, "ldap": true, - "google": false, - "saml": false, - "oauth2": false, + "google": true, + "saml": true, + "oauth2": true, "email": true }, "customAuthNames": { - "ldap": "FooBar" + "ldap": "FooBar", + "saml": "aufSAMLn.de", + "oauth2": "Olaf2" }, "specialLinks": { "privacy": "test", diff --git a/src/components/landing/pages/login/auth/via-oauth2.tsx b/src/components/landing/pages/login/auth/via-oauth2.tsx index 5f05e5fcb..e135aa5ab 100644 --- a/src/components/landing/pages/login/auth/via-oauth2.tsx +++ b/src/components/landing/pages/login/auth/via-oauth2.tsx @@ -63,7 +63,7 @@ const getMetadata: OAuth2Map = (oauth2type: OAuth2Type) => { } case OAuth2Type.OAUTH2: return { - name: "oAuth2", + name: "OAuth2", icon: "share", className: "btn-primary", url: buildBackendAuthUrl("oauth2") diff --git a/src/components/landing/pages/login/login.tsx b/src/components/landing/pages/login/login.tsx index 78a610a88..df37c0d07 100644 --- a/src/components/landing/pages/login/login.tsx +++ b/src/components/landing/pages/login/login.tsx @@ -10,11 +10,22 @@ import {ApplicationState} from "../../../../redux"; const Login: React.FC = () => { useTranslation(); const authProviders = useSelector((state: ApplicationState) => state.backendConfig.authProviders); - + const customAuthNames = useSelector((state: ApplicationState) => state.backendConfig.customAuthNames); const emailForm = authProviders.email ? : null const ldapForm = authProviders.ldap ? : null const emailLdapSeperator = authProviders.email && authProviders.ldap ?
: null + const oauth2CustomName: (type: OAuth2Type) => string | undefined = (type) => { + switch (type) { + case OAuth2Type.SAML: + return customAuthNames.saml; + case OAuth2Type.OAUTH2: + return customAuthNames.oauth2; + default: + return undefined; + } + } + return (
@@ -45,7 +56,10 @@ const Login: React.FC = () => { className="p-2 d-flex flex-column" key={value} > - + ) }) diff --git a/src/redux/backend-config/reducers.ts b/src/redux/backend-config/reducers.ts index 199d2fa37..c5d7223c2 100644 --- a/src/redux/backend-config/reducers.ts +++ b/src/redux/backend-config/reducers.ts @@ -16,7 +16,9 @@ export const initialState: BackendConfigState = { email: false }, customAuthNames: { - ldap: "" + ldap: "", + saml: "", + oauth2: "" }, specialLinks: { privacy: "", diff --git a/src/redux/backend-config/types.ts b/src/redux/backend-config/types.ts index 8a3c1c498..742004f35 100644 --- a/src/redux/backend-config/types.ts +++ b/src/redux/backend-config/types.ts @@ -24,6 +24,8 @@ export interface AuthProvidersState { export interface CustomAuthNames { ldap: string; + saml: string; + oauth2: string; } export interface SpecialLinks {