keycloak

package module
v0.0.0-...-70c9aed Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWKS

type JWKS struct {
	Keys []struct {
		Kid string `json:"kid"`
		Kty string `json:"kty"`
		Alg string `json:"alg"`
		N   string `json:"n"` // Modulus
		E   string `json:"e"` // Exponent
	} `json:"keys"`
}

type KeyCloakConfig

type KeyCloakConfig struct {
	ClientID     string
	ClientSecret string
	Url          string
	Realm        string
}

type KeycloakModule

type KeycloakModule struct {
	Client           *gocloak.GoCloak
	ClientID         string
	ClientSecret     string
	Realm            string
	AllowedAudiences []string
	JWKSURL          string
	PublicKey        *rsa.PublicKey
}

func NewKeycloakModule

func NewKeycloakModule(config KeyCloakConfig, allowedAudiences []string) (*KeycloakModule, error)

NewKeycloakModule initializes the Keycloak module

func (*KeycloakModule) Middleware

func (km *KeycloakModule) Middleware(requiredRole string) gin.HandlerFunc

Middleware provides a Gin middleware for token validation

func (*KeycloakModule) ValidateToken

func (km *KeycloakModule) ValidateToken(ctx context.Context, token string) (*gocloak.IntroSpectTokenResult, error)

ValidateToken validates an OAuth2 token using introspection

type ResourceAccess

type ResourceAccess struct {
	Roles []string `json:"roles"`
}

type ResourceAccessMap

type ResourceAccessMap map[string]ResourceAccess

Jump to

Keyboard shortcuts

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