frontdoor

package module
v0.0.0-...-ff58081 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2025 License: MIT Imports: 19 Imported by: 0

README

frontdoor

run natively:

DATA_DRIVER=sqlite3 DATA_SOURCE=db.sqlite go run ./service --initialize

run with Docker:

docker build -t no-magic-dev/frontdoor:latest .
docker run -it --env DATA_DRIVER=sqlite3 --env DATA_SOURCE=db.sqlite -p 8088 no-magic-dev/frontdoor:latest /bin/service --initialize

run with k8s:

docker build -t no-magic-dev/frontdoor:latest .
minikube start --driver=hyperkit --cpus 4 --memory 4096
minikube addons enable ingress
kubectl apply -f deployment/k8s.yaml
kubectl logs deployment/auth

Note the k8s ingress requires a host header -H "Host: auth.svc" to successfully pass requests to the underlying service.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthenticated = NewError("authentication required", http.StatusUnauthorized)
	ErrUnauthorized    = NewError("authorization required", http.StatusUnauthorized)
	ErrNotFound        = NewError("resource not found", http.StatusNotFound)
	ErrUnexpected      = NewError("unexpected error occurred", http.StatusInternalServerError)
	ErrBadRequest      = NewError("bad request", http.StatusBadRequest)
)

Functions

This section is empty.

Types

type Authentication

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

func NewAuthentication

func NewAuthentication(ctx context.Context, conn *sql.Conn) (*Authentication, error)

func (*Authentication) Close

func (authentication *Authentication) Close() error

func (*Authentication) Logout

func (authentication *Authentication) Logout() http.HandlerFunc

func (*Authentication) Middleware

func (authentication *Authentication) Middleware() func(route http.HandlerFunc) http.HandlerFunc

func (*Authentication) SignIn

func (authentication *Authentication) SignIn() http.HandlerFunc

func (*Authentication) SignUp

func (authentication *Authentication) SignUp() http.HandlerFunc

func (*Authentication) WhoAmI

func (authentication *Authentication) WhoAmI() http.HandlerFunc

type Authorization

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

func NewAuthorization

func NewAuthorization(ctx context.Context, conn *sql.Conn) (*Authorization, error)

func (*Authorization) Administrator

func (authorization *Authorization) Administrator(route http.HandlerFunc) http.HandlerFunc

func (*Authorization) Basic

func (authorization *Authorization) Basic(route http.HandlerFunc) http.HandlerFunc

func (*Authorization) Close

func (authorization *Authorization) Close() error

func (*Authorization) Grant

func (authorization *Authorization) Grant() http.HandlerFunc

func (*Authorization) Middleware

func (authorization *Authorization) Middleware(required Role) func(route http.HandlerFunc) http.HandlerFunc

func (*Authorization) Secure

func (authorization *Authorization) Secure(route http.HandlerFunc) http.HandlerFunc

type Error

type Error struct {
	Sev  error  `json:"-"`
	Msg  string `json:"error"`
	Code int    `json:"code"`
	Data any    `json:"-"`
}

func NewError

func NewError(message string, code int) Error

func (Error) Error

func (e Error) Error() string

func (Error) Include

func (e Error) Include(data any) Error

func (Error) Location

func (e Error) Location(skip int) string

func (Error) Respond

func (e Error) Respond(w http.ResponseWriter, r *http.Request)

func (Error) Severe

func (e Error) Severe(err error) Error

type ID

type ID [12]byte

func NewID

func NewID() (id ID, err error)

func ParseID

func ParseID(s string) (ID, error)

func (ID) Bytes

func (id ID) Bytes() []byte

func (ID) String

func (id ID) String() string

type Role

type Role int
const (
	Verified Role = 1 << iota
	Basic
	Admin
	Super
)

type RoleContextKey

type RoleContextKey struct{}

type UserContextKey

type UserContextKey struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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