コード例 #1
0
  private void grantPermissionsToRealmCreator(RealmModel realm) {
    if (auth.hasRealmRole(AdminRoles.ADMIN)) {
      return;
    }

    RealmModel adminRealm = new RealmManager(session).getKeycloakAdminstrationRealm();
    ClientModel realmAdminApp = realm.getMasterAdminClient();
    for (String r : AdminRoles.ALL_REALM_ROLES) {
      RoleModel role = realmAdminApp.getRole(r);
      auth.getUser().grantRole(role);
    }
  }
コード例 #2
0
ファイル: AdminRoot.java プロジェクト: appcube/keycloak
  /**
   * General information about the server
   *
   * @param headers
   * @return
   */
  @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;
  }