auth

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package auth handles sever-side and client-side authentication

Index

Constants

View Source
const (
	ISADMIN = iota
	ISLOCAL
	ISKNOWN
	ISUNITED
	ISREGISTERED
)

Variables

This section is empty.

Functions

func NewService

func NewService(
	rdb *redis.Client,
	config core.Config,
	entity core.EntityService,
	domain core.DomainService,
	key core.KeyService,
	policy core.PolicyService,
) core.AuthService

NewService creates a new auth service

func Recaptcha

func Recaptcha(validator *recaptcha.ReCAPTCHA) echo.MiddlewareFunc

Recaptcha is a middleware factory that returns a middleware to verify reCAPTCHA challenges. It expects the challenge response in the "captcha" header and uses the provided validator. If verification is successful, it sets a flag in the context.

func ReceiveGatewayAuthPropagation

func ReceiveGatewayAuthPropagation(next echo.HandlerFunc) echo.HandlerFunc

ReceiveGatewayAuthPropagation is a middleware that receives authentication information propagated from a gateway via HTTP headers. It extracts requester type, ID, tags, domain, keychain, etc., and sets them in the context. This is typically used in internal services that sit behind an authenticating gateway.

func Restrict

func Restrict(principal Principal) echo.MiddlewareFunc

Restrict is a middleware factory that returns a middleware to restrict access based on the requester's principal type. It checks the requester type and tags stored in the context against the required principal level (e.g., ISADMIN, ISLOCAL).

Types

type Handler

type Handler interface {
	GetPassport(c echo.Context) error
}

Handler is the interface for handling HTTP requests

func NewHandler

func NewHandler(service core.AuthService) Handler

NewHandler creates a new handler

type Principal

type Principal int

Jump to

Keyboard shortcuts

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