KEYCLOAK-124
This commit is contained in:
parent
9e73592381
commit
66f99d66d8
4 changed files with 12 additions and 6 deletions
|
@ -320,7 +320,7 @@ module.factory('errorInterceptor', function($q, $window, $rootScope, $location,
|
|||
if (response.status == 401) {
|
||||
console.log('session timeout?');
|
||||
Auth.loggedIn = false;
|
||||
$location.url('/');
|
||||
window.location = '/auth-server/rest/saas/login?path=' + $location.path();
|
||||
} else {
|
||||
$rootScope.httpProviderError = response.status;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ module.controller('GlobalCtrl', function($scope, $http, Auth, Current, $location
|
|||
$scope.$watch(function() {
|
||||
return $location.path();
|
||||
}, function() {
|
||||
$scope.fragment = $location.path();
|
||||
$scope.path = $location.path().substring(1).split("/");
|
||||
});
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="navbar-inner clearfix container">
|
||||
<h1><a href="#/realms/{{realm.id}}"><strong>Keycloak</strong> Central Login</a></h1>
|
||||
<ul class="nav pull-right" data-ng-hide="auth.loggedIn">
|
||||
<li><a href="/auth-server/rest/saas/login">Login</a></li>
|
||||
<li><a href="/auth-server/rest/saas/login?path={{fragment}}">Login</a></li>
|
||||
<li><a href="/auth-server/rest/saas/registrations">Register</a></li>
|
||||
</ul>
|
||||
<ul class="nav pull-right" data-ng-show="auth.loggedIn">
|
||||
|
|
|
@ -263,7 +263,7 @@ public class SaasService {
|
|||
@Path("login")
|
||||
@GET
|
||||
@NoCache
|
||||
public Response loginPage() {
|
||||
public Response loginPage(@QueryParam("path") String path) {
|
||||
logger.debug("loginPage ********************** <---");
|
||||
RealmManager realmManager = new RealmManager(session);
|
||||
RealmModel realm = getAdminstrationRealm(realmManager);
|
||||
|
@ -277,7 +277,7 @@ public class SaasService {
|
|||
URI redirectUri = uriInfo.getBaseUriBuilder().path(SaasService.class).path(SaasService.class, "loginRedirect").build();
|
||||
logger.debug("redirectUri: {0}", redirectUri.toString());
|
||||
oauth.setStateCookiePath(redirectUri.getPath());
|
||||
return oauth.redirect(uriInfo, redirectUri.toString());
|
||||
return oauth.redirect(uriInfo, redirectUri.toString(), path);
|
||||
}
|
||||
|
||||
@Path("login-redirect")
|
||||
|
@ -316,7 +316,7 @@ public class SaasService {
|
|||
logger.debug("state not specified");
|
||||
throw new BadRequestException();
|
||||
}
|
||||
new JaxrsOAuthClient().checkStateCookie(uriInfo, headers);
|
||||
String path = new JaxrsOAuthClient().checkStateCookie(uriInfo, headers);
|
||||
|
||||
JWSInput input = new JWSInput(code, providers);
|
||||
boolean verifiedCode = false;
|
||||
|
@ -358,7 +358,12 @@ public class SaasService {
|
|||
}
|
||||
logger.debug("loginRedirect SUCCESS");
|
||||
NewCookie cookie = authManager.createSaasIdentityCookie(realm, accessCode.getUser(), uriInfo);
|
||||
return Response.status(302).cookie(cookie).location(contextRoot(uriInfo).path(adminPath).build()).build();
|
||||
|
||||
URI redirectUri = contextRoot(uriInfo).path(adminPath).build();
|
||||
if (path != null) {
|
||||
redirectUri = redirectUri.resolve("#" + path);
|
||||
}
|
||||
return Response.status(302).cookie(cookie).location(redirectUri).build();
|
||||
} finally {
|
||||
authManager.expireCookie(AbstractOAuthClient.OAUTH_TOKEN_REQUEST_STATE, uriInfo.getAbsolutePath().getPath());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue