common

package
v0.0.0-...-f0b2224 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteKind               = "Route"
	SecretKind              = "Secret"
	PodDisruptionBudgetKind = "PodDisruptionBudget"
	OpenShiftAPIServerKind  = "OpenShiftAPIServer"
)

These kinds are not provided by the openshift api

Variables

This section is empty.

Functions

func GetMatchingKeycloaks

func GetMatchingKeycloaks(ctx context.Context, c client.Client, labelSelector *v1.LabelSelector) (v1alpha1.ExternalKeycloakList, 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 runtime.Object, cr runtime.Object) error

Types

type ActionRunner

type ActionRunner interface {
	RunAll(desiredState DesiredClusterState) error
	Create(obj runtime.Object) error
	Update(obj runtime.Object) error
	Delete(obj runtime.Object) error
	CreateRealm(obj *v1alpha1.KeycloakRealm) error
	DeleteRealm(obj *v1alpha1.KeycloakRealm) 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
	CreateUser(obj *v1alpha1.KeycloakUser, realm string) error
	UpdateUser(obj *v1alpha1.KeycloakUser, realm string) error
	DeleteUser(id, 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
	ApplyOverrides(obj *v1alpha1.KeycloakRealm) error
	Ping() error
}

func NewClusterActionRunner

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

Create an action runner to run kubernetes actions

func NewClusterAndKeycloakActionRunner

func NewClusterAndKeycloakActionRunner(context context.Context, client client.Client, scheme *runtime.Scheme, cr runtime.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 Background

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

Background represents a procedure that runs in the background, periodically auto-detecting features

func NewAutoDetect

func NewAutoDetect(mgr manager.Manager) (*Background, error)

New creates a new auto-detect runner

func (*Background) Start

func (b *Background) Start()

Start initializes the auto-detection process that runs in the background

func (*Background) Stop

func (b *Background) Stop()

Stop causes the background process to stop auto detecting capabilities

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) CreateAuthenticatorConfig

func (c *Client) CreateAuthenticatorConfig(authenticatorConfig *v1alpha1.AuthenticatorConfig, realmName, executionID string) (string, 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) CreateIdentityProvider

func (c *Client) CreateIdentityProvider(identityProvider *v1alpha1.KeycloakIdentityProvider, realmName string) (string, error)

func (*Client) CreateRealm

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

func (*Client) CreateUser

func (c *Client) CreateUser(user *v1alpha1.KeycloakAPIUser, realmName string) (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) DeleteAuthenticatorConfig

func (c *Client) DeleteAuthenticatorConfig(configID, realmName 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) DeleteIdentityProvider

func (c *Client) DeleteIdentityProvider(alias string, 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) DeleteUser

func (c *Client) DeleteUser(userID, realmName string) 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) FindUserByEmail

func (c *Client) FindUserByEmail(email, realm string) (*v1alpha1.KeycloakAPIUser, error)

func (*Client) FindUserByUsername

func (c *Client) FindUserByUsername(name, realm string) (*v1alpha1.KeycloakAPIUser, error)

func (*Client) GetAuthenticatorConfig

func (c *Client) GetAuthenticatorConfig(configID, realmName string) (*v1alpha1.AuthenticatorConfig, error)

func (*Client) GetClient

func (c *Client) GetClient(clientID, realmName string) (*v1alpha1.KeycloakAPIClient, 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) GetFullKeycloakPath

func (c *Client) GetFullKeycloakPath() string

func (*Client) GetIdentityProvider

func (c *Client) GetIdentityProvider(alias string, realmName string) (*v1alpha1.KeycloakIdentityProvider, 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) GetUser

func (c *Client) GetUser(userID, realmName string) (*v1alpha1.KeycloakAPIUser, error)

func (*Client) GetUserFederatedIdentities

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

func (*Client) ListAuthenticationExecutionsForFlow

func (c *Client) ListAuthenticationExecutionsForFlow(flowAlias, realmName string) ([]*v1alpha1.AuthenticationExecutionInfo, 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) ListIdentityProviders

func (c *Client) ListIdentityProviders(realmName string) ([]*v1alpha1.KeycloakIdentityProvider, 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) ListUsers

func (c *Client) ListUsers(realmName string) ([]*v1alpha1.KeycloakAPIUser, 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) UpdateAuthenticatorConfig

func (c *Client) UpdateAuthenticatorConfig(authenticatorConfig *v1alpha1.AuthenticatorConfig, 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) UpdateIdentityProvider

func (c *Client) UpdateIdentityProvider(specIdentityProvider *v1alpha1.KeycloakIdentityProvider, realmName string) error

func (*Client) UpdatePassword

func (c *Client) UpdatePassword(user *v1alpha1.KeycloakAPIUser, realmName, newPass string) error

func (*Client) UpdateRealm

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

func (*Client) UpdateUser

func (c *Client) UpdateUser(specUser *v1alpha1.KeycloakAPIUser, realmName string) 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.ExternalKeycloak
	ServiceAccountUserState *UserState
}

func NewClientState

func NewClientState(context context.Context, realm *kc.KeycloakRealm, keycloak kc.ExternalKeycloak) *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) ApplyOverrides

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

Delete a realm using the keycloak api

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 runtime.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) CreateUser

func (i *ClusterActionRunner) CreateUser(obj *v1alpha1.KeycloakUser, realm string) error

func (*ClusterActionRunner) Delete

func (i *ClusterActionRunner) Delete(obj runtime.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) DeleteUser

func (i *ClusterActionRunner) DeleteUser(id, realm string) error

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 runtime.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

func (*ClusterActionRunner) UpdateUser

func (i *ClusterActionRunner) UpdateUser(obj *v1alpha1.KeycloakUser, realm string) error

type ClusterState

type ClusterState struct {
	KeycloakAdminSecret *v1.Secret
}

func NewClusterState

func NewClusterState() *ClusterState

func (*ClusterState) Read

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

type ConfigureRealmAction

type ConfigureRealmAction struct {
	Ref *v1alpha1.KeycloakRealm
	Msg string
}

func (ConfigureRealmAction) Run

func (i ConfigureRealmAction) Run(runner ActionRunner) (string, 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 CreateRealmAction

type CreateRealmAction struct {
	Ref *v1alpha1.KeycloakRealm
	Msg string
}

func (CreateRealmAction) Run

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

type CreateUserAction

type CreateUserAction struct {
	Ref   *v1alpha1.KeycloakUser
	Realm string
	Msg   string
}

func (CreateUserAction) Run

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

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 DeleteRealmAction

type DeleteRealmAction struct {
	Ref *v1alpha1.KeycloakRealm
	Msg string
}

func (DeleteRealmAction) Run

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

type DeleteUserAction

type DeleteUserAction struct {
	ID    string
	Realm string
	Msg   string
}

func (DeleteUserAction) Run

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

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 runtime.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 runtime.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 runtime.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.ExternalKeycloak) (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)
	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

	CreateUser(user *v1alpha1.KeycloakAPIUser, realmName string) (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)
	UpdatePassword(user *v1alpha1.KeycloakAPIUser, realmName, newPass string) error
	FindUserByEmail(email, realm string) (*v1alpha1.KeycloakAPIUser, error)
	FindUserByUsername(name, realm string) (*v1alpha1.KeycloakAPIUser, error)
	GetUser(userID, realmName string) (*v1alpha1.KeycloakAPIUser, error)
	UpdateUser(specUser *v1alpha1.KeycloakAPIUser, realmName string) error
	DeleteUser(userID, realmName string) error
	ListUsers(realmName string) ([]*v1alpha1.KeycloakAPIUser, error)

	CreateIdentityProvider(identityProvider *v1alpha1.KeycloakIdentityProvider, realmName string) (string, error)
	GetIdentityProvider(alias, realmName string) (*v1alpha1.KeycloakIdentityProvider, error)
	UpdateIdentityProvider(specIdentityProvider *v1alpha1.KeycloakIdentityProvider, realmName string) error
	DeleteIdentityProvider(alias, realmName string) error
	ListIdentityProviders(realmName string) ([]*v1alpha1.KeycloakIdentityProvider, 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

	ListAuthenticationExecutionsForFlow(flowAlias, realmName string) ([]*v1alpha1.AuthenticationExecutionInfo, error)

	CreateAuthenticatorConfig(authenticatorConfig *v1alpha1.AuthenticatorConfig, realmName, executionID string) (string, error)
	GetAuthenticatorConfig(configID, realmName string) (*v1alpha1.AuthenticatorConfig, error)
	UpdateAuthenticatorConfig(authenticatorConfig *v1alpha1.AuthenticatorConfig, realmName string) error
	DeleteAuthenticatorConfig(configID, realmName string) error

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

type LocalConfigKeycloakFactory

type LocalConfigKeycloakFactory struct {
}

func (*LocalConfigKeycloakFactory) AuthenticatedClient

func (i *LocalConfigKeycloakFactory) AuthenticatedClient(kc v1alpha1.ExternalKeycloak, 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.ExternalKeycloak
}

func NewRealmState

func NewRealmState(context context.Context, keycloak kc.ExternalKeycloak) *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 UpdateUserAction

type UpdateUserAction struct {
	Ref   *v1alpha1.KeycloakUser
	Realm string
	Msg   string
}

func (UpdateUserAction) Run

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

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.ExternalKeycloak
	Context              context.Context
}

func NewUserState

func NewUserState(keycloak v1alpha1.ExternalKeycloak) *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) Read

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

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