mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 03:06:31 -05:00
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 <philip.molares@udo.edu>
This commit is contained in:
parent
83ab0bbe7e
commit
aeeb08ea5a
5 changed files with 28 additions and 8 deletions
|
@ -7,13 +7,15 @@
|
||||||
"gitlab": true,
|
"gitlab": true,
|
||||||
"dropbox": true,
|
"dropbox": true,
|
||||||
"ldap": true,
|
"ldap": true,
|
||||||
"google": false,
|
"google": true,
|
||||||
"saml": false,
|
"saml": true,
|
||||||
"oauth2": false,
|
"oauth2": true,
|
||||||
"email": true
|
"email": true
|
||||||
},
|
},
|
||||||
"customAuthNames": {
|
"customAuthNames": {
|
||||||
"ldap": "FooBar"
|
"ldap": "FooBar",
|
||||||
|
"saml": "aufSAMLn.de",
|
||||||
|
"oauth2": "Olaf2"
|
||||||
},
|
},
|
||||||
"specialLinks": {
|
"specialLinks": {
|
||||||
"privacy": "test",
|
"privacy": "test",
|
||||||
|
|
|
@ -63,7 +63,7 @@ const getMetadata: OAuth2Map = (oauth2type: OAuth2Type) => {
|
||||||
}
|
}
|
||||||
case OAuth2Type.OAUTH2:
|
case OAuth2Type.OAUTH2:
|
||||||
return {
|
return {
|
||||||
name: "oAuth2",
|
name: "OAuth2",
|
||||||
icon: "share",
|
icon: "share",
|
||||||
className: "btn-primary",
|
className: "btn-primary",
|
||||||
url: buildBackendAuthUrl("oauth2")
|
url: buildBackendAuthUrl("oauth2")
|
||||||
|
|
|
@ -10,11 +10,22 @@ import {ApplicationState} from "../../../../redux";
|
||||||
const Login: React.FC = () => {
|
const Login: React.FC = () => {
|
||||||
useTranslation();
|
useTranslation();
|
||||||
const authProviders = useSelector((state: ApplicationState) => state.backendConfig.authProviders);
|
const authProviders = useSelector((state: ApplicationState) => state.backendConfig.authProviders);
|
||||||
|
const customAuthNames = useSelector((state: ApplicationState) => state.backendConfig.customAuthNames);
|
||||||
const emailForm = authProviders.email ? <ViaEMail/> : null
|
const emailForm = authProviders.email ? <ViaEMail/> : null
|
||||||
const ldapForm = authProviders.ldap ? <ViaLdap/> : null
|
const ldapForm = authProviders.ldap ? <ViaLdap/> : null
|
||||||
const emailLdapSeperator = authProviders.email && authProviders.ldap ? <hr className="w-100 bg-white"/> : null
|
const emailLdapSeperator = authProviders.email && authProviders.ldap ? <hr className="w-100 bg-white"/> : 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 (
|
return (
|
||||||
<Jumbotron className="bg-dark">
|
<Jumbotron className="bg-dark">
|
||||||
<div className="my-3">
|
<div className="my-3">
|
||||||
|
@ -45,7 +56,10 @@ const Login: React.FC = () => {
|
||||||
className="p-2 d-flex flex-column"
|
className="p-2 d-flex flex-column"
|
||||||
key={value}
|
key={value}
|
||||||
>
|
>
|
||||||
<ViaOAuth2 oauth2Type={value}/>
|
<ViaOAuth2
|
||||||
|
oauth2Type={value}
|
||||||
|
optionalName={oauth2CustomName(value)}
|
||||||
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,7 +16,9 @@ export const initialState: BackendConfigState = {
|
||||||
email: false
|
email: false
|
||||||
},
|
},
|
||||||
customAuthNames: {
|
customAuthNames: {
|
||||||
ldap: ""
|
ldap: "",
|
||||||
|
saml: "",
|
||||||
|
oauth2: ""
|
||||||
},
|
},
|
||||||
specialLinks: {
|
specialLinks: {
|
||||||
privacy: "",
|
privacy: "",
|
||||||
|
|
|
@ -24,6 +24,8 @@ export interface AuthProvidersState {
|
||||||
|
|
||||||
export interface CustomAuthNames {
|
export interface CustomAuthNames {
|
||||||
ldap: string;
|
ldap: string;
|
||||||
|
saml: string;
|
||||||
|
oauth2: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SpecialLinks {
|
export interface SpecialLinks {
|
||||||
|
|
Loading…
Reference in a new issue