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>
|
||||
</table>
|
||||
</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>
|
||||
</body>
|
||||
</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;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
{
|
||||
"realm": "cors",
|
||||
"enabled": true,
|
||||
"accessTokenLifespan": 3000,
|
||||
"accessCodeLifespan": 10,
|
||||
"accessCodeLifespanUserAction": 6000,
|
||||
"accessTokenLifespan": 60,
|
||||
"accessCodeLifespan": 60,
|
||||
"accessCodeLifespanUserAction": 300,
|
||||
"ssoSessionIdleTimeout": 600,
|
||||
"ssoSessionMaxLifespan": 36000,
|
||||
"sslRequired": "external",
|
||||
"registrationAllowed": false,
|
||||
"social": false,
|
||||
|
|
|
@ -179,11 +179,7 @@ public class AdminRoot {
|
|||
*/
|
||||
@Path("realms")
|
||||
public RealmsAdminResource getRealmsAdmin(@Context final HttpHeaders headers) {
|
||||
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);
|
||||
}
|
||||
handlePreflightRequest();
|
||||
|
||||
AdminAuth auth = authenticateRealmAdminRequest(headers);
|
||||
if (auth != null) {
|
||||
|
@ -206,10 +202,26 @@ public class AdminRoot {
|
|||
*/
|
||||
@Path("serverinfo")
|
||||
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();
|
||||
ResteasyProviderFactory.getInstance().injectProperties(adminResource);
|
||||
//resourceContext.initResource(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