Merge pull request #683 from mposolda/master
KEYCLOAK-670 allow ServerInfo to be available with cors
This commit is contained in:
commit
88a39dbaf7
4 changed files with 46 additions and 8 deletions
|
@ -52,6 +52,22 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2><span>Social providers</span></h2>
|
||||||
|
<button type="submit" data-ng-click="loadServerInfo()">load available social providers</button>
|
||||||
|
<table class="table" data-ng-show="serverInfo.socialProviders.length > 0">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Available social providers</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr data-ng-repeat="sp in serverInfo.socialProviders">
|
||||||
|
<td>{{sp}}</a></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -58,6 +58,14 @@ module.controller('GlobalCtrl', function($scope, $http) {
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.loadServerInfo = function() {
|
||||||
|
$http.get("http://localhost-auth:8080/auth/admin/serverinfo").success(function(data) {
|
||||||
|
$scope.serverInfo = angular.fromJson(data);
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
$scope.logout = logout;
|
$scope.logout = logout;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
{
|
{
|
||||||
"realm": "cors",
|
"realm": "cors",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"accessTokenLifespan": 3000,
|
"accessTokenLifespan": 60,
|
||||||
"accessCodeLifespan": 10,
|
"accessCodeLifespan": 60,
|
||||||
"accessCodeLifespanUserAction": 6000,
|
"accessCodeLifespanUserAction": 300,
|
||||||
|
"ssoSessionIdleTimeout": 600,
|
||||||
|
"ssoSessionMaxLifespan": 36000,
|
||||||
"sslRequired": "external",
|
"sslRequired": "external",
|
||||||
"registrationAllowed": false,
|
"registrationAllowed": false,
|
||||||
"social": false,
|
"social": false,
|
||||||
|
|
|
@ -179,11 +179,7 @@ public class AdminRoot {
|
||||||
*/
|
*/
|
||||||
@Path("realms")
|
@Path("realms")
|
||||||
public RealmsAdminResource getRealmsAdmin(@Context final HttpHeaders headers) {
|
public RealmsAdminResource getRealmsAdmin(@Context final HttpHeaders headers) {
|
||||||
if (request.getHttpMethod().equalsIgnoreCase("OPTIONS")) {
|
handlePreflightRequest();
|
||||||
logger.debug("Cors admin pre-flight");
|
|
||||||
Response response = Cors.add(request, Response.ok()).preflight().allowedMethods("GET", "PUT", "POST", "DELETE").auth().build();
|
|
||||||
throw new NoLogWebApplicationException(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
AdminAuth auth = authenticateRealmAdminRequest(headers);
|
AdminAuth auth = authenticateRealmAdminRequest(headers);
|
||||||
if (auth != null) {
|
if (auth != null) {
|
||||||
|
@ -206,10 +202,26 @@ public class AdminRoot {
|
||||||
*/
|
*/
|
||||||
@Path("serverinfo")
|
@Path("serverinfo")
|
||||||
public ServerInfoAdminResource getServerInfo(@Context final HttpHeaders headers) {
|
public ServerInfoAdminResource getServerInfo(@Context final HttpHeaders headers) {
|
||||||
|
handlePreflightRequest();
|
||||||
|
|
||||||
|
AdminAuth auth = authenticateRealmAdminRequest(headers);
|
||||||
|
if (auth != null) {
|
||||||
|
logger.debug("authenticated admin access for: " + auth.getUser().getUsername());
|
||||||
|
}
|
||||||
|
Cors.add(request).allowedOrigins(auth.getToken()).allowedMethods("GET", "PUT", "POST", "DELETE").auth().build(response);
|
||||||
|
|
||||||
ServerInfoAdminResource adminResource = new ServerInfoAdminResource();
|
ServerInfoAdminResource adminResource = new ServerInfoAdminResource();
|
||||||
ResteasyProviderFactory.getInstance().injectProperties(adminResource);
|
ResteasyProviderFactory.getInstance().injectProperties(adminResource);
|
||||||
//resourceContext.initResource(adminResource);
|
//resourceContext.initResource(adminResource);
|
||||||
return adminResource;
|
return adminResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void handlePreflightRequest() {
|
||||||
|
if (request.getHttpMethod().equalsIgnoreCase("OPTIONS")) {
|
||||||
|
logger.debug("Cors admin pre-flight");
|
||||||
|
Response response = Cors.add(request, Response.ok()).preflight().allowedMethods("GET", "PUT", "POST", "DELETE").auth().build();
|
||||||
|
throw new NoLogWebApplicationException(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue