clientreg

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package oidc provides a client for OIDC Dynamic Client Registration (RFC 7591/7592).

Index

Constants

View Source
const (
	TokenEndpointAuthMethodNone              = "none"
	TokenEndpointAuthMethodClientSecretPost  = "client_secret_post"
	TokenEndpointAuthMethodClientSecretBasic = "client_secret_basic"
)
View Source
const (
	GrantTypeAuthorizationCode = "authorization_code"
	GrantTypeRefreshToken      = "refresh_token"
	GrantTypeClientCredentials = "client_credentials"
	GrantTypeImplicit          = "implicit"
)

Variables

View Source
var ErrNoRegistrationURI = errors.New("oidc: registration client URI is required")
View Source
var ErrNoTokenProvider = errors.New("oidc: token provider is required for this operation")

Functions

func ClientIDFromContext

func ClientIDFromContext(ctx context.Context) string

func IsNotFound

func IsNotFound(err error) bool

func IsUnauthorized

func IsUnauthorized(err error) bool

func WithClientID

func WithClientID(ctx context.Context, clientID string) context.Context

Types

type Client

type Client interface {
	Register(ctx context.Context, registrationEndpoint string, metadata ClientMetadata) (ClientInformation, error)
	Read(ctx context.Context, clientID, registrationClientURI, registrationAccessToken string) (ClientInformation, error)
	Update(ctx context.Context, registrationClientURI, registrationAccessToken string, metadata ClientMetadata) (ClientInformation, error)
	Delete(ctx context.Context, clientID, registrationClientURI, registrationAccessToken string) error
}

func NewClient

func NewClient(opts ...Option) Client

type ClientInformation

type ClientInformation struct {
	ClientID                string `json:"client_id"`
	ClientSecret            string `json:"client_secret,omitempty"`
	ClientIDIssuedAt        int64  `json:"client_id_issued_at,omitempty"`
	ClientSecretExpiresAt   int64  `json:"client_secret_expires_at,omitempty"`
	RegistrationAccessToken string `json:"registration_access_token,omitempty"`
	RegistrationClientURI   string `json:"registration_client_uri,omitempty"`
	ClientMetadata
}

type ClientMetadata

type ClientMetadata struct {
	ClientID                string   `json:"client_id,omitempty"`
	ClientName              string   `json:"client_name,omitempty"`
	RedirectURIs            []string `json:"redirect_uris,omitempty"`
	GrantTypes              []string `json:"grant_types,omitempty"`
	ResponseTypes           []string `json:"response_types,omitempty"`
	TokenEndpointAuthMethod string   `json:"token_endpoint_auth_method,omitempty"`
	PostLogoutRedirectURIs  []string `json:"post_logout_redirect_uris,omitempty"`
	Scope                   string   `json:"scope,omitempty"`
	Contacts                []string `json:"contacts,omitempty"`
	LogoURI                 string   `json:"logo_uri,omitempty"`
	ClientURI               string   `json:"client_uri,omitempty"`
	PolicyURI               string   `json:"policy_uri,omitempty"`
	TOSURI                  string   `json:"tos_uri,omitempty"`
	JWKSURI                 string   `json:"jwks_uri,omitempty"`
	SoftwareID              string   `json:"software_id,omitempty"`
	SoftwareVersion         string   `json:"software_version,omitempty"`
}

type HTTPError

type HTTPError struct {
	StatusCode int
	Body       string
	Operation  OperationType
}

func IsHTTPError

func IsHTTPError(err error) (*HTTPError, bool)

func NewHTTPError

func NewHTTPError(statusCode int, body string, operation OperationType) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

type OperationType

type OperationType string
const (
	OperationRegister OperationType = "register"
	OperationRead     OperationType = "read"
	OperationUpdate   OperationType = "update"
	OperationDelete   OperationType = "delete"
)

type Option

type Option func(*clientOptions)

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

func WithTokenProvider

func WithTokenProvider(p TokenProvider) Option

type RetryTransport

type RetryTransport struct {
	Base           http.RoundTripper
	TokenRefresher TokenRefresher
}

RetryTransport wraps an http.RoundTripper and retries requests on 401 after refreshing the authentication token via TokenRefresher.

func NewRetryTransport

func NewRetryTransport(base http.RoundTripper, refresher TokenRefresher) *RetryTransport

func (*RetryTransport) RoundTrip

func (t *RetryTransport) RoundTrip(req *http.Request) (*http.Response, error)

type TokenProvider

type TokenProvider interface {
	TokenForRegistration(ctx context.Context) (string, error)
}

type TokenRefresher

type TokenRefresher interface {
	RefreshToken(ctx context.Context, clientID string) (newToken string, err error)
}

Directories

Path Synopsis
Package keycloak provides Keycloak-specific extensions for Dynamic Client Registration.
Package keycloak provides Keycloak-specific extensions for Dynamic Client Registration.

Jump to

Keyboard shortcuts

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