common

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecretKind = "Secret"
)

Variables

This section is empty.

Functions

func GetMatchingKeycloaks

func GetMatchingKeycloaks(ctx context.Context, c client.Client, labelSelector *v1.LabelSelector) (v1alpha1.KeycloakList, error)

Try to get a list of keycloak instances that match the selector specified on the realm

func GetMatchingRealms

func GetMatchingRealms(ctx context.Context, c client.Client, labelSelector *v1.LabelSelector) (v1alpha1.KeycloakRealmList, error)

Try to get a list of keycloak instances that match the selector specified on the realm

func GetStateFieldName

func GetStateFieldName(controllerName string, kind string) string

func WatchSecondaryResource

func WatchSecondaryResource(c controller.Controller, controllerName string, resourceKind string, objectTypetoWatch client.Object, cr runtime.Object) error

Types

type ActionRunner

type ActionRunner interface {
	RunAll(desiredState DesiredClusterState) error
	Create(obj client.Object) error
	Update(obj client.Object) error
	Delete(obj client.Object) error
	CreateClient(keycloakClient *v1alpha1.KeycloakClient, Realm string) error
	DeleteClient(keycloakClient *v1alpha1.KeycloakClient, Realm string) error
	UpdateClient(keycloakClient *v1alpha1.KeycloakClient, Realm string) error
	CreateClientRole(keycloakClient *v1alpha1.KeycloakClient, role *v1alpha1.RoleRepresentation, realm string) error
	UpdateClientRole(keycloakClient *v1alpha1.KeycloakClient, role, oldRole *v1alpha1.RoleRepresentation, realm string) error
	DeleteClientRole(keycloakClient *v1alpha1.KeycloakClient, role, Realm string) error
	CreateClientRealmScopeMappings(keycloakClient *v1alpha1.KeycloakClient, mappings *[]v1alpha1.RoleRepresentation, realm string) error
	DeleteClientRealmScopeMappings(keycloakClient *v1alpha1.KeycloakClient, mappings *[]v1alpha1.RoleRepresentation, realm string) error
	CreateClientClientScopeMappings(keycloakClient *v1alpha1.KeycloakClient, mappings *v1alpha1.ClientMappingsRepresentation, realm string) error
	DeleteClientClientScopeMappings(keycloakClient *v1alpha1.KeycloakClient, mappings *v1alpha1.ClientMappingsRepresentation, realm string) error
	UpdateClientDefaultClientScope(keycloakClient *v1alpha1.KeycloakClient, clientScope *v1alpha1.KeycloakClientScope, realm string) error
	DeleteClientDefaultClientScope(keycloakClient *v1alpha1.KeycloakClient, clientScope *v1alpha1.KeycloakClientScope, realm string) error
	UpdateClientOptionalClientScope(keycloakClient *v1alpha1.KeycloakClient, clientScope *v1alpha1.KeycloakClientScope, realm string) error
	DeleteClientOptionalClientScope(keycloakClient *v1alpha1.KeycloakClient, clientScope *v1alpha1.KeycloakClientScope, realm string) error

	AssignRealmRole(obj *v1alpha1.KeycloakUserRole, userID, realm string) error
	RemoveRealmRole(obj *v1alpha1.KeycloakUserRole, userID, realm string) error
	AssignClientRole(obj *v1alpha1.KeycloakUserRole, clientID, userID, realm string) error
	RemoveClientRole(obj *v1alpha1.KeycloakUserRole, clientID, userID, realm string) error
	AddDefaultRoles(obj *[]v1alpha1.RoleRepresentation, defaultRealmRoleID, realm string) error
	DeleteDefaultRoles(obj *[]v1alpha1.RoleRepresentation, defaultRealmRoleID, realm string) error
	Ping() error
}

func NewClusterActionRunner

func NewClusterActionRunner(context context.Context, client client.Client, scheme *runtime.Scheme, cr client.Object) ActionRunner

Create an action runner to run kubernetes actions

func NewClusterAndKeycloakActionRunner

func NewClusterAndKeycloakActionRunner(context context.Context, client client.Client, scheme *runtime.Scheme, cr client.Object, keycloakClient KeycloakInterface) ActionRunner

Create an action runner to run kubernetes and keycloak api actions

type AddDefaultRolesAction

type AddDefaultRolesAction struct {
	Roles              *[]v1alpha1.RoleRepresentation
	DefaultRealmRoleID string
	Ref                *v1alpha1.KeycloakClient
	Msg                string
	Realm              string
}

func (AddDefaultRolesAction) Run

type AssignClientRoleAction

type AssignClientRoleAction struct {
	UserID   string
	ClientID string
	Ref      *v1alpha1.KeycloakUserRole
	Realm    string
	Msg      string
}

func (AssignClientRoleAction) Run

type AssignRealmRoleAction

type AssignRealmRoleAction struct {
	UserID string
	Ref    *v1alpha1.KeycloakUserRole
	Realm  string
	Msg    string
}

func (AssignRealmRoleAction) Run

type Client

type Client struct {
	URL string
	// contains filtered or unexported fields
}

func (*Client) AddRealmRoleComposites

func (c *Client) AddRealmRoleComposites(realmName, roleID string, roles *[]v1alpha1.RoleRepresentation) error

func (*Client) CreateClient

func (c *Client) CreateClient(client *v1alpha1.KeycloakAPIClient, realmName string) (string, error)

func (*Client) CreateClientClientScopeMappings

func (c *Client) CreateClientClientScopeMappings(specClient *v1alpha1.KeycloakAPIClient, mappings *v1alpha1.ClientMappingsRepresentation, realmName string) error

func (*Client) CreateClientRealmScopeMappings

func (c *Client) CreateClientRealmScopeMappings(specClient *v1alpha1.KeycloakAPIClient, mappings *[]v1alpha1.RoleRepresentation, realmName string) error

func (*Client) CreateClientRole

func (c *Client) CreateClientRole(clientID string, role *v1alpha1.RoleRepresentation, realmName string) (string, error)

func (*Client) CreateFederatedIdentity

func (c *Client) CreateFederatedIdentity(fid v1alpha1.FederatedIdentity, userID string, realmName string) (string, error)

func (*Client) CreateRealm

func (c *Client) CreateRealm(realm *v1alpha1.KeycloakRealm) (string, error)

func (*Client) CreateUserClientRole

func (c *Client) CreateUserClientRole(role *v1alpha1.KeycloakUserRole, realmName, clientID, userID string) (string, error)

func (*Client) CreateUserRealmRole

func (c *Client) CreateUserRealmRole(role *v1alpha1.KeycloakUserRole, realmName, userID string) (string, error)

func (*Client) DeleteClient

func (c *Client) DeleteClient(clientID, realmName string) error

func (*Client) DeleteClientClientScopeMappings

func (c *Client) DeleteClientClientScopeMappings(specClient *v1alpha1.KeycloakAPIClient, mappings *v1alpha1.ClientMappingsRepresentation, realmName string) error

func (*Client) DeleteClientDefaultClientScope

func (c *Client) DeleteClientDefaultClientScope(specClient *v1alpha1.KeycloakAPIClient, clientScope *v1alpha1.KeycloakClientScope, realmName string) error

func (*Client) DeleteClientOptionalClientScope

func (c *Client) DeleteClientOptionalClientScope(specClient *v1alpha1.KeycloakAPIClient, clientScope *v1alpha1.KeycloakClientScope, realmName string) error

func (*Client) DeleteClientRealmScopeMappings

func (c *Client) DeleteClientRealmScopeMappings(specClient *v1alpha1.KeycloakAPIClient, mappings *[]v1alpha1.RoleRepresentation, realmName string) error

func (*Client) DeleteClientRole

func (c *Client) DeleteClientRole(clientID, role, realmName string) error

func (*Client) DeleteRealm

func (c *Client) DeleteRealm(realmName string) error

func (*Client) DeleteRealmRoleComposites

func (c *Client) DeleteRealmRoleComposites(realmName, roleID string, roles *[]v1alpha1.RoleRepresentation) error

func (*Client) DeleteUserClientRole

func (c *Client) DeleteUserClientRole(role *v1alpha1.KeycloakUserRole, realmName, clientID, userID string) error

func (*Client) DeleteUserRealmRole

func (c *Client) DeleteUserRealmRole(role *v1alpha1.KeycloakUserRole, realmName, userID string) error

func (*Client) Endpoint

func (c *Client) Endpoint() string

func (*Client) GetClient

func (c *Client) GetClient(clientID, realmName string) (*v1alpha1.KeycloakAPIClient, error)

func (*Client) GetClientID

func (c *Client) GetClientID(name, realmName string) (string, error)

func (*Client) GetClientInstall

func (c *Client) GetClientInstall(clientID, realmName string) ([]byte, error)

func (*Client) GetClientSecret

func (c *Client) GetClientSecret(clientID, realmName string) (string, error)

func (*Client) GetRealm

func (c *Client) GetRealm(realmName string) (*v1alpha1.KeycloakRealm, error)

func (*Client) GetServiceAccountUser

func (c *Client) GetServiceAccountUser(realmName, clientID string) (*v1alpha1.KeycloakAPIUser, error)

func (*Client) GetUserFederatedIdentities

func (c *Client) GetUserFederatedIdentities(userID string, realmName string) ([]v1alpha1.FederatedIdentity, error)

func (*Client) ListAvailableClientScopes

func (c *Client) ListAvailableClientScopes(realmName string) ([]v1alpha1.KeycloakClientScope, error)

func (*Client) ListAvailableUserClientRoles

func (c *Client) ListAvailableUserClientRoles(realmName, clientID, userID string) ([]*v1alpha1.KeycloakUserRole, error)

func (*Client) ListAvailableUserRealmRoles

func (c *Client) ListAvailableUserRealmRoles(realmName, userID string) ([]*v1alpha1.KeycloakUserRole, error)

func (*Client) ListClientRoles

func (c *Client) ListClientRoles(clientID, realmName string) ([]v1alpha1.RoleRepresentation, error)

func (*Client) ListClients

func (c *Client) ListClients(realmName string) ([]*v1alpha1.KeycloakAPIClient, error)

func (*Client) ListDefaultClientScopes

func (c *Client) ListDefaultClientScopes(clientID, realmName string) ([]v1alpha1.KeycloakClientScope, error)

func (*Client) ListOptionalClientScopes

func (c *Client) ListOptionalClientScopes(clientID, realmName string) ([]v1alpha1.KeycloakClientScope, error)

func (*Client) ListRealmRoleClientRoleComposites

func (c *Client) ListRealmRoleClientRoleComposites(realmName, roleID, clientID string) ([]v1alpha1.RoleRepresentation, error)

func (*Client) ListRealms

func (c *Client) ListRealms() ([]*v1alpha1.KeycloakRealm, error)

func (*Client) ListScopeMappings

func (c *Client) ListScopeMappings(clientID, realmName string) (*v1alpha1.MappingsRepresentation, error)

func (*Client) ListUserClientRoles

func (c *Client) ListUserClientRoles(realmName, clientID, userID string) ([]*v1alpha1.KeycloakUserRole, error)

func (*Client) ListUserRealmRoles

func (c *Client) ListUserRealmRoles(realmName, userID string) ([]*v1alpha1.KeycloakUserRole, error)

func (*Client) Ping

func (c *Client) Ping() error

func (*Client) RemoveFederatedIdentity

func (c *Client) RemoveFederatedIdentity(fid v1alpha1.FederatedIdentity, userID string, realmName string) error

func (*Client) UpdateClient

func (c *Client) UpdateClient(specClient *v1alpha1.KeycloakAPIClient, realmName string) error

func (*Client) UpdateClientDefaultClientScope

func (c *Client) UpdateClientDefaultClientScope(specClient *v1alpha1.KeycloakAPIClient, clientScope *v1alpha1.KeycloakClientScope, realmName string) error

func (*Client) UpdateClientOptionalClientScope

func (c *Client) UpdateClientOptionalClientScope(specClient *v1alpha1.KeycloakAPIClient, clientScope *v1alpha1.KeycloakClientScope, realmName string) error

func (*Client) UpdateClientRole

func (c *Client) UpdateClientRole(clientID string, role, oldRole *v1alpha1.RoleRepresentation, realmName string) error

func (*Client) UpdateRealm

func (c *Client) UpdateRealm(realm *v1alpha1.KeycloakRealm) error

type ClientState

type ClientState struct {
	Client                  *kc.KeycloakAPIClient
	ClientSecret            *v1.Secret // keycloak-client-secret-<custom resource name>
	Context                 context.Context
	Realm                   *kc.KeycloakRealm
	Roles                   []kc.RoleRepresentation
	DefaultRoleID           string
	DefaultRoles            []kc.RoleRepresentation
	ScopeMappings           *kc.MappingsRepresentation
	AvailableClientScopes   []kc.KeycloakClientScope
	DefaultClientScopes     []kc.KeycloakClientScope
	OptionalClientScopes    []kc.KeycloakClientScope
	DeprecatedClientSecret  *v1.Secret // keycloak-client-secret-<clientID>
	Keycloak                kc.Keycloak
	ServiceAccountUserState *UserState
}

func NewClientState

func NewClientState(context context.Context, realm *kc.KeycloakRealm, keycloak kc.Keycloak) *ClientState

func (*ClientState) Read

func (i *ClientState) Read(context context.Context, cr *kc.KeycloakClient, realmClient KeycloakInterface, controllerClient client.Client) error

type ClusterAction

type ClusterAction interface {
	Run(runner ActionRunner) (string, error)
}

type ClusterActionRunner

type ClusterActionRunner struct {
	// contains filtered or unexported fields
}

func (*ClusterActionRunner) AddDefaultRoles

func (i *ClusterActionRunner) AddDefaultRoles(obj *[]v1alpha1.RoleRepresentation, defaultRealmRoleID, realm string) error

func (*ClusterActionRunner) AssignClientRole

func (i *ClusterActionRunner) AssignClientRole(obj *v1alpha1.KeycloakUserRole, clientID, userID, realm string) error

func (*ClusterActionRunner) AssignRealmRole

func (i *ClusterActionRunner) AssignRealmRole(obj *v1alpha1.KeycloakUserRole, userID, realm string) error

func (*ClusterActionRunner) Create

func (i *ClusterActionRunner) Create(obj client.Object) error

func (*ClusterActionRunner) CreateClient

func (i *ClusterActionRunner) CreateClient(obj *v1alpha1.KeycloakClient, realm string) error

func (*ClusterActionRunner) CreateClientClientScopeMappings

func (i *ClusterActionRunner) CreateClientClientScopeMappings(keycloakClient *v1alpha1.KeycloakClient, mappings *v1alpha1.ClientMappingsRepresentation, realm string) error

func (*ClusterActionRunner) CreateClientRealmScopeMappings

func (i *ClusterActionRunner) CreateClientRealmScopeMappings(keycloakClient *v1alpha1.KeycloakClient, mappings *[]v1alpha1.RoleRepresentation, realm string) error

func (*ClusterActionRunner) CreateClientRole

func (i *ClusterActionRunner) CreateClientRole(obj *v1alpha1.KeycloakClient, role *v1alpha1.RoleRepresentation, realm string) error

func (*ClusterActionRunner) CreateRealm

func (i *ClusterActionRunner) CreateRealm(obj *v1alpha1.KeycloakRealm) error

Create a new realm using the keycloak api

func (*ClusterActionRunner) Delete

func (i *ClusterActionRunner) Delete(obj client.Object) error

func (*ClusterActionRunner) DeleteClient

func (i *ClusterActionRunner) DeleteClient(obj *v1alpha1.KeycloakClient, realm string) error

func (*ClusterActionRunner) DeleteClientClientScopeMappings

func (i *ClusterActionRunner) DeleteClientClientScopeMappings(keycloakClient *v1alpha1.KeycloakClient, mappings *v1alpha1.ClientMappingsRepresentation, realm string) error

func (*ClusterActionRunner) DeleteClientDefaultClientScope

func (i *ClusterActionRunner) DeleteClientDefaultClientScope(keycloakClient *v1alpha1.KeycloakClient, clientScope *v1alpha1.KeycloakClientScope, realm string) error

func (*ClusterActionRunner) DeleteClientOptionalClientScope

func (i *ClusterActionRunner) DeleteClientOptionalClientScope(keycloakClient *v1alpha1.KeycloakClient, clientScope *v1alpha1.KeycloakClientScope, realm string) error

func (*ClusterActionRunner) DeleteClientRealmScopeMappings

func (i *ClusterActionRunner) DeleteClientRealmScopeMappings(keycloakClient *v1alpha1.KeycloakClient, mappings *[]v1alpha1.RoleRepresentation, realm string) error

func (*ClusterActionRunner) DeleteClientRole

func (i *ClusterActionRunner) DeleteClientRole(obj *v1alpha1.KeycloakClient, role, realm string) error

func (*ClusterActionRunner) DeleteDefaultRoles

func (i *ClusterActionRunner) DeleteDefaultRoles(obj *[]v1alpha1.RoleRepresentation, defaultRealmRoleID, realm string) error

func (*ClusterActionRunner) DeleteRealm

func (i *ClusterActionRunner) DeleteRealm(obj *v1alpha1.KeycloakRealm) error

Delete a realm using the keycloak api

func (*ClusterActionRunner) Ping

func (i *ClusterActionRunner) Ping() error

Check if Keycloak is available

func (*ClusterActionRunner) RemoveClientRole

func (i *ClusterActionRunner) RemoveClientRole(obj *v1alpha1.KeycloakUserRole, clientID, userID, realm string) error

func (*ClusterActionRunner) RemoveRealmRole

func (i *ClusterActionRunner) RemoveRealmRole(obj *v1alpha1.KeycloakUserRole, userID, realm string) error

func (*ClusterActionRunner) RunAll

func (i *ClusterActionRunner) RunAll(desiredState DesiredClusterState) error

func (*ClusterActionRunner) Update

func (i *ClusterActionRunner) Update(obj client.Object) error

func (*ClusterActionRunner) UpdateClient

func (i *ClusterActionRunner) UpdateClient(obj *v1alpha1.KeycloakClient, realm string) error

func (*ClusterActionRunner) UpdateClientDefaultClientScope

func (i *ClusterActionRunner) UpdateClientDefaultClientScope(keycloakClient *v1alpha1.KeycloakClient, clientScope *v1alpha1.KeycloakClientScope, realm string) error

func (*ClusterActionRunner) UpdateClientOptionalClientScope

func (i *ClusterActionRunner) UpdateClientOptionalClientScope(keycloakClient *v1alpha1.KeycloakClient, clientScope *v1alpha1.KeycloakClientScope, realm string) error

func (*ClusterActionRunner) UpdateClientRole

func (i *ClusterActionRunner) UpdateClientRole(obj *v1alpha1.KeycloakClient, role, oldRole *v1alpha1.RoleRepresentation, realm string) error

type ClusterState

type ClusterState struct {
	KeycloakDeployment  *v12.StatefulSet
	KeycloakAdminSecret *v1.Secret
}

func NewClusterState

func NewClusterState() *ClusterState

func (*ClusterState) IsResourcesReady

func (i *ClusterState) IsResourcesReady(cr *kc.Keycloak) (bool, error)

func (*ClusterState) Read

func (i *ClusterState) Read(context context.Context, cr *kc.Keycloak, controllerClient client.Client) error

type CreateClientAction

type CreateClientAction struct {
	Ref   *v1alpha1.KeycloakClient
	Msg   string
	Realm string
}

func (CreateClientAction) Run

func (i CreateClientAction) Run(runner ActionRunner) (string, error)

type CreateClientClientScopeMappingsAction

type CreateClientClientScopeMappingsAction struct {
	Mappings *v1alpha1.ClientMappingsRepresentation
	Ref      *v1alpha1.KeycloakClient
	Msg      string
	Realm    string
}

func (CreateClientClientScopeMappingsAction) Run

type CreateClientRealmScopeMappingsAction

type CreateClientRealmScopeMappingsAction struct {
	Mappings *[]v1alpha1.RoleRepresentation
	Ref      *v1alpha1.KeycloakClient
	Msg      string
	Realm    string
}

func (CreateClientRealmScopeMappingsAction) Run

type CreateClientRoleAction

type CreateClientRoleAction struct {
	Role  *v1alpha1.RoleRepresentation
	Ref   *v1alpha1.KeycloakClient
	Msg   string
	Realm string
}

func (CreateClientRoleAction) Run

type DeleteClientAction

type DeleteClientAction struct {
	Ref   *v1alpha1.KeycloakClient
	Realm string
	Msg   string
}

func (DeleteClientAction) Run

func (i DeleteClientAction) Run(runner ActionRunner) (string, error)

type DeleteClientClientScopeMappingsAction

type DeleteClientClientScopeMappingsAction struct {
	Mappings *v1alpha1.ClientMappingsRepresentation
	Ref      *v1alpha1.KeycloakClient
	Msg      string
	Realm    string
}

func (DeleteClientClientScopeMappingsAction) Run

type DeleteClientDefaultClientScopeAction

type DeleteClientDefaultClientScopeAction struct {
	ClientScope *v1alpha1.KeycloakClientScope
	Ref         *v1alpha1.KeycloakClient
	Msg         string
	Realm       string
}

func (DeleteClientDefaultClientScopeAction) Run

type DeleteClientOptionalClientScopeAction

type DeleteClientOptionalClientScopeAction struct {
	ClientScope *v1alpha1.KeycloakClientScope
	Ref         *v1alpha1.KeycloakClient
	Msg         string
	Realm       string
}

func (DeleteClientOptionalClientScopeAction) Run

type DeleteClientRealmScopeMappingsAction

type DeleteClientRealmScopeMappingsAction struct {
	Mappings *[]v1alpha1.RoleRepresentation
	Ref      *v1alpha1.KeycloakClient
	Msg      string
	Realm    string
}

func (DeleteClientRealmScopeMappingsAction) Run

type DeleteClientRoleAction

type DeleteClientRoleAction struct {
	Role  *v1alpha1.RoleRepresentation
	Ref   *v1alpha1.KeycloakClient
	Msg   string
	Realm string
}

func (DeleteClientRoleAction) Run

type DeleteDefaultRolesAction

type DeleteDefaultRolesAction struct {
	Roles              *[]v1alpha1.RoleRepresentation
	DefaultRealmRoleID string
	Ref                *v1alpha1.KeycloakClient
	Msg                string
	Realm              string
}

func (DeleteDefaultRolesAction) Run

type DesiredClusterState

type DesiredClusterState []ClusterAction

The desired cluster state is defined by a list of actions that have to be run to get from the current state to the desired state

func (*DesiredClusterState) AddAction

func (*DesiredClusterState) AddActions

func (d *DesiredClusterState) AddActions(actions []ClusterAction) DesiredClusterState

type GenericCreateAction

type GenericCreateAction struct {
	Ref client.Object
	Msg string
}

An action to create generic kubernetes resources (resources that don't require special treatment)

func (GenericCreateAction) Run

func (i GenericCreateAction) Run(runner ActionRunner) (string, error)

type GenericDeleteAction

type GenericDeleteAction struct {
	Ref client.Object
	Msg string
}

An action to delete generic kubernetes resources (resources that don't require special treatment)

func (GenericDeleteAction) Run

func (i GenericDeleteAction) Run(runner ActionRunner) (string, error)

type GenericUpdateAction

type GenericUpdateAction struct {
	Ref client.Object
	Msg string
}

An action to update generic kubernetes resources (resources that don't require special treatment)

func (GenericUpdateAction) Run

func (i GenericUpdateAction) Run(runner ActionRunner) (string, error)

type KeycloakClientFactory

type KeycloakClientFactory interface {
	AuthenticatedClient(kc v1alpha1.Keycloak) (KeycloakInterface, error)
}

KeycloakClientFactory interface

type KeycloakInterface

type KeycloakInterface interface {
	Ping() error

	Endpoint() string

	CreateRealm(realm *v1alpha1.KeycloakRealm) (string, error)
	GetRealm(realmName string) (*v1alpha1.KeycloakRealm, error)
	UpdateRealm(specRealm *v1alpha1.KeycloakRealm) error
	DeleteRealm(realmName string) error
	ListRealms() ([]*v1alpha1.KeycloakRealm, error)

	ListRealmRoleClientRoleComposites(realmName, roleID, clientID string) ([]v1alpha1.RoleRepresentation, error)
	AddRealmRoleComposites(realmName, roleID string, roles *[]v1alpha1.RoleRepresentation) error
	DeleteRealmRoleComposites(realmName, roleID string, roles *[]v1alpha1.RoleRepresentation) error

	CreateClient(client *v1alpha1.KeycloakAPIClient, realmName string) (string, error)
	GetClient(clientID, realmName string) (*v1alpha1.KeycloakAPIClient, error)
	GetClientID(clientID, realmName string) (string, error)
	GetClientSecret(clientID, realmName string) (string, error)
	GetClientInstall(clientID, realmName string) ([]byte, error)
	UpdateClient(specClient *v1alpha1.KeycloakAPIClient, realmName string) error
	DeleteClient(clientID, realmName string) error
	ListClients(realmName string) ([]*v1alpha1.KeycloakAPIClient, error)
	ListClientRoles(clientID, realmName string) ([]v1alpha1.RoleRepresentation, error)
	ListScopeMappings(clientID, realmName string) (*v1alpha1.MappingsRepresentation, error)
	ListAvailableClientScopes(realmName string) ([]v1alpha1.KeycloakClientScope, error)
	ListDefaultClientScopes(clientID, realmName string) ([]v1alpha1.KeycloakClientScope, error)
	ListOptionalClientScopes(clientID, realmName string) ([]v1alpha1.KeycloakClientScope, error)
	CreateClientRole(clientID string, role *v1alpha1.RoleRepresentation, realmName string) (string, error)
	UpdateClientRole(clientID string, role, oldRole *v1alpha1.RoleRepresentation, realmName string) error
	DeleteClientRole(clientID, role, realmName string) error
	CreateClientRealmScopeMappings(specClient *v1alpha1.KeycloakAPIClient, mappings *[]v1alpha1.RoleRepresentation, realmName string) error
	DeleteClientRealmScopeMappings(specClient *v1alpha1.KeycloakAPIClient, mappings *[]v1alpha1.RoleRepresentation, realmName string) error
	CreateClientClientScopeMappings(specClient *v1alpha1.KeycloakAPIClient, mappings *v1alpha1.ClientMappingsRepresentation, realmName string) error
	DeleteClientClientScopeMappings(specClient *v1alpha1.KeycloakAPIClient, mappings *v1alpha1.ClientMappingsRepresentation, realmName string) error
	UpdateClientDefaultClientScope(specClient *v1alpha1.KeycloakAPIClient, clientScope *v1alpha1.KeycloakClientScope, realmName string) error
	DeleteClientDefaultClientScope(specClient *v1alpha1.KeycloakAPIClient, clientScope *v1alpha1.KeycloakClientScope, realmName string) error
	UpdateClientOptionalClientScope(specClient *v1alpha1.KeycloakAPIClient, clientScope *v1alpha1.KeycloakClientScope, realmName string) error
	DeleteClientOptionalClientScope(specClient *v1alpha1.KeycloakAPIClient, clientScope *v1alpha1.KeycloakClientScope, realmName string) error

	CreateFederatedIdentity(fid v1alpha1.FederatedIdentity, userID string, realmName string) (string, error)
	RemoveFederatedIdentity(fid v1alpha1.FederatedIdentity, userID string, realmName string) error
	GetUserFederatedIdentities(userName string, realmName string) ([]v1alpha1.FederatedIdentity, error)

	CreateUserClientRole(role *v1alpha1.KeycloakUserRole, realmName, clientID, userID string) (string, error)
	ListUserClientRoles(realmName, clientID, userID string) ([]*v1alpha1.KeycloakUserRole, error)
	ListAvailableUserClientRoles(realmName, clientID, userID string) ([]*v1alpha1.KeycloakUserRole, error)
	DeleteUserClientRole(role *v1alpha1.KeycloakUserRole, realmName, clientID, userID string) error

	CreateUserRealmRole(role *v1alpha1.KeycloakUserRole, realmName, userID string) (string, error)
	ListUserRealmRoles(realmName, userID string) ([]*v1alpha1.KeycloakUserRole, error)
	ListAvailableUserRealmRoles(realmName, userID string) ([]*v1alpha1.KeycloakUserRole, error)
	DeleteUserRealmRole(role *v1alpha1.KeycloakUserRole, realmName, userID string) error

	GetServiceAccountUser(realmName, clientID string) (*v1alpha1.KeycloakAPIUser, error)
}

type LocalConfigKeycloakFactory

type LocalConfigKeycloakFactory struct {
}

func (*LocalConfigKeycloakFactory) AuthenticatedClient

func (i *LocalConfigKeycloakFactory) AuthenticatedClient(kc v1alpha1.Keycloak, insecureSsl bool) (KeycloakInterface, error)

AuthenticatedClient returns an authenticated client for requesting endpoints from the Keycloak api

type PingAction

type PingAction struct {
	Msg string
}

func (PingAction) Run

func (i PingAction) Run(runner ActionRunner) (string, error)

type RealmState

type RealmState struct {
	Realm            *kc.KeycloakRealm
	RealmUserSecrets map[string]*v1.Secret
	Context          context.Context
	Keycloak         *kc.Keycloak
}

func NewRealmState

func NewRealmState(context context.Context, keycloak kc.Keycloak) *RealmState

func (*RealmState) Read

func (i *RealmState) Read(cr *kc.KeycloakRealm, realmClient KeycloakInterface, controllerClient client.Client) error

type RemoveClientRoleAction

type RemoveClientRoleAction struct {
	UserID   string
	ClientID string
	Ref      *v1alpha1.KeycloakUserRole
	Realm    string
	Msg      string
}

func (RemoveClientRoleAction) Run

type RemoveRealmRoleAction

type RemoveRealmRoleAction struct {
	UserID string
	Ref    *v1alpha1.KeycloakUserRole
	Realm  string
	Msg    string
}

func (RemoveRealmRoleAction) Run

type Requester

type Requester interface {
	Do(req *http.Request) (*http.Response, error)
}

type StateManager

type StateManager struct {
	*sync.Mutex
	// contains filtered or unexported fields
}

func GetStateManager

func GetStateManager() *StateManager

func (*StateManager) Clear

func (sm *StateManager) Clear()

func (*StateManager) GetState

func (sm *StateManager) GetState(key string) interface{}

func (*StateManager) SetState

func (sm *StateManager) SetState(key string, value interface{})

type T

type T interface{}

T is a generic type for keycloak spec resources

type UpdateClientAction

type UpdateClientAction struct {
	Ref   *v1alpha1.KeycloakClient
	Msg   string
	Realm string
}

func (UpdateClientAction) Run

func (i UpdateClientAction) Run(runner ActionRunner) (string, error)

type UpdateClientDefaultClientScopeAction

type UpdateClientDefaultClientScopeAction struct {
	ClientScope *v1alpha1.KeycloakClientScope
	Ref         *v1alpha1.KeycloakClient
	Msg         string
	Realm       string
}

func (UpdateClientDefaultClientScopeAction) Run

type UpdateClientOptionalClientScopeAction

type UpdateClientOptionalClientScopeAction struct {
	ClientScope *v1alpha1.KeycloakClientScope
	Ref         *v1alpha1.KeycloakClient
	Msg         string
	Realm       string
}

func (UpdateClientOptionalClientScopeAction) Run

type UpdateClientRoleAction

type UpdateClientRoleAction struct {
	Role    *v1alpha1.RoleRepresentation
	OldRole *v1alpha1.RoleRepresentation
	Ref     *v1alpha1.KeycloakClient
	Msg     string
	Realm   string
}

func (UpdateClientRoleAction) Run

type UserState

type UserState struct {
	User                 *v1alpha1.KeycloakAPIUser
	ClientRoles          map[string][]*v1alpha1.KeycloakUserRole
	RealmRoles           []*v1alpha1.KeycloakUserRole
	AvailableClientRoles map[string][]*v1alpha1.KeycloakUserRole
	AvailableRealmRoles  []*v1alpha1.KeycloakUserRole
	Clients              []*v1alpha1.KeycloakAPIClient
	Secret               *v1.Secret
	Keycloak             v1alpha1.Keycloak
	Context              context.Context
}

func NewUserState

func NewUserState(keycloak v1alpha1.Keycloak) *UserState

func (*UserState) GetAvailableClientRole

func (i *UserState) GetAvailableClientRole(name, clientID string) *v1alpha1.KeycloakUserRole

Check if a client role is part of the available roles for this user Don't allow to assign unavailable roles

func (*UserState) GetAvailableRealmRole

func (i *UserState) GetAvailableRealmRole(name string) *v1alpha1.KeycloakUserRole

Check if a realm role is part of the available roles for this user Don't allow to assign unavailable roles

func (*UserState) GetClientByID

func (i *UserState) GetClientByID(clientID string) *v1alpha1.KeycloakAPIClient

Keycloak clients have `ID` and `ClientID` properties and depending on the action we need one or the other. This function translates between the two

func (*UserState) ReadWithExistingAPIUser

func (i *UserState) ReadWithExistingAPIUser(keycloakClient KeycloakInterface, userClient client.Client, user *v1alpha1.KeycloakAPIUser, realm v1alpha1.KeycloakRealm) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL