server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 32 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	KeyUseSig = "sig"
)

Variables

View Source
var (
	ErrUnsupportedKeyUse         = errors.New("unsupported key use")
	ErrContainsInvalidCharacters = errors.New("invalid characters found, expecting letters, numbers, - or _")
)

Functions

func NewProvider

func NewProvider(logger *slog.Logger, options ProviderOptions) (*op.Provider, error)

Types

type Client

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

func NewClient

func NewClient(config configuration.ClientConfig) *Client

func (*Client) AccessTokenType

func (c *Client) AccessTokenType() op.AccessTokenType

AccessTokenType implements op.Client.

func (*Client) ApplicationType

func (c *Client) ApplicationType() op.ApplicationType

ApplicationType implements op.Client.

func (*Client) AuthMethod

func (c *Client) AuthMethod() oidc.AuthMethod

AuthMethod implements op.Client.

func (*Client) ClockSkew

func (c *Client) ClockSkew() time.Duration

ClockSkew implements op.Client.

func (*Client) DevMode

func (c *Client) DevMode() bool

DevMode implements op.Client.

func (*Client) GetID

func (c *Client) GetID() string

GetID implements op.Client.

func (*Client) GrantTypes

func (c *Client) GrantTypes() []oidc.GrantType

GrantTypes implements op.Client.

func (*Client) IDTokenLifetime

func (c *Client) IDTokenLifetime() time.Duration

IDTokenLifetime implements op.Client.

func (*Client) IDTokenUserinfoClaimsAssertion

func (c *Client) IDTokenUserinfoClaimsAssertion() bool

IDTokenUserinfoClaimsAssertion implements op.Client.

func (*Client) IsScopeAllowed

func (c *Client) IsScopeAllowed(scope string) bool

IsScopeAllowed implements op.Client.

func (*Client) LoginURL

func (c *Client) LoginURL(id string) string

LoginURL implements op.Client.

func (*Client) PostLogoutRedirectURIs

func (c *Client) PostLogoutRedirectURIs() []string

PostLogoutRedirectURIs implements op.Client.

func (*Client) RedirectURIs

func (c *Client) RedirectURIs() []string

RedirectURIs implements op.Client.

func (*Client) ResponseTypes

func (c *Client) ResponseTypes() []oidc.ResponseType

ResponseTypes implements op.Client.

func (*Client) RestrictAdditionalAccessTokenScopes

func (c *Client) RestrictAdditionalAccessTokenScopes() func(scopes []string) []string

RestrictAdditionalAccessTokenScopes implements op.Client.

func (*Client) RestrictAdditionalIdTokenScopes

func (c *Client) RestrictAdditionalIdTokenScopes() func(scopes []string) []string

RestrictAdditionalIdTokenScopes implements op.Client.

type CreateRefreshTokenArgs added in v0.1.2

type CreateRefreshTokenArgs struct {
	RefreshTokenID string
	ApplicationID  string
	RequestID      *string
	Scopes         []string
	Audience       []string
	ACR            string
	AMR            []string
	Subject        string
	AuthTime       time.Time
}

type CreateTokenArgs added in v0.1.2

type CreateTokenArgs struct {
	ApplicationID  string
	RequestID      *string
	Scopes         []string
	Audience       []string
	Subject        string
	RefreshTokenID *string
}

type ExchangeRefreshTokenArgs added in v0.1.2

type ExchangeRefreshTokenArgs struct {
	TokenRequest op.TokenExchangeRequest
}

type IssueTokensArgs added in v0.1.2

type IssueTokensArgs struct {
	TokenRequest      op.TokenRequest
	IssueRefreshToken bool
}

type ProviderOptions

type ProviderOptions struct {
	Key          [32]byte
	Storage      op.Storage
	ExtraOptions []op.Option
}

type Server

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

func NewServer

func NewServer(logger *slog.Logger, config *configuration.ConfigurationManager, db *sql.DB) (*Server, error)

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

type Storage

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

func NewStorage

func NewStorage(logger *slog.Logger, configMgr *configuration.ConfigurationManager, db *sql.DB, queries *query.Queries, users *users, clients *clients) (*Storage, error)

func (*Storage) AuthRequestByCode

func (s *Storage) AuthRequestByCode(ctx context.Context, code string) (op.AuthRequest, error)

func (*Storage) AuthRequestByID

func (s *Storage) AuthRequestByID(ctx context.Context, id string) (op.AuthRequest, error)

func (*Storage) AuthorizeClientIDSecret

func (s *Storage) AuthorizeClientIDSecret(ctx context.Context, clientID string, clientSecret string) error

func (*Storage) CreateAccessAndRefreshTokens

func (s *Storage) CreateAccessAndRefreshTokens(ctx context.Context, request op.TokenRequest, currentRefreshToken string) (accessTokenID string, newRefreshTokenID string, expiration time.Time, err error)

func (*Storage) CreateAccessToken

func (s *Storage) CreateAccessToken(ctx context.Context, request op.TokenRequest) (accessTokenID string, expiration time.Time, err error)

CreateAccessToken implements op.Storage.

func (*Storage) CreateAuthRequest

func (s *Storage) CreateAuthRequest(ctx context.Context, authReq *oidc.AuthRequest, userID string) (op.AuthRequest, error)

CreateAuthRequest implements op.Storage.

func (*Storage) DeleteAuthRequest

func (s *Storage) DeleteAuthRequest(ctx context.Context, id string) error

DeleteAuthRequest implements op.Storage.

func (*Storage) GetClientByClientID

func (s *Storage) GetClientByClientID(ctx context.Context, clientID string) (op.Client, error)

GetClientByClientID implements op.Storage.

func (*Storage) GetKeyByIDAndClientID

func (s *Storage) GetKeyByIDAndClientID(ctx context.Context, keyID string, clientID string) (*jose.JSONWebKey, error)

GetKeyByIDAndClientID implements op.Storage.

Clients have no registered public keys in the configuration, so a JWT assertion (private_key_jwt client authentication) cannot be verified.

func (*Storage) GetPrivateClaimsFromScopes

func (s *Storage) GetPrivateClaimsFromScopes(ctx context.Context, userID string, clientID string, scopes []string) (map[string]any, error)

GetPrivateClaimsFromScopes implements op.Storage.

These are the claims of JWT access tokens beyond the registered ones; the library has already removed the profile, email, phone and address scopes, so only custom claims are added.

func (*Storage) GetRefreshTokenInfo

func (s *Storage) GetRefreshTokenInfo(ctx context.Context, clientID string, token string) (userID string, tokenID string, err error)

GetRefreshTokenInfo implements op.Storage.

Refresh tokens are handed out as their ID.

func (*Storage) Health

func (s *Storage) Health(context.Context) error

Health implements op.Storage.

func (*Storage) KeySet

func (s *Storage) KeySet(ctx context.Context) ([]op.Key, error)

KeySet implements op.Storage.

func (*Storage) RevokeToken

func (s *Storage) RevokeToken(ctx context.Context, tokenOrTokenID string, userID string, clientID string) *oidc.Error

RevokeToken implements op.Storage.

tokenOrTokenID is an access token ID or a refresh token ID. Revoking a refresh token also revokes the access tokens issued with it. A token that does not exist is already revoked (RFC 7009 section 2.2).

func (*Storage) SaveAuthCode

func (s *Storage) SaveAuthCode(ctx context.Context, id string, code string) error

SaveAuthCode implements op.Storage.

func (*Storage) SetIntrospectionFromToken

func (s *Storage) SetIntrospectionFromToken(ctx context.Context, introspection *oidc.IntrospectionResponse, tokenID string, subject string, clientID string) error

SetIntrospectionFromToken implements op.Storage.

An error makes the token inactive. clientID is the resource server that asks: it must be in the token's audience.

func (*Storage) SetUserinfoFromRequest

func (s *Storage) SetUserinfoFromRequest(ctx context.Context, userinfo *oidc.UserInfo, token op.IDTokenRequest, scopes []string) error

SetUserinfoFromRequest implements op.CanSetUserinfoFromRequest: the claims of an ID token beyond the registered ones.

The library takes an ID token's acr only from an auth request, so an ID token refreshed from a refresh token gets the acr of its login here.

func (*Storage) SetUserinfoFromScopes

func (s *Storage) SetUserinfoFromScopes(ctx context.Context, userinfo *oidc.UserInfo, userID string, clientID string, scopes []string) error

func (*Storage) SetUserinfoFromToken

func (s *Storage) SetUserinfoFromToken(ctx context.Context, userinfo *oidc.UserInfo, tokenID string, subject string, origin string) error

SetUserinfoFromToken implements op.Storage.

func (*Storage) SignatureAlgorithms

func (s *Storage) SignatureAlgorithms(ctx context.Context) ([]jose.SignatureAlgorithm, error)

SignatureAlgorithms implements op.Storage.

func (*Storage) SigningKey

func (s *Storage) SigningKey(ctx context.Context) (op.SigningKey, error)

SigningKey implements op.Storage.

func (*Storage) TerminateSession

func (s *Storage) TerminateSession(ctx context.Context, userID string, clientID string) error

TerminateSession implements op.Storage.

idpzero keeps no browser session: every authorization request shows the login page. There is nothing to terminate, so RP-initiated logout only redirects.

func (*Storage) TokenRequestByRefreshToken

func (s *Storage) TokenRequestByRefreshToken(ctx context.Context, refreshTokenID string) (op.RefreshTokenRequest, error)

TokenRequestByRefreshToken implements op.Storage.

func (*Storage) ValidateJWTProfileScopes

func (s *Storage) ValidateJWTProfileScopes(ctx context.Context, userID string, scopes []string) ([]string, error)

ValidateJWTProfileScopes implements op.Storage.

It is only used by the JWT authorization grant (RFC 7523), which the provider does not enable.

Jump to

Keyboard shortcuts

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