Resource Server API Documentation

Hello,

I’m look for documentation on creating resources, permissions, policies via API but I’m not seeing any.

I’m seeing calls like
/auth/admin/realms/{realm}/clients/{client}/authz/resource-server/resource
in the admin console via browser dev tools, but I’m not seeing any record of those being documented anywhere.

Am I looking in the wrong place (Keycloak Docs) or are these API’s not currently documented?

Thanks,
Michael

1 Like

I had the same problem, looking to do more or less the same thing, this is what I found.

The key for what I was doing was getting a PolicyStore, AdminPermissionManagement and GroupPermissionManagement instance

// Get the realm from the session.
RealmModel realm = session.getContext().getRealm();

// Get the authorization provider and its policy store from the realm.
AuthorizationProvider authorizationProvider = session.getProvider(AuthorizationProvider.class);
PolicyStore policyStore = authorizationProvider.getStoreFactory().getPolicyStore();

// Get the AdminPermissionManagement and GroupPermissionManagement objects for managing
// permissions.
AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
GroupPermissionManagement groups =
    AdminPermissions.management(session, session.getContext().getRealm()).groups();

After that I could create a GroupPolicyRepresentation and use that with the PolicyStore to create the policies I needed.

I never found any documentation.

2 Likes