auth

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitAuthentication

func InitAuthentication(auth *core.Authentication)

func Token

func Token() (string, error)

Types

type Context

type Context struct {
	Gin     *gin.Context
	Session *UserSession
	Log     *slog.Logger
	Config  any
	Token   string
}

func (*Context) BindParamsFromBody

func (c *Context) BindParamsFromBody(obj any) (err error)

func (*Context) BindParamsFromQuery

func (c *Context) BindParamsFromQuery(obj any) (err error)

func (*Context) GetCodeFromUrl

func (c *Context) GetCodeFromUrl() string

func (*Context) GetId2FromUrl

func (c *Context) GetId2FromUrl() (uint, error)

func (*Context) GetIdFromUrl

func (c *Context) GetIdFromUrl() (uint, error)

func (*Context) GetPagingParams

func (c *Context) GetPagingParams() (offset int, limit int, errV error)

func (*Context) GetParamAsBool

func (c *Context) GetParamAsBool(name string, defValue bool) (bool, error)

func (*Context) GetParamAsInt

func (c *Context) GetParamAsInt(name string, defValue int) (int, error)

func (*Context) GetParamAsString

func (c *Context) GetParamAsString(name string, defValue string) string

func (*Context) ReturnData

func (c *Context) ReturnData(contentType string, data []byte) error

func (*Context) ReturnError

func (c *Context) ReturnError(err error)

func (*Context) ReturnList

func (c *Context) ReturnList(result any, offset int, limit int, size int) error

func (*Context) ReturnObject

func (c *Context) ReturnObject(data any) error

type OidcController

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

func NewOidcController

func NewOidcController(authority string, client *http.Client, logger *slog.Logger, config any) *OidcController

func (*OidcController) Secure

func (oc *OidcController) Secure(h RestService, roles []role.Role) func(c *gin.Context)

type RestContext

type RestContext struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type RestService

type RestService func(c *Context)

type TokenResponse

type TokenResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Scope        string `json:"scope"`
}

type UserSession

type UserSession struct {
	SessionID  string
	Username   string
	OnBehalfOf string
	Name       string
	Surname    string
	Email      string
	IssuedAt   time.Time
	Expiry     time.Time
	Roles      map[role.Role]any
}

func (*UserSession) IsAdmin

func (us *UserSession) IsAdmin() bool

func (*UserSession) IsUserInRole

func (us *UserSession) IsUserInRole(roles []role.Role) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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