mirror of https://github.com/vector-im/riot-web
Update CAS login to allow HS to do interaction with CAS and client receives and redeems login token
parent
3fec3a7326
commit
de165ea6ad
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright 2015 OpenMarket Ltd
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var url = require ('url');
|
|
||||||
|
|
||||||
function getServiceUrl() {
|
|
||||||
var parsedUrl = url.parse(window.location.href);
|
|
||||||
return parsedUrl.protocol + "//" + parsedUrl.host + parsedUrl.pathname;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
getServiceUrl: getServiceUrl
|
|
||||||
};
|
|
|
@ -17,20 +17,16 @@ limitations under the License.
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var MatrixClientPeg = require("../../MatrixClientPeg");
|
var MatrixClientPeg = require("../../MatrixClientPeg");
|
||||||
var Cas = require("../../CasLogic");
|
var url = require("url");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
onCasClicked: function(ev) {
|
onCasClicked: function(ev) {
|
||||||
var serviceRedirectUrl = Cas.getServiceUrl() + "#/login/cas";
|
var cli = MatrixClientPeg.get();
|
||||||
var self = this;
|
var parsedUrl = url.parse(window.location.href, true);
|
||||||
MatrixClientPeg.get().getCasServer().done(function(data) {
|
parsedUrl.query["homeserver"] = cli.getHomeserverUrl();
|
||||||
var serverUrl = data.serverUrl + "/login?service=" + encodeURIComponent(serviceRedirectUrl);
|
parsedUrl.query["identityServer"] = cli.getIdentityServerUrl();
|
||||||
window.location.href = serverUrl;
|
MatrixClientPeg.get().loginWithCas(url.format(parsedUrl));
|
||||||
}, function(error) {
|
|
||||||
self.setStep("stage_m.login.cas");
|
|
||||||
self.setState({errorText: 'Login failed.'});
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,8 +23,6 @@ var sdk = require('../../index');
|
||||||
var MatrixTools = require('../../MatrixTools');
|
var MatrixTools = require('../../MatrixTools');
|
||||||
var linkifyMatrix = require("../../linkify-matrix");
|
var linkifyMatrix = require("../../linkify-matrix");
|
||||||
|
|
||||||
var Cas = require("../../CasLogic");
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
PageTypes: {
|
PageTypes: {
|
||||||
RoomView: "room_view",
|
RoomView: "room_view",
|
||||||
|
@ -140,14 +138,17 @@ module.exports = {
|
||||||
});
|
});
|
||||||
this.notifyNewScreen('login');
|
this.notifyNewScreen('login');
|
||||||
break;
|
break;
|
||||||
case 'cas_login':
|
case 'token_login':
|
||||||
if (this.state.logged_in) return;
|
if (this.state.logged_in) return;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
var client = MatrixClientPeg.get();
|
MatrixClientPeg.replaceUsingUrls(
|
||||||
var serviceUrl = Cas.getServiceUrl();
|
payload.params.homeserver,
|
||||||
|
payload.params.identityServer
|
||||||
|
);
|
||||||
|
|
||||||
client.loginWithCas(payload.params.ticket, serviceUrl).done(function(data) {
|
var client = MatrixClientPeg.get();
|
||||||
|
client.loginWithToken(payload.params.loginToken).done(function(data) {
|
||||||
MatrixClientPeg.replaceUsingAccessToken(
|
MatrixClientPeg.replaceUsingAccessToken(
|
||||||
client.getHomeserverUrl(), client.getIdentityServerUrl(),
|
client.getHomeserverUrl(), client.getIdentityServerUrl(),
|
||||||
data.user_id, data.access_token
|
data.user_id, data.access_token
|
||||||
|
@ -387,9 +388,9 @@ module.exports = {
|
||||||
action: 'start_login',
|
action: 'start_login',
|
||||||
params: params
|
params: params
|
||||||
});
|
});
|
||||||
} else if (screen == 'cas_login') {
|
} else if (screen == 'token_login') {
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'cas_login',
|
action: 'token_login',
|
||||||
params: params
|
params: params
|
||||||
});
|
});
|
||||||
} else if (screen.indexOf('room/') == 0) {
|
} else if (screen.indexOf('room/') == 0) {
|
||||||
|
|
Loading…
Reference in New Issue