oas

package
v1.0.33 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthenticated    = fiber.NewError(fiber.StatusUnauthorized, "unauthenticated")
	ErrMissingBearerToken = fiber.NewError(fiber.StatusUnauthorized, "missing bearer token")
)

Functions

func Authenticate

Authenticate returns a nil error and the AuthClaims info (if available) if the subject is authenticated or a

Types

type AuthClaims

type AuthClaims struct {
	Subject string
	Scopes  map[string]bool
}

AuthClaims contains claims that are included in OIDC standard claims. https://openid.net/specs/openid-connect-core-1_0.html#IDToken

type Authenticator

type Authenticator interface {
	// Authenticate returns a nil error and the AuthClaims info (if available) if the subject is authenticated or a
	// non-nil error with an appropriate error cause otherwise.
	Authenticate(requestContext context.Context) (*AuthClaims, error)

	// Close Cleans up the authenticator.
	Close()
}

Authenticator is an interface for authenticating a subject.

type AuthenticatorOpt

type AuthenticatorOpt func(*AuthenticatorOpts)

AuthenticatorOpt is a function that sets the configuration for the authenticator.

func WithBasicAuthSchema

func WithBasicAuthSchema(auth openapi3filter.AuthenticationFunc) AuthenticatorOpt

WithBasicSchema sets the basic authentication schema for the authenticator.

func WithBearerSchema

func WithBearerSchema(auth openapi3filter.AuthenticationFunc) AuthenticatorOpt

WithBearerSchema sets the bearer authentication schema for the authenticator.

func WithOIDCSchema

WithOIDCSchema sets the OIDC authentication schema for the authenticator.

func WithSchema

WithSchema sets the authentication schema for the authenticator.

type AuthenticatorOpts

type AuthenticatorOpts struct {
	Schemas map[string]openapi3filter.AuthenticationFunc
}

AuthenticatorOpts is a function that sets the configuration for the authenticator.

func DefaultAuthenticatorOpts

func DefaultAuthenticatorOpts() AuthenticatorOpts

DefaultAuthenticatorOpts returns the default authenticator options.

func (*AuthenticatorOpts) Configure

func (c *AuthenticatorOpts) Configure(opts ...AuthenticatorOpt)

Configure sets the configuration for the authenticator.

type NoopAuthenticator

type NoopAuthenticator struct{}

func (NoopAuthenticator) Authenticate

func (n NoopAuthenticator) Authenticate(requestContext context.Context) (*AuthClaims, error)

func (NoopAuthenticator) Close

func (n NoopAuthenticator) Close()

type OidcAuthenticator

type OidcAuthenticator interface {
	GetConfiguration() (*OidcConfig, error)
	GetKeys() (*keyfunc.JWKS, error)
}

OidcAuthenticator is an interface for OIDC authentication.

type OidcConfig

type OidcConfig struct {
	Issuer  string `json:"issuer"`
	JWKsURI string `json:"jwks_uri"`
}

OidcConfig contains authorization server metadata. See https://datatracker.ietf.org/doc/html/rfc8414#section-2

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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