From c197661be082acfb6fa5223bd9f3898a16c31111 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 2 Mar 2020 14:59:55 +0000 Subject: [PATCH] riot-desktop open SSO in browser so user doesn't have to auth twice --- src/i18n/strings/en_EN.json | 2 ++ src/vector/platform/ElectronPlatform.js | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 523e4551b7..635374d241 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -7,6 +7,8 @@ "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.": "Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.", "Invalid configuration: no default server specified.": "Invalid configuration: no default server specified.", "Riot Desktop on %(platformName)s": "Riot Desktop on %(platformName)s", + "Single sign-on": "Single sign-on", + "Go to the browser to complete login": "Go to the browser to complete login", "Unknown device": "Unknown device", "%(appName)s via %(browserName)s on %(osName)s": "%(appName)s via %(browserName)s on %(osName)s", "You need to be using HTTPS to place a screen-sharing call.": "You need to be using HTTPS to place a screen-sharing call.", diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 8e29542a17..46332c1eda 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -5,6 +5,7 @@ Copyright 2016 Aviral Dasgupta Copyright 2016 OpenMarket Ltd Copyright 2018 New Vector Ltd Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> +`Copyright 2020 The Matrix.org Foundation C.I.C. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -24,6 +25,11 @@ import BaseEventIndexManager from 'matrix-react-sdk/src/indexing/BaseEventIndexM import dis from 'matrix-react-sdk/src/dispatcher'; import { _t } from 'matrix-react-sdk/src/languageHandler'; import * as rageshake from 'matrix-react-sdk/src/rageshake/rageshake'; +import {MatrixClient} from "matrix-js-sdk"; +import Modal from "matrix-react-sdk/src/Modal"; +import InfoDialog from "matrix-react-sdk/src/components/views/dialogs/InfoDialog"; +import Spinner from "matrix-react-sdk/src/components/views/elements/Spinner"; +import React from "react"; const ipcRenderer = window.ipcRenderer; @@ -392,4 +398,21 @@ export default class ElectronPlatform extends VectorBasePlatform { console.error(error); }); } + + getSSOCallbackUrl(hsUrl: string, isUrl: string): URL { + const url = super.getSSOCallbackUrl(hsUrl, isUrl); + url.protocol = "riot"; + return url; + } + + startSingleSignOn(mxClient: MatrixClient, loginType: "sso" | "cas") { + super.startSingleSignOn(mxClient, loginType); // this will get intercepted by electron-main will-navigate + Modal.createTrackedDialog('Electron', 'SSO', InfoDialog, { + title: _t("Single sign-on"), + description:
+ {_t("Go to the browser to complete login")} + +
, + }); + } }