diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js
index ab76accd58..439cff4fc0 100755
--- a/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js
+++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js
@@ -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;
}
diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js
index 84179d8b36..19a08cf548 100755
--- a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js
+++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js
@@ -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("/");
});
diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/menu.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/menu.html
index 1958a74d21..13d6d9980e 100755
--- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/menu.html
+++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/menu.html
@@ -3,7 +3,7 @@
diff --git a/services/src/main/java/org/keycloak/services/resources/SaasService.java b/services/src/main/java/org/keycloak/services/resources/SaasService.java
index ef936dfde1..fc43120637 100755
--- a/services/src/main/java/org/keycloak/services/resources/SaasService.java
+++ b/services/src/main/java/org/keycloak/services/resources/SaasService.java
@@ -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());
}