Skip to content

Commit b0c0483

Browse files
authored
Merge pull request #27576 from bartvdbraak/add-login-redirect-to-sso
Add SSO redirect option for login page
2 parents 6c3817f + b61d5b4 commit b0c0483

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

docs/config.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,14 @@ When Element is deployed alongside a homeserver with SSO-only login, some option
250250
user can be sent to in order to log them out of that system too, making logout symmetric between Element and the SSO system.
251251
2. `sso_redirect_options`: Options to define how to handle unauthenticated users. If the object contains `"immediate": true`, then
252252
all unauthenticated users will be automatically redirected to the SSO system to start their login. If instead you'd only like to
253-
have users which land on the welcome page to be redirected, use `"on_welcome_page": true`. As an example:
253+
have users which land on the welcome page to be redirected, use `"on_welcome_page": true`. Additionally, there is an option to
254+
redirect anyone landing on the login page, by using `"on_login_page": true`. As an example:
254255
```json
255256
{
256257
"sso_redirect_options": {
257258
"immediate": false,
258-
"on_welcome_page": true
259+
"on_welcome_page": true,
260+
"on_login_page": true
259261
}
260262
}
261263
```

src/vector/app.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,14 @@ export async function loadApp(fragParams: {}, matrixChatRef: React.Ref<MatrixCha
8989
// XXX: This path matching is a bit brittle, but better to do it early instead of in the app code.
9090
const isWelcomeOrLanding =
9191
window.location.hash === "#/welcome" || window.location.hash === "#" || window.location.hash === "";
92+
const isLoginPage = window.location.hash === "#/login";
93+
9294
if (!autoRedirect && ssoRedirects.on_welcome_page && isWelcomeOrLanding) {
9395
autoRedirect = true;
9496
}
97+
if (!autoRedirect && ssoRedirects.on_login_page && isLoginPage) {
98+
autoRedirect = true;
99+
}
95100
if (!hasPossibleToken && !isReturningFromSso && autoRedirect) {
96101
logger.log("Bypassing app load to redirect to SSO");
97102
const tempCli = createClient({

0 commit comments

Comments
 (0)