Skip to content

Commit

Permalink
#1420 No longer rely on JS and XHR to handle the SSO redirections
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Jun 30, 2020
1 parent b0b7032 commit c9b7cb5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 40 deletions.
28 changes: 0 additions & 28 deletions frontend/app/scripts/controllers/AuthenticationCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,6 @@

$uibModalStack.dismissAll();

$scope.ssoLogin = function (code, state) {
AuthenticationSrv.ssoLogin(code, state)
.then(function(response) {
var redirectLocation = response.headers().location;
if(angular.isDefined(redirectLocation)) {
window.location = redirectLocation;
} else {
$rootScope.isLoading = true;
// Simple redirect to remove oauth2 query strings from url (before hash)
window.location.replace(window.location.origin + window.location.pathname);
}
})
.catch(function(err) {
if (err.status === 520) {
NotificationSrv.error('AuthenticationCtrl', err.data, err.status);
} else {
NotificationSrv.log(err.data.message, 'error');
}
$location.url($location.path());
});
};

$scope.ssoEnabled = function() {
return appConfig.config.authType.indexOf("oauth2") !== -1;
};
Expand All @@ -54,11 +32,5 @@
}
});
};

var code = UtilsSrv.extractQueryParam('code', UrlParser('query', $location.absUrl()));
var state = UtilsSrv.extractQueryParam('state', UrlParser('query', $location.absUrl()));
if((angular.isDefined(code) && angular.isDefined(state)) || $stateParams.autoLogin) {
$scope.ssoLogin(code, state);
}
});
})();
4 changes: 0 additions & 4 deletions frontend/app/scripts/services/api/AuthenticationSrv.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@
return $q.reject(err);
});
},
ssoLogin: function(code, state) {
var url = angular.isDefined(code) && angular.isDefined(state) ? './api/ssoLogin?code=' + code + '&state=' + state : './api/ssoLogin';
return $http.post(url, {});
},
isSuperAdmin: function() {
var user = self.currentUser;

Expand Down
21 changes: 21 additions & 0 deletions frontend/app/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,34 @@ pre.clearpre {
width: 50%;
}

/** Login page **/
.login-form {
width: 600px;
margin: auto;
margin-top: 40px;
background-color: #eee;
}

.or-separator {
display: flex;
align-items: center;
text-align: center;
color: #afafaf;
}
.or-separator::before,
.or-separator::after {
content: '';
flex: 1;
border-bottom: 1px solid #cfcfcf;
}
.or-separator::before {
margin-right: .25em;
}
.or-separator::after {
margin-left: .25em;
}
/***************************/

.flexwrap {
display: flex;
flex-wrap: wrap;
Expand Down
17 changes: 9 additions & 8 deletions frontend/app/views/#.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@
</div>
</div>


<div class="row">
<div class="col-xs-offset-8 col-xs-4">
<button type="submit" ng-click="login()" class="btn btn-primary btn-sm btn-block btn-flat" ng-disabled="loginForm.$invalid">#</button>
</div>
</div>
</form>
</div>
<div class="sso-login-box" ng-if="::ssoEnabled()">
<div class="row">
<div class="col-xs-offset-4 col-xs-4">
<button type="submit" class="btn btn-success btn-sm btn-block btn-flat" ng-click="ssoLogin()"># with SSO</button>

<div ng-if="::ssoEnabled()">
<div class="mt-s or-separator">OR</div>

<div class="mv-xs">
<a class="btn btn-success btn-m btn-block" href="./api/ssoLogin"># with SSO</a>
</div>
</div>
</div>
</form>
</div>


</div>

0 comments on commit c9b7cb5

Please # to comment.