Documentation
¶
Overview ¶
Package keycloak provides a client for interacting with the Keycloak Admin REST API. This is a custom implementation that works with raw JSON to support all Keycloak versions without being limited by struct definitions.
Index ¶
- func WithRetry[T any](ctx context.Context, cfg RetryConfig, operation string, fn func() (T, error)) (T, error)
- func WithRetryVoid(ctx context.Context, cfg RetryConfig, operation string, fn func() error) error
- type Client
- func (c *Client) AddClientRolesToGroup(ctx context.Context, realmName, clientID, groupID string, ...) error
- func (c *Client) AddClientRolesToUser(ctx context.Context, realmName, clientID, userID string, ...) error
- func (c *Client) AddRealmRolesToGroup(ctx context.Context, realmName, groupID string, roles []RoleRepresentation) error
- func (c *Client) AddRealmRolesToUser(ctx context.Context, realmName, userID string, roles []RoleRepresentation) error
- func (c *Client) Create(ctx context.Context, path string, body interface{}) (string, error)
- func (c *Client) CreateChildGroup(ctx context.Context, realmName, parentID string, groupDef json.RawMessage) (string, error)
- func (c *Client) CreateClient(ctx context.Context, realmName string, clientDef json.RawMessage) (string, error)
- func (c *Client) CreateClientProtocolMapper(ctx context.Context, realmName, clientID string, mapperDef json.RawMessage) (string, error)
- func (c *Client) CreateClientRole(ctx context.Context, realmName, clientID string, roleDef json.RawMessage) (string, error)
- func (c *Client) CreateClientScope(ctx context.Context, realmName string, scopeDef json.RawMessage) (string, error)
- func (c *Client) CreateClientScopeProtocolMapper(ctx context.Context, realmName, scopeID string, mapperDef json.RawMessage) (string, error)
- func (c *Client) CreateComponent(ctx context.Context, realmName string, componentDef json.RawMessage) (string, error)
- func (c *Client) CreateGroup(ctx context.Context, realmName string, groupDef json.RawMessage) (string, error)
- func (c *Client) CreateIdentityProvider(ctx context.Context, realmName string, idpDef json.RawMessage) (string, error)
- func (c *Client) CreateOrganization(ctx context.Context, realmName string, org OrganizationRepresentation) (string, error)
- func (c *Client) CreateRealm(ctx context.Context, realm json.RawMessage) error
- func (c *Client) CreateRealmFromDefinition(ctx context.Context, definition json.RawMessage) error
- func (c *Client) CreateRealmRole(ctx context.Context, realmName string, roleDef json.RawMessage) (string, error)
- func (c *Client) CreateUser(ctx context.Context, realmName string, userDef json.RawMessage) (string, error)
- func (c *Client) Delete(ctx context.Context, path string) error
- func (c *Client) DeleteClient(ctx context.Context, realmName, clientID string) error
- func (c *Client) DeleteClientProtocolMapper(ctx context.Context, realmName, clientID, mapperID string) error
- func (c *Client) DeleteClientRole(ctx context.Context, realmName, clientID, roleName string) error
- func (c *Client) DeleteClientRolesFromGroup(ctx context.Context, realmName, clientID, groupID string, ...) error
- func (c *Client) DeleteClientRolesFromUser(ctx context.Context, realmName, clientID, userID string, ...) error
- func (c *Client) DeleteClientScope(ctx context.Context, realmName, scopeID string) error
- func (c *Client) DeleteClientScopeProtocolMapper(ctx context.Context, realmName, scopeID, mapperID string) error
- func (c *Client) DeleteComponent(ctx context.Context, realmName, componentID string) error
- func (c *Client) DeleteGroup(ctx context.Context, realmName, groupID string) error
- func (c *Client) DeleteIdentityProvider(ctx context.Context, realmName, alias string) error
- func (c *Client) DeleteOrganization(ctx context.Context, realmName, orgID string) error
- func (c *Client) DeleteRealm(ctx context.Context, realmName string) error
- func (c *Client) DeleteRealmRole(ctx context.Context, realmName, roleName string) error
- func (c *Client) DeleteRealmRolesFromGroup(ctx context.Context, realmName, groupID string, roles []RoleRepresentation) error
- func (c *Client) DeleteRealmRolesFromUser(ctx context.Context, realmName, userID string, roles []RoleRepresentation) error
- func (c *Client) DeleteUser(ctx context.Context, realmName, userID string) error
- func (c *Client) Get(ctx context.Context, path string, result interface{}) error
- func (c *Client) GetClient(ctx context.Context, realmName, clientID string) (*ClientRepresentation, error)
- func (c *Client) GetClientByClientID(ctx context.Context, realmName, clientID string) (*ClientRepresentation, error)
- func (c *Client) GetClientProtocolMapper(ctx context.Context, realmName, clientID, mapperID string) (*ProtocolMapperRepresentation, error)
- func (c *Client) GetClientProtocolMapperByName(ctx context.Context, realmName, clientID, name string) (*ProtocolMapperRepresentation, error)
- func (c *Client) GetClientProtocolMappers(ctx context.Context, realmName, clientID string) ([]ProtocolMapperRepresentation, error)
- func (c *Client) GetClientProtocolMappersRaw(ctx context.Context, realmName, clientUUID string) ([]json.RawMessage, error)
- func (c *Client) GetClientRaw(ctx context.Context, realmName, clientUUID string) (json.RawMessage, error)
- func (c *Client) GetClientRole(ctx context.Context, realmName, clientID, roleName string) (*RoleRepresentation, error)
- func (c *Client) GetClientRoleRaw(ctx context.Context, realmName, clientUUID, roleName string) (json.RawMessage, error)
- func (c *Client) GetClientRoles(ctx context.Context, realmName, clientUUID string) ([]RoleRepresentation, error)
- func (c *Client) GetClientRolesRaw(ctx context.Context, realmName, clientUUID string) ([]json.RawMessage, error)
- func (c *Client) GetClientScope(ctx context.Context, realmName, scopeID string) (*ClientScopeRepresentation, error)
- func (c *Client) GetClientScopeByName(ctx context.Context, realmName, name string) (*ClientScopeRepresentation, error)
- func (c *Client) GetClientScopeProtocolMapperByName(ctx context.Context, realmName, scopeID, name string) (*ProtocolMapperRepresentation, error)
- func (c *Client) GetClientScopeProtocolMappers(ctx context.Context, realmName, scopeID string) ([]ProtocolMapperRepresentation, error)
- func (c *Client) GetClientScopeProtocolMappersRaw(ctx context.Context, realmName, scopeID string) ([]json.RawMessage, error)
- func (c *Client) GetClientScopeRaw(ctx context.Context, realmName, scopeID string) (json.RawMessage, error)
- func (c *Client) GetClientScopes(ctx context.Context, realmName string) ([]ClientScopeRepresentation, error)
- func (c *Client) GetClientScopesRaw(ctx context.Context, realmName string) ([]json.RawMessage, error)
- func (c *Client) GetClientSecret(ctx context.Context, realmName, clientID string) (string, error)
- func (c *Client) GetClientServiceAccount(ctx context.Context, realmName, clientID string) (*UserRepresentation, error)
- func (c *Client) GetClients(ctx context.Context, realmName string, params map[string]string) ([]ClientRepresentation, error)
- func (c *Client) GetClientsRaw(ctx context.Context, realmName string) ([]json.RawMessage, error)
- func (c *Client) GetComponent(ctx context.Context, realmName, componentID string) (*ComponentRepresentation, error)
- func (c *Client) GetComponentByName(ctx context.Context, realmName, name, providerType string) (*ComponentRepresentation, error)
- func (c *Client) GetComponentRaw(ctx context.Context, realmName, componentID string) (json.RawMessage, error)
- func (c *Client) GetComponents(ctx context.Context, realmName string, params map[string]string) ([]ComponentRepresentation, error)
- func (c *Client) GetComponentsRaw(ctx context.Context, realmName string, params map[string]string) ([]json.RawMessage, error)
- func (c *Client) GetGroup(ctx context.Context, realmName, groupID string) (*GroupRepresentation, error)
- func (c *Client) GetGroupByName(ctx context.Context, realmName, name string) (*GroupRepresentation, error)
- func (c *Client) GetGroupClientRoleMappings(ctx context.Context, realmName, groupID, clientUUID string) ([]RoleRepresentation, error)
- func (c *Client) GetGroupClientRoleMappingsRaw(ctx context.Context, realmName, groupID, clientUUID string) ([]json.RawMessage, error)
- func (c *Client) GetGroupRaw(ctx context.Context, realmName, groupID string) (json.RawMessage, error)
- func (c *Client) GetGroupRealmRoleMappings(ctx context.Context, realmName, groupID string) ([]RoleRepresentation, error)
- func (c *Client) GetGroupRealmRoleMappingsRaw(ctx context.Context, realmName, groupID string) ([]json.RawMessage, error)
- func (c *Client) GetGroups(ctx context.Context, realmName string, params map[string]string) ([]GroupRepresentation, error)
- func (c *Client) GetGroupsRaw(ctx context.Context, realmName string) ([]json.RawMessage, error)
- func (c *Client) GetIdentityProvider(ctx context.Context, realmName, alias string) (*IdentityProviderRepresentation, error)
- func (c *Client) GetIdentityProviderRaw(ctx context.Context, realmName, alias string) (json.RawMessage, error)
- func (c *Client) GetIdentityProviders(ctx context.Context, realmName string) ([]IdentityProviderRepresentation, error)
- func (c *Client) GetIdentityProvidersRaw(ctx context.Context, realmName string) ([]json.RawMessage, error)
- func (c *Client) GetOrganization(ctx context.Context, realmName, orgID string) (*OrganizationRepresentation, error)
- func (c *Client) GetOrganizationRaw(ctx context.Context, realmName, orgID string) (json.RawMessage, error)
- func (c *Client) GetOrganizations(ctx context.Context, realmName string) ([]OrganizationRepresentation, error)
- func (c *Client) GetOrganizationsRaw(ctx context.Context, realmName string) ([]json.RawMessage, error)
- func (c *Client) GetRaw(ctx context.Context, path string) (json.RawMessage, error)
- func (c *Client) GetRealm(ctx context.Context, realmName string) (*RealmRepresentation, error)
- func (c *Client) GetRealmRaw(ctx context.Context, realmName string) (json.RawMessage, error)
- func (c *Client) GetRealmRole(ctx context.Context, realmName, roleName string) (*RoleRepresentation, error)
- func (c *Client) GetRealmRoleRaw(ctx context.Context, realmName, roleName string) (json.RawMessage, error)
- func (c *Client) GetRealmRoles(ctx context.Context, realmName string) ([]RoleRepresentation, error)
- func (c *Client) GetRealmRolesRaw(ctx context.Context, realmName string) ([]json.RawMessage, error)
- func (c *Client) GetServerInfo(ctx context.Context) (*ServerInfo, error)
- func (c *Client) GetUser(ctx context.Context, realmName, userID string) (*UserRepresentation, error)
- func (c *Client) GetUserByUsername(ctx context.Context, realmName, username string) (*UserRepresentation, error)
- func (c *Client) GetUserClientRoleMappings(ctx context.Context, realmName, userID, clientUUID string) ([]RoleRepresentation, error)
- func (c *Client) GetUserClientRoleMappingsRaw(ctx context.Context, realmName, userID, clientUUID string) ([]json.RawMessage, error)
- func (c *Client) GetUserRaw(ctx context.Context, realmName, userID string) (json.RawMessage, error)
- func (c *Client) GetUserRealmRoleMappings(ctx context.Context, realmName, userID string) ([]RoleRepresentation, error)
- func (c *Client) GetUserRealmRoleMappingsRaw(ctx context.Context, realmName, userID string) ([]json.RawMessage, error)
- func (c *Client) GetUsers(ctx context.Context, realmName string, params map[string]string) ([]UserRepresentation, error)
- func (c *Client) GetUsersRaw(ctx context.Context, realmName string, params map[string]string) ([]json.RawMessage, error)
- func (c *Client) List(ctx context.Context, path string, params map[string]string, result interface{}) error
- func (c *Client) ListRaw(ctx context.Context, path string, params map[string]string) ([]json.RawMessage, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) Post(ctx context.Context, path string, body interface{}, result interface{}) error
- func (c *Client) RegenerateClientSecret(ctx context.Context, realmName, clientID string) (string, error)
- func (c *Client) SetPassword(ctx context.Context, realmName, userID, password string, temporary bool) error
- func (c *Client) Update(ctx context.Context, path string, body interface{}) error
- func (c *Client) UpdateClient(ctx context.Context, realmName, clientID string, clientDef json.RawMessage) error
- func (c *Client) UpdateClientProtocolMapper(ctx context.Context, realmName, clientID, mapperID string, ...) error
- func (c *Client) UpdateClientRole(ctx context.Context, realmName, clientID, roleName string, ...) error
- func (c *Client) UpdateClientScope(ctx context.Context, realmName, scopeID string, scopeDef json.RawMessage) error
- func (c *Client) UpdateClientScopeProtocolMapper(ctx context.Context, realmName, scopeID, mapperID string, ...) error
- func (c *Client) UpdateComponent(ctx context.Context, realmName, componentID string, ...) error
- func (c *Client) UpdateGroup(ctx context.Context, realmName, groupID string, groupDef json.RawMessage) error
- func (c *Client) UpdateIdentityProvider(ctx context.Context, realmName, alias string, idpDef json.RawMessage) error
- func (c *Client) UpdateOrganization(ctx context.Context, realmName string, org OrganizationRepresentation) error
- func (c *Client) UpdateRealm(ctx context.Context, realmName string, definition json.RawMessage) error
- func (c *Client) UpdateRealmRole(ctx context.Context, realmName, roleName string, roleDef json.RawMessage) error
- func (c *Client) UpdateUser(ctx context.Context, realmName, userID string, userDef json.RawMessage) error
- type ClientManager
- type ClientManagerConfig
- type ClientRepresentation
- type ClientScopeRepresentation
- type ComponentRepresentation
- type Config
- type GroupRepresentation
- type IdentityProviderRepresentation
- type OrganizationDomain
- type OrganizationRepresentation
- type ProtocolMapperRepresentation
- type RealmRepresentation
- type RetryConfig
- type RoleRepresentation
- type ServerInfo
- type TokenResponse
- type UserRepresentation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithRetry ¶
func WithRetry[T any](ctx context.Context, cfg RetryConfig, operation string, fn func() (T, error)) (T, error)
WithRetry executes a function with exponential backoff retry
func WithRetryVoid ¶
WithRetryVoid executes a void function with exponential backoff retry
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides methods to interact with the Keycloak Admin REST API
func (*Client) AddClientRolesToGroup ¶
func (c *Client) AddClientRolesToGroup(ctx context.Context, realmName, clientID, groupID string, roles []RoleRepresentation) error
AddClientRolesToGroup adds client roles to a group
func (*Client) AddClientRolesToUser ¶
func (c *Client) AddClientRolesToUser(ctx context.Context, realmName, clientID, userID string, roles []RoleRepresentation) error
AddClientRolesToUser adds client roles to a user
func (*Client) AddRealmRolesToGroup ¶
func (c *Client) AddRealmRolesToGroup(ctx context.Context, realmName, groupID string, roles []RoleRepresentation) error
AddRealmRolesToGroup adds realm roles to a group
func (*Client) AddRealmRolesToUser ¶
func (c *Client) AddRealmRolesToUser(ctx context.Context, realmName, userID string, roles []RoleRepresentation) error
AddRealmRolesToUser adds realm roles to a user
func (*Client) CreateChildGroup ¶
func (c *Client) CreateChildGroup(ctx context.Context, realmName, parentID string, groupDef json.RawMessage) (string, error)
CreateChildGroup creates a child group
func (*Client) CreateClient ¶
func (c *Client) CreateClient(ctx context.Context, realmName string, clientDef json.RawMessage) (string, error)
CreateClient creates a new client
func (*Client) CreateClientProtocolMapper ¶
func (c *Client) CreateClientProtocolMapper(ctx context.Context, realmName, clientID string, mapperDef json.RawMessage) (string, error)
CreateClientProtocolMapper creates a protocol mapper for a client
func (*Client) CreateClientRole ¶
func (c *Client) CreateClientRole(ctx context.Context, realmName, clientID string, roleDef json.RawMessage) (string, error)
CreateClientRole creates a client role
func (*Client) CreateClientScope ¶
func (c *Client) CreateClientScope(ctx context.Context, realmName string, scopeDef json.RawMessage) (string, error)
CreateClientScope creates a new client scope
func (*Client) CreateClientScopeProtocolMapper ¶
func (c *Client) CreateClientScopeProtocolMapper(ctx context.Context, realmName, scopeID string, mapperDef json.RawMessage) (string, error)
CreateClientScopeProtocolMapper creates a protocol mapper for a client scope
func (*Client) CreateComponent ¶
func (c *Client) CreateComponent(ctx context.Context, realmName string, componentDef json.RawMessage) (string, error)
CreateComponent creates a component
func (*Client) CreateGroup ¶
func (c *Client) CreateGroup(ctx context.Context, realmName string, groupDef json.RawMessage) (string, error)
CreateGroup creates a new group
func (*Client) CreateIdentityProvider ¶
func (c *Client) CreateIdentityProvider(ctx context.Context, realmName string, idpDef json.RawMessage) (string, error)
CreateIdentityProvider creates a new identity provider
func (*Client) CreateOrganization ¶
func (c *Client) CreateOrganization(ctx context.Context, realmName string, org OrganizationRepresentation) (string, error)
CreateOrganization creates a new organization
func (*Client) CreateRealm ¶
CreateRealm creates a new realm
func (*Client) CreateRealmFromDefinition ¶
CreateRealmFromDefinition creates a realm from raw JSON definition
func (*Client) CreateRealmRole ¶
func (c *Client) CreateRealmRole(ctx context.Context, realmName string, roleDef json.RawMessage) (string, error)
CreateRealmRole creates a new realm role
func (*Client) CreateUser ¶
func (c *Client) CreateUser(ctx context.Context, realmName string, userDef json.RawMessage) (string, error)
CreateUser creates a new user
func (*Client) DeleteClient ¶
DeleteClient deletes a client
func (*Client) DeleteClientProtocolMapper ¶
func (c *Client) DeleteClientProtocolMapper(ctx context.Context, realmName, clientID, mapperID string) error
DeleteClientProtocolMapper deletes a protocol mapper
func (*Client) DeleteClientRole ¶
DeleteClientRole deletes a client role
func (*Client) DeleteClientRolesFromGroup ¶
func (c *Client) DeleteClientRolesFromGroup(ctx context.Context, realmName, clientID, groupID string, roles []RoleRepresentation) error
DeleteClientRolesFromGroup removes client roles from a group
func (*Client) DeleteClientRolesFromUser ¶
func (c *Client) DeleteClientRolesFromUser(ctx context.Context, realmName, clientID, userID string, roles []RoleRepresentation) error
DeleteClientRolesFromUser removes client roles from a user
func (*Client) DeleteClientScope ¶
DeleteClientScope deletes a client scope
func (*Client) DeleteClientScopeProtocolMapper ¶
func (c *Client) DeleteClientScopeProtocolMapper(ctx context.Context, realmName, scopeID, mapperID string) error
DeleteClientScopeProtocolMapper deletes a protocol mapper from a client scope
func (*Client) DeleteComponent ¶
DeleteComponent deletes a component
func (*Client) DeleteGroup ¶
DeleteGroup deletes a group
func (*Client) DeleteIdentityProvider ¶
DeleteIdentityProvider deletes an identity provider
func (*Client) DeleteOrganization ¶
DeleteOrganization deletes an organization
func (*Client) DeleteRealm ¶
DeleteRealm deletes a realm
func (*Client) DeleteRealmRole ¶
DeleteRealmRole deletes a realm role
func (*Client) DeleteRealmRolesFromGroup ¶
func (c *Client) DeleteRealmRolesFromGroup(ctx context.Context, realmName, groupID string, roles []RoleRepresentation) error
DeleteRealmRolesFromGroup removes realm roles from a group
func (*Client) DeleteRealmRolesFromUser ¶
func (c *Client) DeleteRealmRolesFromUser(ctx context.Context, realmName, userID string, roles []RoleRepresentation) error
DeleteRealmRolesFromUser removes realm roles from a user
func (*Client) DeleteUser ¶
DeleteUser deletes a user
func (*Client) GetClient ¶
func (c *Client) GetClient(ctx context.Context, realmName, clientID string) (*ClientRepresentation, error)
GetClient gets a client by internal ID
func (*Client) GetClientByClientID ¶
func (c *Client) GetClientByClientID(ctx context.Context, realmName, clientID string) (*ClientRepresentation, error)
GetClientByClientID finds a client by its clientId field
func (*Client) GetClientProtocolMapper ¶
func (c *Client) GetClientProtocolMapper(ctx context.Context, realmName, clientID, mapperID string) (*ProtocolMapperRepresentation, error)
GetClientProtocolMapper gets a protocol mapper by ID
func (*Client) GetClientProtocolMapperByName ¶
func (c *Client) GetClientProtocolMapperByName(ctx context.Context, realmName, clientID, name string) (*ProtocolMapperRepresentation, error)
GetClientProtocolMapperByName finds a protocol mapper by name
func (*Client) GetClientProtocolMappers ¶
func (c *Client) GetClientProtocolMappers(ctx context.Context, realmName, clientID string) ([]ProtocolMapperRepresentation, error)
GetClientProtocolMappers gets all protocol mappers for a client
func (*Client) GetClientProtocolMappersRaw ¶ added in v0.3.0
func (c *Client) GetClientProtocolMappersRaw(ctx context.Context, realmName, clientUUID string) ([]json.RawMessage, error)
GetClientProtocolMappersRaw gets all protocol mappers for a client as raw JSON
func (*Client) GetClientRaw ¶ added in v0.3.0
func (c *Client) GetClientRaw(ctx context.Context, realmName, clientUUID string) (json.RawMessage, error)
GetClientRaw gets a client by internal ID as raw JSON
func (*Client) GetClientRole ¶
func (c *Client) GetClientRole(ctx context.Context, realmName, clientID, roleName string) (*RoleRepresentation, error)
GetClientRole gets a client role by name
func (*Client) GetClientRoleRaw ¶ added in v0.3.0
func (c *Client) GetClientRoleRaw(ctx context.Context, realmName, clientUUID, roleName string) (json.RawMessage, error)
GetClientRoleRaw gets a client role by name as raw JSON
func (*Client) GetClientRoles ¶ added in v0.3.0
func (c *Client) GetClientRoles(ctx context.Context, realmName, clientUUID string) ([]RoleRepresentation, error)
GetClientRoles gets all roles for a client
func (*Client) GetClientRolesRaw ¶ added in v0.3.0
func (c *Client) GetClientRolesRaw(ctx context.Context, realmName, clientUUID string) ([]json.RawMessage, error)
GetClientRolesRaw gets all roles for a client as raw JSON
func (*Client) GetClientScope ¶
func (c *Client) GetClientScope(ctx context.Context, realmName, scopeID string) (*ClientScopeRepresentation, error)
GetClientScope gets a client scope by ID
func (*Client) GetClientScopeByName ¶
func (c *Client) GetClientScopeByName(ctx context.Context, realmName, name string) (*ClientScopeRepresentation, error)
GetClientScopeByName finds a client scope by name
func (*Client) GetClientScopeProtocolMapperByName ¶
func (c *Client) GetClientScopeProtocolMapperByName(ctx context.Context, realmName, scopeID, name string) (*ProtocolMapperRepresentation, error)
GetClientScopeProtocolMapperByName finds a protocol mapper by name in a client scope
func (*Client) GetClientScopeProtocolMappers ¶
func (c *Client) GetClientScopeProtocolMappers(ctx context.Context, realmName, scopeID string) ([]ProtocolMapperRepresentation, error)
GetClientScopeProtocolMappers gets all protocol mappers for a client scope
func (*Client) GetClientScopeProtocolMappersRaw ¶ added in v0.3.0
func (c *Client) GetClientScopeProtocolMappersRaw(ctx context.Context, realmName, scopeID string) ([]json.RawMessage, error)
GetClientScopeProtocolMappersRaw gets all protocol mappers for a client scope as raw JSON
func (*Client) GetClientScopeRaw ¶ added in v0.3.0
func (c *Client) GetClientScopeRaw(ctx context.Context, realmName, scopeID string) (json.RawMessage, error)
GetClientScopeRaw gets a client scope by ID as raw JSON
func (*Client) GetClientScopes ¶
func (c *Client) GetClientScopes(ctx context.Context, realmName string) ([]ClientScopeRepresentation, error)
GetClientScopes gets all client scopes in a realm
func (*Client) GetClientScopesRaw ¶ added in v0.3.0
func (c *Client) GetClientScopesRaw(ctx context.Context, realmName string) ([]json.RawMessage, error)
GetClientScopesRaw gets all client scopes in a realm as raw JSON
func (*Client) GetClientSecret ¶
GetClientSecret gets the client secret
func (*Client) GetClientServiceAccount ¶
func (c *Client) GetClientServiceAccount(ctx context.Context, realmName, clientID string) (*UserRepresentation, error)
GetClientServiceAccount gets the service account user for a client
func (*Client) GetClients ¶
func (c *Client) GetClients(ctx context.Context, realmName string, params map[string]string) ([]ClientRepresentation, error)
GetClients gets all clients in a realm with optional filtering
func (*Client) GetClientsRaw ¶ added in v0.3.0
GetClientsRaw gets all clients in a realm as raw JSON
func (*Client) GetComponent ¶
func (c *Client) GetComponent(ctx context.Context, realmName, componentID string) (*ComponentRepresentation, error)
GetComponent gets a component by ID
func (*Client) GetComponentByName ¶
func (c *Client) GetComponentByName(ctx context.Context, realmName, name, providerType string) (*ComponentRepresentation, error)
GetComponentByName finds a component by name and type
func (*Client) GetComponentRaw ¶ added in v0.3.0
func (c *Client) GetComponentRaw(ctx context.Context, realmName, componentID string) (json.RawMessage, error)
GetComponentRaw gets a component by ID as raw JSON
func (*Client) GetComponents ¶
func (c *Client) GetComponents(ctx context.Context, realmName string, params map[string]string) ([]ComponentRepresentation, error)
GetComponents gets components with optional filtering
func (*Client) GetComponentsRaw ¶ added in v0.3.0
func (c *Client) GetComponentsRaw(ctx context.Context, realmName string, params map[string]string) ([]json.RawMessage, error)
GetComponentsRaw gets all components in a realm as raw JSON
func (*Client) GetGroup ¶
func (c *Client) GetGroup(ctx context.Context, realmName, groupID string) (*GroupRepresentation, error)
GetGroup gets a group by ID
func (*Client) GetGroupByName ¶
func (c *Client) GetGroupByName(ctx context.Context, realmName, name string) (*GroupRepresentation, error)
GetGroupByName finds a group by name
func (*Client) GetGroupClientRoleMappings ¶ added in v0.3.0
func (c *Client) GetGroupClientRoleMappings(ctx context.Context, realmName, groupID, clientUUID string) ([]RoleRepresentation, error)
GetGroupClientRoleMappings gets client role mappings for a group
func (*Client) GetGroupClientRoleMappingsRaw ¶ added in v0.3.0
func (c *Client) GetGroupClientRoleMappingsRaw(ctx context.Context, realmName, groupID, clientUUID string) ([]json.RawMessage, error)
GetGroupClientRoleMappingsRaw gets client role mappings for a group as raw JSON
func (*Client) GetGroupRaw ¶ added in v0.3.0
func (c *Client) GetGroupRaw(ctx context.Context, realmName, groupID string) (json.RawMessage, error)
GetGroupRaw gets a group by ID as raw JSON
func (*Client) GetGroupRealmRoleMappings ¶ added in v0.3.0
func (c *Client) GetGroupRealmRoleMappings(ctx context.Context, realmName, groupID string) ([]RoleRepresentation, error)
GetGroupRealmRoleMappings gets realm role mappings for a group
func (*Client) GetGroupRealmRoleMappingsRaw ¶ added in v0.3.0
func (c *Client) GetGroupRealmRoleMappingsRaw(ctx context.Context, realmName, groupID string) ([]json.RawMessage, error)
GetGroupRealmRoleMappingsRaw gets realm role mappings for a group as raw JSON
func (*Client) GetGroups ¶
func (c *Client) GetGroups(ctx context.Context, realmName string, params map[string]string) ([]GroupRepresentation, error)
GetGroups gets all groups in a realm
func (*Client) GetGroupsRaw ¶ added in v0.3.0
GetGroupsRaw gets all groups in a realm as raw JSON
func (*Client) GetIdentityProvider ¶
func (c *Client) GetIdentityProvider(ctx context.Context, realmName, alias string) (*IdentityProviderRepresentation, error)
GetIdentityProvider gets an identity provider by alias
func (*Client) GetIdentityProviderRaw ¶ added in v0.3.0
func (c *Client) GetIdentityProviderRaw(ctx context.Context, realmName, alias string) (json.RawMessage, error)
GetIdentityProviderRaw gets an identity provider by alias as raw JSON
func (*Client) GetIdentityProviders ¶ added in v0.3.0
func (c *Client) GetIdentityProviders(ctx context.Context, realmName string) ([]IdentityProviderRepresentation, error)
GetIdentityProviders gets all identity providers in a realm
func (*Client) GetIdentityProvidersRaw ¶ added in v0.3.0
func (c *Client) GetIdentityProvidersRaw(ctx context.Context, realmName string) ([]json.RawMessage, error)
GetIdentityProvidersRaw gets all identity providers in a realm as raw JSON
func (*Client) GetOrganization ¶
func (c *Client) GetOrganization(ctx context.Context, realmName, orgID string) (*OrganizationRepresentation, error)
GetOrganization gets an organization by ID
func (*Client) GetOrganizationRaw ¶ added in v0.3.0
func (c *Client) GetOrganizationRaw(ctx context.Context, realmName, orgID string) (json.RawMessage, error)
GetOrganizationRaw gets an organization by ID as raw JSON
func (*Client) GetOrganizations ¶
func (c *Client) GetOrganizations(ctx context.Context, realmName string) ([]OrganizationRepresentation, error)
GetOrganizations gets all organizations in a realm
func (*Client) GetOrganizationsRaw ¶ added in v0.3.0
func (c *Client) GetOrganizationsRaw(ctx context.Context, realmName string) ([]json.RawMessage, error)
GetOrganizationsRaw gets all organizations in a realm as raw JSON
func (*Client) GetRaw ¶ added in v0.3.0
GetRaw retrieves a resource as raw JSON (full representation)
func (*Client) GetRealmRaw ¶ added in v0.3.0
GetRealmRaw gets a realm as raw JSON (full representation)
func (*Client) GetRealmRole ¶
func (c *Client) GetRealmRole(ctx context.Context, realmName, roleName string) (*RoleRepresentation, error)
GetRealmRole gets a realm role by name
func (*Client) GetRealmRoleRaw ¶ added in v0.3.0
func (c *Client) GetRealmRoleRaw(ctx context.Context, realmName, roleName string) (json.RawMessage, error)
GetRealmRoleRaw gets a realm role by name as raw JSON
func (*Client) GetRealmRoles ¶ added in v0.3.0
GetRealmRoles gets all realm roles
func (*Client) GetRealmRolesRaw ¶ added in v0.3.0
GetRealmRolesRaw gets all realm roles as raw JSON
func (*Client) GetServerInfo ¶
func (c *Client) GetServerInfo(ctx context.Context) (*ServerInfo, error)
GetServerInfo returns Keycloak server information
func (*Client) GetUser ¶
func (c *Client) GetUser(ctx context.Context, realmName, userID string) (*UserRepresentation, error)
GetUser gets a user by ID
func (*Client) GetUserByUsername ¶
func (c *Client) GetUserByUsername(ctx context.Context, realmName, username string) (*UserRepresentation, error)
GetUserByUsername finds a user by username
func (*Client) GetUserClientRoleMappings ¶ added in v0.3.0
func (c *Client) GetUserClientRoleMappings(ctx context.Context, realmName, userID, clientUUID string) ([]RoleRepresentation, error)
GetUserClientRoleMappings gets client role mappings for a user
func (*Client) GetUserClientRoleMappingsRaw ¶ added in v0.3.0
func (c *Client) GetUserClientRoleMappingsRaw(ctx context.Context, realmName, userID, clientUUID string) ([]json.RawMessage, error)
GetUserClientRoleMappingsRaw gets client role mappings for a user as raw JSON
func (*Client) GetUserRaw ¶ added in v0.3.0
GetUserRaw gets a user by ID as raw JSON
func (*Client) GetUserRealmRoleMappings ¶ added in v0.3.0
func (c *Client) GetUserRealmRoleMappings(ctx context.Context, realmName, userID string) ([]RoleRepresentation, error)
GetUserRealmRoleMappings gets realm role mappings for a user
func (*Client) GetUserRealmRoleMappingsRaw ¶ added in v0.3.0
func (c *Client) GetUserRealmRoleMappingsRaw(ctx context.Context, realmName, userID string) ([]json.RawMessage, error)
GetUserRealmRoleMappingsRaw gets realm role mappings for a user as raw JSON
func (*Client) GetUsers ¶
func (c *Client) GetUsers(ctx context.Context, realmName string, params map[string]string) ([]UserRepresentation, error)
GetUsers gets users with optional filtering
func (*Client) GetUsersRaw ¶ added in v0.3.0
func (c *Client) GetUsersRaw(ctx context.Context, realmName string, params map[string]string) ([]json.RawMessage, error)
GetUsersRaw gets all users in a realm as raw JSON
func (*Client) List ¶
func (c *Client) List(ctx context.Context, path string, params map[string]string, result interface{}) error
List retrieves a list of resources with optional query parameters
func (*Client) ListRaw ¶ added in v0.3.0
func (c *Client) ListRaw(ctx context.Context, path string, params map[string]string) ([]json.RawMessage, error)
ListRaw retrieves a list of resources as raw JSON array
func (*Client) RegenerateClientSecret ¶
func (c *Client) RegenerateClientSecret(ctx context.Context, realmName, clientID string) (string, error)
RegenerateClientSecret regenerates the client secret
func (*Client) SetPassword ¶
func (c *Client) SetPassword(ctx context.Context, realmName, userID, password string, temporary bool) error
SetPassword sets a user's password
func (*Client) UpdateClient ¶
func (c *Client) UpdateClient(ctx context.Context, realmName, clientID string, clientDef json.RawMessage) error
UpdateClient updates a client
func (*Client) UpdateClientProtocolMapper ¶
func (c *Client) UpdateClientProtocolMapper(ctx context.Context, realmName, clientID, mapperID string, mapperDef json.RawMessage) error
UpdateClientProtocolMapper updates a protocol mapper
func (*Client) UpdateClientRole ¶
func (c *Client) UpdateClientRole(ctx context.Context, realmName, clientID, roleName string, roleDef json.RawMessage) error
UpdateClientRole updates a client role
func (*Client) UpdateClientScope ¶
func (c *Client) UpdateClientScope(ctx context.Context, realmName, scopeID string, scopeDef json.RawMessage) error
UpdateClientScope updates a client scope
func (*Client) UpdateClientScopeProtocolMapper ¶
func (c *Client) UpdateClientScopeProtocolMapper(ctx context.Context, realmName, scopeID, mapperID string, mapperDef json.RawMessage) error
UpdateClientScopeProtocolMapper updates a protocol mapper in a client scope
func (*Client) UpdateComponent ¶
func (c *Client) UpdateComponent(ctx context.Context, realmName, componentID string, componentDef json.RawMessage) error
UpdateComponent updates a component
func (*Client) UpdateGroup ¶
func (c *Client) UpdateGroup(ctx context.Context, realmName, groupID string, groupDef json.RawMessage) error
UpdateGroup updates a group
func (*Client) UpdateIdentityProvider ¶
func (c *Client) UpdateIdentityProvider(ctx context.Context, realmName, alias string, idpDef json.RawMessage) error
UpdateIdentityProvider updates an identity provider
func (*Client) UpdateOrganization ¶
func (c *Client) UpdateOrganization(ctx context.Context, realmName string, org OrganizationRepresentation) error
UpdateOrganization updates an existing organization
func (*Client) UpdateRealm ¶
func (c *Client) UpdateRealm(ctx context.Context, realmName string, definition json.RawMessage) error
UpdateRealm updates a realm from raw JSON definition
func (*Client) UpdateRealmRole ¶
func (c *Client) UpdateRealmRole(ctx context.Context, realmName, roleName string, roleDef json.RawMessage) error
UpdateRealmRole updates a realm role
func (*Client) UpdateUser ¶
func (c *Client) UpdateUser(ctx context.Context, realmName, userID string, userDef json.RawMessage) error
UpdateUser updates a user
type ClientManager ¶
type ClientManager struct {
// contains filtered or unexported fields
}
ClientManager handles Keycloak client lifecycle and rate limiting
func NewClientManager ¶
func NewClientManager(log logr.Logger) *ClientManager
NewClientManager creates a new client manager with default configuration
func NewClientManagerWithConfig ¶
func NewClientManagerWithConfig(log logr.Logger, cfg ClientManagerConfig) *ClientManager
NewClientManagerWithConfig creates a new client manager with custom configuration
func (*ClientManager) AcquireSlot ¶
func (m *ClientManager) AcquireSlot(ctx context.Context) (release func(), err error)
AcquireSlot acquires a rate-limiting slot. The returned function must be called to release the slot. If rate limiting is not configured, returns a no-op function immediately.
func (*ClientManager) ClearClients ¶
func (m *ClientManager) ClearClients()
ClearClients removes all clients
func (*ClientManager) GetOrCreateClient ¶
func (m *ClientManager) GetOrCreateClient(instanceName string, cfg Config) *Client
GetOrCreateClient gets or creates a Keycloak client for an instance
func (*ClientManager) RemoveClient ¶
func (m *ClientManager) RemoveClient(instanceName string)
RemoveClient removes a client from the manager
type ClientManagerConfig ¶
type ClientManagerConfig struct {
// MaxConcurrentRequests limits the number of concurrent requests to Keycloak.
// This prevents overwhelming Keycloak when reconciling many resources.
// Default: 10 (0 means no limit)
MaxConcurrentRequests int
}
ClientManagerConfig holds configuration for the ClientManager
func DefaultClientManagerConfig ¶
func DefaultClientManagerConfig() ClientManagerConfig
DefaultClientManagerConfig returns default client manager configuration
type ClientRepresentation ¶
type ClientRepresentation struct {
ID *string `json:"id,omitempty"`
ClientID *string `json:"clientId,omitempty"`
Name *string `json:"name,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Secret *string `json:"secret,omitempty"`
ServiceAccountsEnabled *bool `json:"serviceAccountsEnabled,omitempty"`
}
ClientRepresentation represents a Keycloak client (minimal fields we need)
type ClientScopeRepresentation ¶
type ClientScopeRepresentation struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Protocol *string `json:"protocol,omitempty"`
}
ClientScopeRepresentation represents a Keycloak client scope (minimal fields we need)
type ComponentRepresentation ¶
type ComponentRepresentation struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
ProviderID *string `json:"providerId,omitempty"`
ProviderType *string `json:"providerType,omitempty"`
ParentID *string `json:"parentId,omitempty"`
}
ComponentRepresentation represents a Keycloak component (minimal fields we need)
type Config ¶
type Config struct {
BaseURL string
Realm string // defaults to "master"
Username string
Password string
ClientID string // optional, for client credentials
ClientSecret string // optional, for client credentials
}
Config holds Keycloak client configuration
type GroupRepresentation ¶
type GroupRepresentation struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Path *string `json:"path,omitempty"`
SubGroups []GroupRepresentation `json:"subGroups,omitempty"`
}
GroupRepresentation represents a Keycloak group (minimal fields we need)
type IdentityProviderRepresentation ¶
type IdentityProviderRepresentation struct {
Alias *string `json:"alias,omitempty"`
DisplayName *string `json:"displayName,omitempty"`
ProviderId *string `json:"providerId,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
}
IdentityProviderRepresentation represents a Keycloak identity provider (minimal fields we need)
type OrganizationDomain ¶
type OrganizationDomain struct {
Name string `json:"name,omitempty"`
Verified bool `json:"verified,omitempty"`
}
OrganizationDomain represents a domain associated with an organization
type OrganizationRepresentation ¶
type OrganizationRepresentation struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Alias string `json:"alias,omitempty"`
Description string `json:"description,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Domains []OrganizationDomain `json:"domains,omitempty"`
Attributes map[string][]string `json:"attributes,omitempty"`
}
OrganizationRepresentation represents a Keycloak organization
type ProtocolMapperRepresentation ¶
type ProtocolMapperRepresentation struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Protocol *string `json:"protocol,omitempty"`
ProtocolMapper *string `json:"protocolMapper,omitempty"`
ConsentRequired *bool `json:"consentRequired,omitempty"`
Config map[string]string `json:"config,omitempty"`
}
ProtocolMapperRepresentation represents a protocol mapper (minimal fields we need)
type RealmRepresentation ¶
type RealmRepresentation struct {
ID *string `json:"id,omitempty"`
Realm *string `json:"realm,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
DisplayName *string `json:"displayName,omitempty"`
OrganizationsEnabled *bool `json:"organizationsEnabled,omitempty"`
}
RealmRepresentation represents a Keycloak realm (minimal fields we need)
type RetryConfig ¶
type RetryConfig struct {
MaxRetries int
InitialDelay time.Duration
MaxDelay time.Duration
BackoffFactor float64
RetryableFunc func(error) bool
}
RetryConfig holds retry configuration
func DefaultRetryConfig ¶
func DefaultRetryConfig() RetryConfig
DefaultRetryConfig returns default retry configuration
type RoleRepresentation ¶
type RoleRepresentation struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Composite *bool `json:"composite,omitempty"`
ClientRole *bool `json:"clientRole,omitempty"`
ContainerID *string `json:"containerId,omitempty"`
}
RoleRepresentation represents a Keycloak role (minimal fields we need)
type ServerInfo ¶
type ServerInfo struct {
SystemInfo struct {
Version string `json:"version"`
} `json:"systemInfo"`
}
ServerInfo represents Keycloak server information
type TokenResponse ¶
type TokenResponse struct {
AccessToken string `json:"access_token"`
ExpiresIn int `json:"expires_in"`
RefreshToken string `json:"refresh_token"`
RefreshExpiresIn int `json:"refresh_expires_in"`
TokenType string `json:"token_type"`
}
TokenResponse represents an OAuth2 token response
type UserRepresentation ¶
type UserRepresentation struct {
ID *string `json:"id,omitempty"`
Username *string `json:"username,omitempty"`
Email *string `json:"email,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
FirstName *string `json:"firstName,omitempty"`
LastName *string `json:"lastName,omitempty"`
EmailVerified *bool `json:"emailVerified,omitempty"`
}
UserRepresentation represents a Keycloak user (minimal fields we need)