diff --git a/src/CasLogic.js b/src/CasLogic.js
deleted file mode 100644
index 1bcc6d5c78e4e026844e25a225038aa5ac7986ba..0000000000000000000000000000000000000000
--- a/src/CasLogic.js
+++ /dev/null
@@ -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
-};
diff --git a/src/controllers/organisms/CasLogin.js b/src/controllers/organisms/CasLogin.js
index b01c3781b03f8bb31b5b36b507628e3943592022..d84306e5879bb54ab43b0f79a1923d8af782b1c0 100644
--- a/src/controllers/organisms/CasLogin.js
+++ b/src/controllers/organisms/CasLogin.js
@@ -17,20 +17,17 @@ limitations under the License.
 'use strict';
 
 var MatrixClientPeg = require("../../MatrixClientPeg");
-var Cas = require("../../CasLogic");
+var url = require("url");
 
 module.exports = {
 
     onCasClicked: function(ev) {
-        var serviceRedirectUrl = Cas.getServiceUrl() + "#/login/cas";
-        var self = this;
-        MatrixClientPeg.get().getCasServer().done(function(data) {
-            var serverUrl = data.serverUrl + "/login?service=" + encodeURIComponent(serviceRedirectUrl);
-            window.location.href = serverUrl;
-        }, function(error) {
-            self.setStep("stage_m.login.cas");
-            self.setState({errorText: 'Login failed.'});
-        });
+        var cli = MatrixClientPeg.get();
+        var parsedUrl = url.parse(window.location.href, true);
+        parsedUrl.query["homeserver"] = cli.getHomeserverUrl();
+        parsedUrl.query["identityServer"] = cli.getIdentityServerUrl();
+        var casUrl = MatrixClientPeg.get().getCasLoginUrl(url.format(parsedUrl));
+        window.location.href = casUrl;
     },
 
 };
diff --git a/src/controllers/pages/MatrixChat.js b/src/controllers/pages/MatrixChat.js
index 57344b5a694ee1dcea3536f8f7e6eb356f07b4cd..93464da526cb7690ae6042ebd866d984894e7909 100644
--- a/src/controllers/pages/MatrixChat.js
+++ b/src/controllers/pages/MatrixChat.js
@@ -23,7 +23,7 @@ var sdk = require('../../index');
 var MatrixTools = require('../../MatrixTools');
 var linkifyMatrix = require("../../linkify-matrix");
 
-var Cas = require("../../CasLogic");
+var url = require('url');
 
 module.exports = {
     PageTypes: {
@@ -140,14 +140,17 @@ module.exports = {
                 });
                 this.notifyNewScreen('login');
                 break;
-            case 'cas_login':
+            case 'token_login':
                 if (this.state.logged_in) return;
 
                 var self = this;
-                var client = MatrixClientPeg.get();
-                var serviceUrl = Cas.getServiceUrl();
+                MatrixClientPeg.replaceUsingUrls(
+                    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(
                         client.getHomeserverUrl(), client.getIdentityServerUrl(),
                         data.user_id, data.access_token
@@ -156,8 +159,13 @@ module.exports = {
                         screen: undefined,
                         logged_in: true
                     });
-                    self.startMatrixClient();
-                    self.notifyNewScreen('');
+
+                    // We're left with the login token, hs and is url as query params
+                    // in the url, a little nasty but let's redirect to clear them
+                    var parsedUrl = url.parse(window.location.href);
+                    parsedUrl.search = "";
+                    window.location.href = url.format(parsedUrl);
+
                 }, function(error) {
                     self.notifyNewScreen('login');
                     self.setState({errorText: 'Login failed.'});
@@ -388,9 +396,9 @@ module.exports = {
                 action: 'start_login',
                 params: params
             });
-        } else if (screen == 'cas_login') {
+        } else if (screen == 'token_login') {
             dis.dispatch({
-                action: 'cas_login',
+                action: 'token_login',
                 params: params
             });
         } else if (screen.indexOf('room/') == 0) {