mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 09:45:29 +00:00
feat: auto redirect to the SSO login page
This commit is contained in:
parent
dd6c121936
commit
dd5dba17fc
1
.env
1
.env
@ -73,6 +73,7 @@ OAUTH_AUTHORIZATION_URL=
|
||||
OAUTH_TOKEN_URL=
|
||||
OAUTH_USERINFO_URL=
|
||||
OAUTH_SCOPE=
|
||||
SSO_AUTO_REDIRECT=0
|
||||
|
||||
# Typically your IP address, this envvar is required for
|
||||
# some connectors that need to be provided with your host's
|
||||
|
||||
@ -129,7 +129,7 @@ export default function App(): React.ReactElement {
|
||||
}}
|
||||
>
|
||||
<Routes>
|
||||
<Route path='/' element={<Navigate to='/login'/>}/>
|
||||
<Route path='/' element={<Navigate to='/home'/>}/>
|
||||
<Route path='/home' element={<TextPage resource='home.md'/>}/>
|
||||
|
||||
<Route path='/search/domain' element={<DomainSearchPage/>}/>
|
||||
|
||||
@ -30,7 +30,13 @@ export default function LoginPage() {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getConfiguration().then(setConfiguration)
|
||||
getConfiguration().then((configuration) => {
|
||||
if(!configuration.registerEnabled && configuration.ssoLogin && configuration.ssoAutoRedirect) {
|
||||
window.location.href = '/login/oauth'
|
||||
return
|
||||
}
|
||||
setConfiguration(configuration)
|
||||
})
|
||||
}, [])
|
||||
|
||||
const grid = [
|
||||
|
||||
@ -105,6 +105,7 @@ export interface Watchlist {
|
||||
}
|
||||
|
||||
export interface InstanceConfig {
|
||||
ssoAutoRedirect: boolean
|
||||
ssoLogin: boolean
|
||||
limtedFeatures: boolean
|
||||
registerEnabled: boolean
|
||||
|
||||
@ -9,6 +9,7 @@ parameters:
|
||||
mailer_sender_email: '%env(string:MAILER_SENDER_EMAIL)%'
|
||||
mailer_sender_name: '%env(string:MAILER_SENDER_NAME)%'
|
||||
oauth_enabled: '%env(OAUTH_CLIENT_ID)%'
|
||||
sso_auto_redirect: '%env(bool:SSO_AUTO_REDIRECT)%'
|
||||
registration_enabled: '%env(bool:REGISTRATION_ENABLED)%'
|
||||
registration_verify_email: '%env(bool:REGISTRATION_VERIFY_EMAIL)%'
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ import {LinkCard} from '@astrojs/starlight/components';
|
||||
| `OAUTH_TOKEN_URL` | Token URL (OAuth 2.0) | |
|
||||
| `OAUTH_USERINFO_URL` | User Info URL (OAuth 2.0) | |
|
||||
| `OAUTH_SCOPE` | Scope (OAuth 2.0) | |
|
||||
| `SSO_AUTO_REDIRECT` | Redirection to the SSO auth URL | |
|
||||
|
||||
|
||||
## Authentication
|
||||
|
||||
@ -33,6 +33,7 @@ import {LinkCard} from '@astrojs/starlight/components';
|
||||
| `OAUTH_TOKEN_URL` | URL de jeton (OAuth 2.0) | |
|
||||
| `OAUTH_USERINFO_URL` | URL des informations utilisateur (OAuth 2.0) | |
|
||||
| `OAUTH_SCOPE` | Scope (OAuth 2.0) | |
|
||||
| `SSO_AUTO_REDIRECT` | Redirection vers l'URL d'authentification du SSO | |
|
||||
|
||||
|
||||
## Authentification
|
||||
|
||||
@ -14,7 +14,8 @@ class InstanceController extends AbstractController
|
||||
$instance
|
||||
->setLimitedFeatures($this->getParameter('limited_features') ?? false)
|
||||
->setOauthEnabled($this->getParameter('oauth_enabled') ?? false)
|
||||
->setRegisterEnabled($this->getParameter('registration_enabled') ?? false);
|
||||
->setRegisterEnabled($this->getParameter('registration_enabled') ?? false)
|
||||
->setSsoAutoRedirect($this->getParameter('sso_auto_redirect') ?? false);
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
@ -25,6 +25,8 @@ class Instance
|
||||
|
||||
private ?bool $limitedFeatures = null;
|
||||
|
||||
private ?bool $ssoAutoRedirect = null;
|
||||
|
||||
public function isSsoLogin(): ?bool
|
||||
{
|
||||
return $this->oauthEnabled;
|
||||
@ -60,4 +62,16 @@ class Instance
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSsoAutoRedirect(): ?bool
|
||||
{
|
||||
return $this->ssoAutoRedirect;
|
||||
}
|
||||
|
||||
public function setSsoAutoRedirect(?bool $ssoAutoRedirect): static
|
||||
{
|
||||
$this->ssoAutoRedirect = $ssoAutoRedirect;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user