toolbox

package
v2.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfigKeyNotFound   = errors.New("component config key not found")
	ErrInvalidConfigFormat = errors.New("invalid config encoding")
)

Errors definition

Functions

func ContextWithForwarded added in v2.16.0

func ContextWithForwarded(ctx context.Context, internalURL *url.URL, externalURL *url.URL) context.Context

ContextWithForwarded returns a context that allows http client to use a Forwarded header

func NewConfig added in v2.11.0

func NewConfig(confUnmarshal ConfigurationProvider) (keycloak.Config, error)

NewConfig returns a Keycloak configuration

func NewKeycloakURIProvider

func NewKeycloakURIProvider(entries map[string]string, defaultKey string) (keycloak.KeycloakURIProvider, error)

NewKeycloakURIProvider creates a Keycloak URI provider

func NewKeycloakURIProviderFromArray

func NewKeycloakURIProviderFromArray(uris []string) (keycloak.KeycloakURIProvider, error)

NewKeycloakURIProviderFromArray creates a Keycloak URI provider

Types

type ComponentConfig added in v2.14.0

type ComponentConfig struct {
	ProviderType string `mapstructure:"provider-type"`
	ProviderID   string `mapstructure:"provider-id"`
	ConfigName   string `mapstructure:"config-name"`
}

ComponentConfig struct

type ComponentConfigKeyValue added in v2.14.0

type ComponentConfigKeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

ComponentConfigKeyValue struct

type ComponentTool added in v2.14.0

type ComponentTool interface {
	FindComponent(components []keycloak.ComponentRepresentation) *keycloak.ComponentRepresentation
	InitializeComponent(realmName string, idpID string, initial any) (keycloak.ComponentRepresentation, error)
	GetComponentEntry(comp *keycloak.ComponentRepresentation, key string, out any) error
	UpdateComponentEntry(comp *keycloak.ComponentRepresentation, key string, value any) error
	DeleteComponentEntry(comp *keycloak.ComponentRepresentation, key string) (bool, error)

	GetProviderType() string
}

ComponentTool interface

func NewComponentTool added in v2.14.0

func NewComponentTool(config ComponentConfig) ComponentTool

NewComponentTool creates

type ConfigurationProvider added in v2.11.0

type ConfigurationProvider func(target any) error

ConfigurationProvider interface

type GenericComponentTool added in v2.14.0

type GenericComponentTool struct {
	ProviderType string
	ProviderID   string
	ConfigName   string
}

GenericComponentTool struct

func (*GenericComponentTool) DeleteComponentEntry added in v2.14.0

func (ct *GenericComponentTool) DeleteComponentEntry(comp *keycloak.ComponentRepresentation, key string) (bool, error)

DeleteComponentEntry deletes a component entry

func (*GenericComponentTool) FindComponent added in v2.14.0

FindComponent searches a component

func (*GenericComponentTool) GetComponentEntry added in v2.14.0

func (ct *GenericComponentTool) GetComponentEntry(comp *keycloak.ComponentRepresentation, key string, out any) error

GetComponentEntry decodes a stored JSON value into the provided struct.

func (*GenericComponentTool) GetProviderType added in v2.14.0

func (ct *GenericComponentTool) GetProviderType() string

GetProviderType returns the provider type

func (*GenericComponentTool) InitializeComponent added in v2.14.0

func (ct *GenericComponentTool) InitializeComponent(parentID string, idpID string, initial any) (keycloak.ComponentRepresentation, error)

InitializeComponent initializes a component

func (*GenericComponentTool) UpdateComponentEntry added in v2.14.0

func (ct *GenericComponentTool) UpdateComponentEntry(comp *keycloak.ComponentRepresentation, key string, value any) error

UpdateComponentEntry encodes a struct and stores it under the key.

type InternalConfig added in v2.11.0

type InternalConfig struct {
	InternalURI    string            `mapstructure:"internal-uri"`
	RealmPublicURI map[string]string `mapstructure:"realm-public-uri-map"`
	DefaultKey     *string           `mapstructure:"default-key"`
	Timeout        time.Duration     `mapstructure:"timeout"`
}

InternalConfig struct

type IssuerManager

type IssuerManager interface {
	GetOidcVerifierProvider(issuer string) (OidcVerifierProvider, error)
}

IssuerManager provides URL according to a given context

func NewIssuerManager

func NewIssuerManager(config keycloak.Config) (IssuerManager, error)

NewIssuerManager creates a new URLProvider

type Logger

type Logger interface {
	Warn(ctx context.Context, keyvals ...any)
}

Logger interface for logging with level

type OAuth2Config added in v2.7.0

type OAuth2Config struct {
	Realm        *string `mapstructure:"realm"`
	Username     *string `mapstructure:"username"`
	Password     *string `mapstructure:"password"`
	ClientID     *string `mapstructure:"client-id"`
	ClientSecret *string `mapstructure:"client-secret"`
}

OAuth2Config struct

func (*OAuth2Config) IsClientConfig added in v2.7.0

func (oac *OAuth2Config) IsClientConfig() bool

IsClientConfig checks if the config is a client config or a username/password one

type OidcTokenProvider

type OidcTokenProvider interface {
	ProvideToken(ctx context.Context) (string, error)
	ProvideTokenForRealm(ctx context.Context, realm string) (string, error)
}

OidcTokenProvider provides OIDC tokens

func NewOAuth2TokenProvider added in v2.7.0

func NewOAuth2TokenProvider(kcConfig keycloak.Config, oauth2Config OAuth2Config, logger Logger) OidcTokenProvider

NewOAuth2TokenProvider creates an OidcTokenProvider

func NewOidcTokenProvider

func NewOidcTokenProvider(config keycloak.Config, realm, username, password, clientID string, logger Logger) OidcTokenProvider

NewOidcTokenProvider creates an OidcTokenProvider

type OidcVerifier

type OidcVerifier interface {
	Verify(accessToken string) error
}

OidcVerifier is an interface for OIDC token verifiers

type OidcVerifierProvider

type OidcVerifierProvider interface {
	GetOidcVerifier(realm string) (OidcVerifier, error)
}

OidcVerifierProvider is an interface for a provider of OidcVerifier instances

func NewVerifierCache

func NewVerifierCache(internalURL *url.URL, externalURL *url.URL) OidcVerifierProvider

NewVerifierCache create an instance of OIDC verifier cache

type ProfileRetriever added in v2.6.1

type ProfileRetriever interface {
	GetRealm(accessToken string, realmName string) (keycloak.RealmRepresentation, error)
	GetUserProfile(accessToken string, realmName string) (keycloak.UserProfileRepresentation, error)
}

ProfileRetriever interface

type UserProfileCache added in v2.6.1

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

UserProfileCache struct

func NewUserProfileCache added in v2.6.1

func NewUserProfileCache(retriever ProfileRetriever, tokenProvider OidcTokenProvider) *UserProfileCache

NewUserProfileCache creates a UserProfileCache instance

func (*UserProfileCache) GetRealmUserProfile added in v2.6.1

func (upc *UserProfileCache) GetRealmUserProfile(ctx context.Context, realmName string) (keycloak.UserProfileRepresentation, error)

GetRealmUserProfile gets the realm users profile using the token provider provided when creating the UserProfileCache instance

func (*UserProfileCache) GetRealmUserProfileWithToken added in v2.6.1

func (upc *UserProfileCache) GetRealmUserProfileWithToken(accessToken string, realmName string) (keycloak.UserProfileRepresentation, error)

GetRealmUserProfileWithToken gets the realm users profile using the provided access token

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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