server

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxTokenRequestBody = 1 << 20

Variables

View Source
var (
	ErrClientNotFound = errors.New("orionis server: client not found")
	ErrUnauthorized   = errors.New("orionis server: unauthorized client")
)

Functions

This section is empty.

Types

type Builder

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

func FromConfig

func FromConfig(cfg Config) *Builder

func New

func New() *Builder

func (*Builder) AccessTokenTTL

func (b *Builder) AccessTokenTTL(ttl time.Duration) *Builder

func (*Builder) ActiveKID

func (b *Builder) ActiveKID(kid string) *Builder

func (*Builder) Build

func (b *Builder) Build() (*Server, error)

func (*Builder) Client

func (b *Builder) Client(client Client) *Builder

func (*Builder) Clients

func (b *Builder) Clients(clients ...Client) *Builder

func (*Builder) Clock

func (b *Builder) Clock(now func() time.Time) *Builder

func (*Builder) Issuer

func (b *Builder) Issuer(issuer string) *Builder

func (*Builder) MaxBody

func (b *Builder) MaxBody(size int64) *Builder

func (*Builder) Must

func (b *Builder) Must() *Server

func (*Builder) Signer

func (b *Builder) Signer(signer Signer) *Builder

func (*Builder) Signers

func (b *Builder) Signers(signers ...Signer) *Builder

func (*Builder) Store

func (b *Builder) Store(store ClientStore) *Builder

func (*Builder) TTL

func (b *Builder) TTL(ttl time.Duration) *Builder

type Client

type Client struct {
	ID               string   `json:"id"`
	Secrets          []string `json:"secrets,omitempty"`
	SecretSHA256Hex  []string `json:"secret_sha256_hex,omitempty"`
	AllowedAudiences []string `json:"allowed_audiences"`
	AllowedScopes    []string `json:"allowed_scopes"`
	DefaultScopes    []string `json:"default_scopes,omitempty"`
	Disabled         bool     `json:"disabled,omitempty"`
}

func NewClient

func NewClient(id string) Client

func (Client) Audience

func (c Client) Audience(audience string) Client

func (Client) Audiences

func (c Client) Audiences(audiences ...string) Client

func (Client) Defaults

func (c Client) Defaults(scopes ...string) Client

func (Client) Disable

func (c Client) Disable() Client

func (Client) Normalize

func (c Client) Normalize() Client

func (Client) Scope

func (c Client) Scope(scope string) Client

func (Client) Scopes

func (c Client) Scopes(scopes ...string) Client

func (Client) Secret

func (c Client) Secret(secret string) Client

func (Client) SecretSHA256

func (c Client) SecretSHA256(hexValue string) Client

func (Client) ValidateScopePolicy added in v0.3.0

func (c Client) ValidateScopePolicy() error

func (Client) VerifySecret

func (c Client) VerifySecret(secret string) bool

type ClientStore

type ClientStore interface {
	FindClient(ctx context.Context, id string) (Client, error)
}

type Config

type Config struct {
	Issuer              string
	Store               ClientStore
	Signers             []Signer
	ActiveKID           string
	AccessTokenTTL      time.Duration
	MaxTokenRequestBody int64

	Now func() time.Time

	Clients []Client
}

type MemoryClientStore

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

func MemoryStore

func MemoryStore(clients ...Client) *MemoryClientStore

func NewMemoryClientStore

func NewMemoryClientStore(clients ...Client) *MemoryClientStore

func (*MemoryClientStore) FindClient

func (s *MemoryClientStore) FindClient(ctx context.Context, id string) (Client, error)

func (*MemoryClientStore) Upsert

func (s *MemoryClientStore) Upsert(c Client)

type Server

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

func NewServer

func NewServer(cfg Config) (*Server, error)

func (*Server) DiscoveryHTTP

func (s *Server) DiscoveryHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) HealthHTTP

func (s *Server) HealthHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Issuer

func (s *Server) Issuer() string

func (*Server) JWKSHTTP

func (s *Server) JWKSHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) JWKSURI

func (s *Server) JWKSURI() string

func (*Server) TokenEndpoint

func (s *Server) TokenEndpoint() string

func (*Server) TokenHTTP

func (s *Server) TokenHTTP(w http.ResponseWriter, r *http.Request)

type Signer

type Signer interface {
	KeyID() string
	Algorithm() string
	Sign(claims *orionis.Claims) (string, error)
	PublicJWK() jwk.Key
}

Jump to

Keyboard shortcuts

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