mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 17:26:29 -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,
|
||||
"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",
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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 ? <ViaEMail/> : null
|
||||
const ldapForm = authProviders.ldap ? <ViaLdap/> : 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 (
|
||||
<Jumbotron className="bg-dark">
|
||||
<div className="my-3">
|
||||
|
@ -45,7 +56,10 @@ const Login: React.FC = () => {
|
|||
className="p-2 d-flex flex-column"
|
||||
key={value}
|
||||
>
|
||||
<ViaOAuth2 oauth2Type={value}/>
|
||||
<ViaOAuth2
|
||||
oauth2Type={value}
|
||||
optionalName={oauth2CustomName(value)}
|
||||
/>
|
||||
</Col>
|
||||
)
|
||||
})
|
||||
|
|
|
@ -16,7 +16,9 @@ export const initialState: BackendConfigState = {
|
|||
email: false
|
||||
},
|
||||
customAuthNames: {
|
||||
ldap: ""
|
||||
ldap: "",
|
||||
saml: "",
|
||||
oauth2: ""
|
||||
},
|
||||
specialLinks: {
|
||||
privacy: "",
|
||||
|
|
|
@ -24,6 +24,8 @@ export interface AuthProvidersState {
|
|||
|
||||
export interface CustomAuthNames {
|
||||
ldap: string;
|
||||
saml: string;
|
||||
oauth2: string;
|
||||
}
|
||||
|
||||
export interface SpecialLinks {
|
||||
|
|
Loading…
Reference in a new issue