auth

package
v0.30.0-dev.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleAuthRequest

func HandleAuthRequest[AuthModel any](
	authHandler Handler[AuthModel],
	r *http.Request,
) (AuthModel, error)

HandleAuthRequest is a helper function that parses the parameters and calls the authentication function with the parsed parameters.

Types

type APIKeyAuthConfig

type APIKeyAuthConfig struct {
	Name        string
	FieldName   string
	In          oapi.In
	Description string
}

type APIKeyAuthHandlerFunc

type APIKeyAuthHandlerFunc[AuthModel any] func(ctx context.Context, apiKey string) (AuthModel, error)

APIKeyAuthHandlerFunc is a function that handles API key authentication. This is the function that should be implemented by the user. It should return the user model if the API key is valid, otherwise it should return an error.

type APIKeyAuthType

type APIKeyAuthType[AuthModel any] struct {
	Name        string
	FieldName   string
	In          oapi.In
	Description string
	Handler     APIKeyAuthHandlerFunc[AuthModel]
}

func (APIKeyAuthType[AuthModel]) GetDescription

func (t APIKeyAuthType[AuthModel]) GetDescription() string

func (APIKeyAuthType[AuthModel]) GetFieldName

func (t APIKeyAuthType[AuthModel]) GetFieldName() string

func (APIKeyAuthType[AuthModel]) GetFormat

func (t APIKeyAuthType[AuthModel]) GetFormat() string

func (APIKeyAuthType[AuthModel]) GetHandler

func (t APIKeyAuthType[AuthModel]) GetHandler() AuthHandlerFunc[AuthModel]

func (APIKeyAuthType[AuthModel]) GetIn

func (t APIKeyAuthType[AuthModel]) GetIn() oapi.In

func (APIKeyAuthType[AuthModel]) GetName

func (t APIKeyAuthType[AuthModel]) GetName() string

func (APIKeyAuthType[AuthModel]) GetType

func (t APIKeyAuthType[AuthModel]) GetType() openapiModels.AuthType

type AuthHandlerFunc

type AuthHandlerFunc[AuthModel any] func(r *http.Request) (AuthModel, error)

AuthHandlerFunc is a function that handles authentication for a route.

type BasicAuthConfig

type BasicAuthConfig struct {
	Name        string
	Description string
}

type BasicAuthHandlerFunc

type BasicAuthHandlerFunc[AuthModel any] func(ctx context.Context, username, password string) (AuthModel, error)

BasicAuthHandlerFunc is a function that handles basic auth. This is the function that should be implemented by the user. It should return the user model if the username and password are valid, otherwise it should return an error.

type BasicAuthType

type BasicAuthType[AuthModel any] struct {
	Name        string
	Description string
	Handler     BasicAuthHandlerFunc[AuthModel]
}

func (BasicAuthType[AuthModel]) GetDescription

func (t BasicAuthType[AuthModel]) GetDescription() string

func (BasicAuthType[AuthModel]) GetFieldName

func (t BasicAuthType[AuthModel]) GetFieldName() string

func (BasicAuthType[AuthModel]) GetFormat

func (t BasicAuthType[AuthModel]) GetFormat() string

func (BasicAuthType[AuthModel]) GetHandler

func (t BasicAuthType[AuthModel]) GetHandler() AuthHandlerFunc[AuthModel]

func (BasicAuthType[AuthModel]) GetIn

func (t BasicAuthType[AuthModel]) GetIn() oapi.In

func (BasicAuthType[AuthModel]) GetName

func (t BasicAuthType[AuthModel]) GetName() string

func (BasicAuthType[AuthModel]) GetType

func (t BasicAuthType[AuthModel]) GetType() openapiModels.AuthType

type BearerAuthConfig

type BearerAuthConfig struct {
	Name        string
	Format      string
	Description string
}

type BearerAuthHandlerFunc

type BearerAuthHandlerFunc[AuthModel any] func(ctx context.Context, token string) (AuthModel, error)

BearerAuthHandlerFunc is a function that handles bearer token authentication. This is the function that should be implemented by the user. It should return the user model if the token is valid, otherwise it should return an error.

type BearerAuthType

type BearerAuthType[AuthModel any] struct {
	Name        string
	Format      string
	Description string
	Handler     BearerAuthHandlerFunc[AuthModel]
}

func (BearerAuthType[AuthModel]) GetDescription

func (t BearerAuthType[AuthModel]) GetDescription() string

func (BearerAuthType[AuthModel]) GetFieldName

func (t BearerAuthType[AuthModel]) GetFieldName() string

func (BearerAuthType[AuthModel]) GetFormat

func (t BearerAuthType[AuthModel]) GetFormat() string

func (BearerAuthType[AuthModel]) GetHandler

func (t BearerAuthType[AuthModel]) GetHandler() AuthHandlerFunc[AuthModel]

func (BearerAuthType[AuthModel]) GetIn

func (t BearerAuthType[AuthModel]) GetIn() oapi.In

func (BearerAuthType[AuthModel]) GetName

func (t BearerAuthType[AuthModel]) GetName() string

func (BearerAuthType[AuthModel]) GetType

func (t BearerAuthType[AuthModel]) GetType() openapiModels.AuthType

type Handler

type Handler[AuthModel any] interface {
	GetType() openapiModels.AuthType
	GetName() string
	GetFieldName() string
	GetFormat() string
	GetDescription() string
	GetIn() oapi.In
	GetHandler() AuthHandlerFunc[AuthModel]
}

func APIKeyAuth

func APIKeyAuth[AuthModel any](
	handler APIKeyAuthHandlerFunc[AuthModel],
	config APIKeyAuthConfig,
) Handler[AuthModel]

APIKeyAuth creates an API key auth handler with configuration

func BasicAuth

func BasicAuth[AuthModel any](
	handler BasicAuthHandlerFunc[AuthModel],
	config BasicAuthConfig,
) Handler[AuthModel]

BasicAuth creates a basic auth handler with configuration

func BearerAuth

func BearerAuth[AuthModel any](
	handler BearerAuthHandlerFunc[AuthModel],
	config BearerAuthConfig,
) Handler[AuthModel]

BearerAuth creates a bearer auth handler with configuration

func SessionCookieAuth

func SessionCookieAuth[AuthModel any](
	handler SessionCookieAuthHandlerFunc[AuthModel],
	config SessionCookieAuthConfig[AuthModel],
) Handler[AuthModel]

SessionCookieAuth creates a session cookie auth handler with configuration

type SessionCookieAuthConfig

type SessionCookieAuthConfig[AuthModel any] struct {
	CookieName  string
	Description string
}

type SessionCookieAuthHandlerFunc

type SessionCookieAuthHandlerFunc[AuthModel any] func(ctx context.Context, cookie string) (AuthModel, error)

SessionCookieAuthHandlerFunc is a function that handles session cookie authentication. This is the function that should be implemented by the user. It should return the user model if the API key is valid, otherwise it should return an error.

type SessionCookieAuthType

type SessionCookieAuthType[AuthModel any] struct {
	CookieName  string
	Description string
	Handler     SessionCookieAuthHandlerFunc[AuthModel]
}

func (SessionCookieAuthType[AuthModel]) GetDescription

func (t SessionCookieAuthType[AuthModel]) GetDescription() string

func (SessionCookieAuthType[AuthModel]) GetFieldName

func (t SessionCookieAuthType[AuthModel]) GetFieldName() string

func (SessionCookieAuthType[AuthModel]) GetFormat

func (t SessionCookieAuthType[AuthModel]) GetFormat() string

func (SessionCookieAuthType[AuthModel]) GetHandler

func (t SessionCookieAuthType[AuthModel]) GetHandler() AuthHandlerFunc[AuthModel]

func (SessionCookieAuthType[AuthModel]) GetIn

func (t SessionCookieAuthType[AuthModel]) GetIn() oapi.In

func (SessionCookieAuthType[AuthModel]) GetName

func (t SessionCookieAuthType[AuthModel]) GetName() string

func (SessionCookieAuthType[AuthModel]) GetType

func (t SessionCookieAuthType[AuthModel]) GetType() openapiModels.AuthType

Jump to

Keyboard shortcuts

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