Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config parameter disabling forcing sso iframe #463

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Application extends App implements IBootstrap {
'show_labs_settings' => 'true',
'set_custom_permalink' => 'false',
'sso_immediate_redirect' => 'false',
'sso_force_iframe' => 'false',
];

public function __construct(array $urlParams = []) {
Expand Down
2 changes: 2 additions & 0 deletions lib/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function index() {

$this->initialStateService->provideInitialState(Application::APP_ID, 'disable_custom_urls',
$this->config->getAppValue(Application::APP_ID, 'disable_custom_urls', Application::AvailableSettings['disable_custom_urls']));
$this->initialStateService->provideInitialState(Application::APP_ID, 'sso_force_iframe',
$this->config->getAppValue(Application::APP_ID, 'sso_force_iframe', Application::AvailableSettings['sso_force_iframe']));

$default_server_domain = $this->config->getAppValue(Application::APP_ID, 'base_url', Application::AvailableSettings['base_url']);
$csp = new ContentSecurityPolicy();
Expand Down
13 changes: 13 additions & 0 deletions src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@
for="sso_immediate_redirect"
>{{ t('riotchat', 'Redirect immediately to SSO (requires SSO to be configured on the Matrix Homeserver)') }}</label>
<br>
<input
id="sso_force_iframe"
v-model="sso_force_iframe"
type="checkbox"
class="checkbox"
@change="updateSetting('sso_force_iframe')"
>
<label
ref="sso_force_iframe"
for="sso_force_iframe"
>{{ t('riotchat', 'Disable redirect to non-iframed version for SSO (make sure to set the headers to allow the SSO or CAS to be iframed)') }}</label>
<br>
<input
id="disable_login_language_selector"
v-model="disable_login_language_selector"
Expand Down Expand Up @@ -232,6 +244,7 @@ export default {
"custom_json_loading": false,
"set_custom_permalink": loadState('riotchat', 'set_custom_permalink') === 'true',
"sso_immediate_redirect": loadState('riotchat', 'sso_immediate_redirect') === 'true',
"sso_force_iframe": loadState('riotchat', 'sso_force_iframe') === 'true',
};
},
computed: {
Expand Down
23 changes: 13 additions & 10 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,19 @@ function onIframeLoad () {
}
};

// Watch for the localStorage change that indicates that an SSO sign in is being attempted
// eslint-disable-next-line no-proto
iframe.contentWindow.localStorage.__proto__.setItem = function (...params) {
// It looks like an SSO or CAS login is being attempted
if (params[0] === "mx_sso_hs_url" && iframe.contentWindow.location.hash === "#/login") {
// Kick them to the non-iframed version. A bit jarring but SSO login most likely won't work in the iframe.
window.location.href = generateUrl('/apps/riotchat/riot/#/login');
}
window.localStorage.setItem.apply(this, params);
};
// Setting sso_force_iframe (in config) to true forces iframe even if using SSO or CAS login
if (loadState('riotchat', 'sso_force_iframe') !== 'true') {
// Watch for the localStorage change that indicates that an SSO sign in is being attempted
// eslint-disable-next-line no-proto
iframe.contentWindow.localStorage.__proto__.setItem = function (...params) {
// It looks like an SSO or CAS login is being attempted
if (params[0] === "mx_sso_hs_url" && iframe.contentWindow.location.hash === "#/login") {
// Kick them to the non-iframed version. A bit jarring but SSO login most likely won't work in the iframe.
window.location.href = generateUrl('/apps/riotchat/riot/#/login');
}
window.localStorage.setItem.apply(this, params);
};
}
}

function iframeHashChanged () {
Expand Down