Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Support for m.login.sso #2279

Merged
merged 1 commit into from
Nov 19, 2018
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
11 changes: 11 additions & 0 deletions res/css/structures/login/_Login.scss
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,17 @@ limitations under the License.
color: $primary-fg-color;
}

.mx_Login_sso_link {
display: block;
text-align: center;
font-size: 15px;
margin-bottom: 20px;
}

.mx_Login_sso_link:link {
color: $primary-fg-color;
}

.mx_Login_loader {
display: inline;
position: relative;
Expand Down
8 changes: 3 additions & 5 deletions src/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.
*/

import Matrix from "matrix-js-sdk";
import { _t } from "./languageHandler";

import Promise from 'bluebird';
import url from 'url';
Expand Down Expand Up @@ -225,19 +224,18 @@ export default class Login {
});
}

redirectToCas() {
getSsoLoginUrl(loginType) {
const client = this._createTemporaryClient();
const parsedUrl = url.parse(window.location.href, true);

// XXX: at this point, the fragment will always be #/login, which is no
// use to anyone. Ideally, we would get the intended fragment from
// MatrixChat.screenAfterLogin so that you could follow #/room links etc
// through a CAS login.
// through an SSO login.
parsedUrl.hash = "";

parsedUrl.query["homeserver"] = client.getHomeserverUrl();
parsedUrl.query["identityServer"] = client.getIdentityServerUrl();
const casUrl = client.getCasLoginUrl(url.format(parsedUrl));
window.location.href = casUrl;
return client.getSsoLoginUrl(url.format(parsedUrl), loginType);
}
}
14 changes: 6 additions & 8 deletions src/components/structures/login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ module.exports = React.createClass({
// letting you do that login type
this._stepRendererMap = {
'm.login.password': this._renderPasswordStep,
'm.login.cas': this._renderCasStep,

// CAS and SSO are the same thing, modulo the url we link to
'm.login.cas': () => this._renderSsoStep(this._loginLogic.getSsoLoginUrl("cas")),
'm.login.sso': () => this._renderSsoStep(this._loginLogic.getSsoLoginUrl("sso")),
};

this._initLoginLogic();
Expand Down Expand Up @@ -186,10 +189,6 @@ module.exports = React.createClass({
}).done();
},

onCasLogin: function() {
this._loginLogic.redirectToCas();
},

_onLoginAsGuestClick: function() {
const self = this;
self.setState({
Expand Down Expand Up @@ -403,10 +402,9 @@ module.exports = React.createClass({
);
},

_renderCasStep: function() {
const CasLogin = sdk.getComponent('login.CasLogin');
_renderSsoStep: function(url) {
return (
<CasLogin onSubmit={this.onCasLogin} />
<a href={url} className="mx_Login_sso_link">{ _t('Sign in with single sign-on') }</a>
);
},

Expand Down
38 changes: 0 additions & 38 deletions src/components/views/login/CasLogin.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@
"Message removed": "Message removed",
"Robot check is currently unavailable on desktop - please use a <a>web browser</a>": "Robot check is currently unavailable on desktop - please use a <a>web browser</a>",
"This Home Server would like to make sure you are not a robot": "This Home Server would like to make sure you are not a robot",
"Sign in with CAS": "Sign in with CAS",
"Custom Server Options": "Custom Server Options",
"You can use the custom server options to sign into other Matrix servers by specifying a different Home server URL.": "You can use the custom server options to sign into other Matrix servers by specifying a different Home server URL.",
"This allows you to use this app with an existing Matrix account on a different home server.": "This allows you to use this app with an existing Matrix account on a different home server.",
Expand Down Expand Up @@ -1218,6 +1217,7 @@
"Error: Problem communicating with the given homeserver.": "Error: Problem communicating with the given homeserver.",
"Can't connect to homeserver via HTTP when an HTTPS URL is in your browser bar. Either use HTTPS or <a>enable unsafe scripts</a>.": "Can't connect to homeserver via HTTP when an HTTPS URL is in your browser bar. Either use HTTPS or <a>enable unsafe scripts</a>.",
"Can't connect to homeserver - please check your connectivity, ensure your <a>homeserver's SSL certificate</a> is trusted, and that a browser extension is not blocking requests.": "Can't connect to homeserver - please check your connectivity, ensure your <a>homeserver's SSL certificate</a> is trusted, and that a browser extension is not blocking requests.",
"Sign in with single sign-on": "Sign in with single sign-on",
"Try the app first": "Try the app first",
"Sign in to get started": "Sign in to get started",
"Failed to fetch avatar URL": "Failed to fetch avatar URL",
Expand Down