Skip to content

Commit 7598be6

Browse files
committed
Merge pull request element-hq#198 from stevenhammerton/sh-cas-auth
Add support for CAS auth
2 parents 1dd7077 + 293ee1b commit 7598be6

4 files changed

Lines changed: 59 additions & 11 deletions

File tree

‎src/skins/vector/skindex.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ skin['molecules.UserSelector'] = require('./views/molecules/UserSelector');
6666
skin['molecules.voip.CallView'] = require('./views/molecules/voip/CallView');
6767
skin['molecules.voip.IncomingCallBox'] = require('./views/molecules/voip/IncomingCallBox');
6868
skin['molecules.voip.VideoView'] = require('./views/molecules/voip/VideoView');
69+
skin['organisms.CasLogin'] = require('./views/organisms/CasLogin');
6970
skin['organisms.CreateRoom'] = require('./views/organisms/CreateRoom');
7071
skin['organisms.ErrorDialog'] = require('./views/organisms/ErrorDialog');
7172
skin['organisms.LeftPanel'] = require('./views/organisms/LeftPanel');
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var React = require('react');
20+
21+
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
22+
23+
var CasLoginController = require('matrix-react-sdk/lib/controllers/organisms/CasLogin');
24+
25+
module.exports = React.createClass({
26+
displayName: 'CasLogin',
27+
mixins: [CasLoginController],
28+
29+
render: function() {
30+
return (
31+
<div>
32+
<button onClick={this.onCasClicked}>Sign in with CAS</button>
33+
</div>
34+
);
35+
},
36+
37+
});

‎src/skins/vector/views/templates/Login.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ module.exports = React.createClass({
141141
</form>
142142
</div>
143143
);
144+
case 'stage_m.login.cas':
145+
var CasLogin = sdk.getComponent('organisms.CasLogin');
146+
return (
147+
<CasLogin />
148+
);
144149
}
145150
},
146151

‎src/vector/index.js‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,29 @@ var sdk = require("matrix-react-sdk");
2121
sdk.loadSkin(require('../skins/vector/skindex'));
2222
sdk.loadModule(require('../modules/VectorConferenceHandler'));
2323

24+
var qs = require("querystring");
25+
2426
var lastLocationHashSet = null;
2527

28+
29+
// We want to support some name / value pairs in the fragment
30+
// so we're re-using query string like format
31+
function parseQsFromFragment(location) {
32+
var hashparts = location.hash.split('?');
33+
if (hashparts.length > 1) {
34+
return qs.parse(hashparts[1]);
35+
}
36+
return {};
37+
}
38+
2639
// Here, we do some crude URL analysis to allow
2740
// deep-linking. We only support registration
2841
// deep-links in this example.
2942
function routeUrl(location) {
3043
if (location.hash.indexOf('#/register') == 0) {
31-
var hashparts = location.hash.split('?');
32-
var params = {};
33-
if (hashparts.length == 2) {
34-
var pairs = hashparts[1].split('&');
35-
for (var i = 0; i < pairs.length; ++i) {
36-
var parts = pairs[i].split('=');
37-
if (parts.length != 2) continue;
38-
params[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
39-
}
40-
}
41-
window.matrixChat.showScreen('register', params);
44+
window.matrixChat.showScreen('register', parseQsFromFragment(location));
45+
} else if (location.hash.indexOf('#/login/cas') == 0) {
46+
window.matrixChat.showScreen('cas_login', parseQsFromFragment(location));
4247
} else {
4348
window.matrixChat.showScreen(location.hash.substring(2));
4449
}

0 commit comments

Comments
 (0)