Automatically re-authenticate on single-logout (#28723)
Automatically forces the user to re-authenticate from the Admin and Account consoles when a single-logout occurs. Closes #23832 Closes #23833 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com> Signed-off-by: Jon Koops <jonkoops@gmail.com> Co-authored-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
parent
5ae1712f73
commit
957859d846
2 changed files with 15 additions and 10 deletions
|
@ -42,12 +42,17 @@ export const KeycloakProvider = ({
|
||||||
const [init, setInit] = useState(false);
|
const [init, setInit] = useState(false);
|
||||||
const [error, setError] = useState<unknown>();
|
const [error, setError] = useState<unknown>();
|
||||||
const keycloak = useMemo(
|
const keycloak = useMemo(
|
||||||
() =>
|
() => {
|
||||||
new Keycloak({
|
const keycloak = new Keycloak({
|
||||||
url: environment.authUrl,
|
url: environment.authUrl,
|
||||||
realm: environment.realm,
|
realm: environment.realm,
|
||||||
clientId: environment.clientId,
|
clientId: environment.clientId,
|
||||||
}),
|
});
|
||||||
|
|
||||||
|
keycloak.onAuthLogout = () => keycloak.login();
|
||||||
|
|
||||||
|
return keycloak;
|
||||||
|
},
|
||||||
[environment],
|
[environment],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -57,13 +62,11 @@ export const KeycloakProvider = ({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const init = () => {
|
const init = () => keycloak.init({
|
||||||
return keycloak.init({
|
onLoad: "check-sso",
|
||||||
onLoad: "check-sso",
|
pkceMethod: "S256",
|
||||||
pkceMethod: "S256",
|
responseMode: "query",
|
||||||
responseMode: "query",
|
});
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
init()
|
init()
|
||||||
.then(() => setInit(true))
|
.then(() => setInit(true))
|
||||||
|
|
|
@ -8,6 +8,8 @@ export const keycloak = new Keycloak({
|
||||||
clientId: environment.clientId,
|
clientId: environment.clientId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
keycloak.onAuthLogout = () => keycloak.login();
|
||||||
|
|
||||||
export async function initKeycloak() {
|
export async function initKeycloak() {
|
||||||
const authenticated = await keycloak.init({
|
const authenticated = await keycloak.init({
|
||||||
onLoad: "check-sso",
|
onLoad: "check-sso",
|
||||||
|
|
Loading…
Reference in a new issue