keycloak

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticator

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

Authenticator implements domain.Authenticator using OIDC/Keycloak JWT tokens

func NewAuthenticator

func NewAuthenticator(ctx context.Context, cfg *Config) (*Authenticator, error)

NewAuthenticator creates a new OIDC JWT authenticator for Keycloak

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(ctx context.Context, tokenString string) (*auth.Identity, error)

Authenticate extracts and validates the JWT token against Keycloak Returns nil if authentication fails

func (*Authenticator) Health

func (a *Authenticator) Health(ctx context.Context) error

Health checks if the Keycloak/OIDC provider is accessible

type Claims

type Claims struct {
	Role              string `json:"role,omitempty"`
	ParticipantID     string `json:"participant_id,omitempty"`
	AgentID           string `json:"agent_id,omitempty"`
	Name              string `json:"name,omitempty"`
	PreferredUsername string `json:"preferred_username,omitempty"`
	RealmAccess       struct {
		Roles []string `json:"roles"`
	} `json:"realm_access,omitempty"`
	ResourceAccess map[string]struct {
		Roles []string `json:"roles"`
	} `json:"resource_access,omitempty"`
}

Claims represents the custom claims structure from Keycloak JWT tokens

type Config

type Config struct {
	KeycloakURL    string `json:"keycloakUrl" env:"OAUTH_KEYCLOAK_URL"`
	Realm          string `json:"realm" env:"OAUTH_REALM"`
	ClientID       string `json:"clientId" env:"OAUTH_CLIENT_ID"`
	ClientSecret   string `json:"clientSecret" env:"OAUTH_CLIENT_SECRET"`
	JWKSCacheTTL   int    `json:"jwksCacheTtl" env:"OAUTH_JWKS_CACHE_TTL"`
	ValidateIssuer bool   `json:"validateIssuer" env:"OAUTH_VALIDATE_ISSUER"`
}

func (*Config) GetIssuer

func (c *Config) GetIssuer() string

GetIssuer returns the expected issuer for JWT tokens

func (*Config) GetJWKSURL

func (c *Config) GetJWKSURL() string

GetJWKSURL returns the JWKS endpoint URL for the Keycloak realm

Jump to

Keyboard shortcuts

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