diff --git a/examples/cors/angular-product-app/src/main/webapp/index.html b/examples/cors/angular-product-app/src/main/webapp/index.html
index 2e05d7f..54bb9d6 100755
--- a/examples/cors/angular-product-app/src/main/webapp/index.html
+++ b/examples/cors/angular-product-app/src/main/webapp/index.html
@@ -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>
diff --git a/examples/cors/angular-product-app/src/main/webapp/js/app.js b/examples/cors/angular-product-app/src/main/webapp/js/app.js
index f2056cc..402ab84 100755
--- a/examples/cors/angular-product-app/src/main/webapp/js/app.js
+++ b/examples/cors/angular-product-app/src/main/webapp/js/app.js
@@ -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;
});
diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java
index 0959e70..40fccf9 100755
--- a/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java
+++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminRoot.java
@@ -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);
+ }
+ }
+
}