oauth

package
v3.6.5 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthClaims

type AuthClaims struct {
	Token *oauth2.Token `json:"token"`
	jwt.RegisteredClaims
	User model.User `json:"user"`
}

type Cache

type Cache interface {
	Load(ctx context.Context, key string) ([]byte, error)
	Store(ctx context.Context, key string, value any, ttl time.Duration) error
	Delete(ctx context.Context, keys ...string) error
}

type CreateHandler

type CreateHandler[T ProviderUser[I], I comparable] func(ctx context.Context, invite model.User, user T) (model.User, error)

type GetHandler

type GetHandler[I comparable] func(ctx context.Context, id I) (model.User, error)

type LinkHandler

type LinkHandler func(ctx context.Context, old, new model.User) error

type ProviderUser

type ProviderUser[I comparable] interface {
	GetID() I
}

type Service

type Service[T ProviderUser[I], I comparable] struct {
	// contains filtered or unexported fields
}

func New

func New[T ProviderUser[I], I comparable](name, getURL, onSuccessPath string, config oauth2.Config, cache Cache, storage Storage, linkHandler LinkHandler, createHandler CreateHandler[T, I], getHandler GetHandler[I], renderer *renderer.Service, cookie cookie.Service) Service[T, I]

func (Service[T, I]) Callback

func (s Service[T, I]) Callback(w http.ResponseWriter, r *http.Request)

func (Service[T, I]) GetUser

func (s Service[T, I]) GetUser(ctx context.Context, r *http.Request) (model.User, error)

func (Service[T, I]) Logout

func (s Service[T, I]) Logout(w http.ResponseWriter, r *http.Request)

func (Service[T, I]) Mux

func (s Service[T, I]) Mux(prefix string, mux *http.ServeMux)

func (Service[T, I]) OnUnauthorized

func (s Service[T, I]) OnUnauthorized(w http.ResponseWriter, r *http.Request, err error)

func (Service[T, I]) Register

func (s Service[T, I]) Register(w http.ResponseWriter, r *http.Request)

type State

type State struct {
	Verifier     string `json:"verifier"`
	Registration string `json:"registration"`
	Redirection  string `json:"redirect"`
}

type Storage

type Storage interface {
	DoAtomic(ctx context.Context, action func(context.Context) error) error

	GetInviteByToken(ctx context.Context, token string) (model.User, error)
	Delete(ctx context.Context, user model.User) error
	DeleteInvite(ctx context.Context, user model.User) error
}

Jump to

Keyboard shortcuts

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