Documentation
¶
Index ¶
- Constants
- Variables
- func ArrayDisjoint[T comparable](all []T, arr []T) []T
- func ArrayFindIndex[T comparable](all []T, fn func(item T) bool) int
- func ArrayFirst[T comparable](all []T, fn func(item T) bool) (found T, ok bool)
- func ArrayIncludes[T comparable](arr []T, item T) bool
- func ArrayIncludesAll[T comparable](all []T, arr []T) []T
- func ArrayRemove[T comparable](all []T, fn func(item T) bool) ([]T, bool)
- func ArrayRemoveAll[T comparable](arr []T, matches func(item T) bool) []T
- func ArrayRemoveIndex[T comparable](all []T, i int) []T
- func BoolFromP(b *bool) bool
- func BoolP(v bool) *bool
- func CheckAddress(address string, timeout time.Duration) bool
- func DeferableClose(ctx context.Context, closeme io.Closer)
- func Error(ctx context.Context, msg string, args ...interface{}) error
- func FromGabs(c *gabs.Container, v interface{}) error
- func GenerateId(prefix string, num int) string
- func GeneratePassword(passwordLength, minSpecialChar, minNum, minUpperCase int) string
- func GetFieldString(v interface{}, field string) string
- func GetID(ctx context.Context) string
- func GetLog(ctx context.Context) string
- func HashId(prefix string, parts ...string) string
- func Info(ctx context.Context, msg string, args ...interface{})
- func IsAdmin(user *UserJWT) bool
- func IsMap(suspect interface{}) bool
- func IsPointer(item interface{}) bool
- func IsZeroDate(dt strfmt.DateTime) bool
- func MapKey[T any](data map[string]T, key string, caseInsensitive bool) (T, bool)
- func MapKeyStr(data map[string]interface{}, key string, caseInsensitive bool) (string, bool)
- func NewByteReadCloser(data []byte) io.ReadCloser
- func NewInstance(v interface{}) interface{}
- func NewInstanceT[T any](v interface{}) (T, error)
- func NewMailer(ctx context.Context, provider string, cfg interface{})
- func NewT[T any]() (T, error)
- func SetFieldString(v interface{}, field string, value string)
- func ShutdownDocker(name string) error
- func StartContext() context.Context
- func StartDocker(name string, args []string, waitFor string) (bool, error)
- func StringFromP(s *string, missing string) string
- func StringP(s string) *string
- func ToGabs(item interface{}) (*gabs.Container, error)
- func UnmarshallT[T any](data []byte) (*T, error)
- func WaitForAddress(address string, timeout time.Duration) bool
- func Warn(ctx context.Context, msg string, args ...interface{})
- func WithID(ctx context.Context, ID string) context.Context
- func WithLogging(ctx context.Context) context.Context
- func WithUser(ctx context.Context, user *UserJWT) context.Context
- type AfterInterceptor
- type Attachment
- type BeforeInterceptor
- type ByteCounter
- type Email
- type Emailer
- type GroupManager
- type Logs
- type Mailer
- type MultiErrors
- func (e *MultiErrors) Append(err ...error)
- func (e *MultiErrors) AsErr() error
- func (e *MultiErrors) Clear()
- func (e *MultiErrors) Error() string
- func (e *MultiErrors) HasError() bool
- func (e *MultiErrors) Len() int
- func (e *MultiErrors) Line(w io.Writer)
- func (e *MultiErrors) List() []error
- func (e *MultiErrors) Merge(err *MultiErrors)
- func (e *MultiErrors) String() string
- func (e *MultiErrors) Tab(w io.Writer)
- type ProviderFactory
- type ProvidersRegistry
- type SeekingBuffer
- type Storage
- type TemplatedEmail
- type UserJWT
- type UserJWTRealmAccess
- type UserJWTResourceAccess
- type UserJWTResourceAccessAccount
- type UserManager
Constants ¶
View Source
const UserAnonymous = "ANONYMOUS"
Variables ¶
View Source
var DriverNotFoundError = errors.New("driver not found")
View Source
var EmailerProviders = NewProviderRegistry[Emailer]()
View Source
var GroupProviders = NewProviderRegistry[GroupManager]()
View Source
var IDKey userkey = userkey("id")
View Source
var InvalidConfigurationError = errors.New("invalid configuration object")
View Source
var Log logkey
View Source
var OperationNotImplementedError = errors.New("operation not implemented")
View Source
var UserKey userkey = userkey("userkey")
View Source
var UserProviders = NewProviderRegistry[UserManager]()
Functions ¶
func ArrayDisjoint ¶ added in v0.0.2
func ArrayDisjoint[T comparable](all []T, arr []T) []T
Determines the items that are NOT in this set and returns those
func ArrayFindIndex ¶ added in v0.0.2
func ArrayFindIndex[T comparable](all []T, fn func(item T) bool) int
func ArrayFirst ¶ added in v0.0.2
func ArrayFirst[T comparable](all []T, fn func(item T) bool) (found T, ok bool)
func ArrayIncludes ¶ added in v0.0.2
func ArrayIncludes[T comparable](arr []T, item T) bool
func ArrayIncludesAll ¶ added in v0.0.2
func ArrayIncludesAll[T comparable](all []T, arr []T) []T
Detemines the items that are in this set
func ArrayRemove ¶ added in v0.0.2
func ArrayRemove[T comparable](all []T, fn func(item T) bool) ([]T, bool)
func ArrayRemoveAll ¶ added in v0.0.2
func ArrayRemoveAll[T comparable](arr []T, matches func(item T) bool) []T
func ArrayRemoveIndex ¶ added in v0.0.2
func ArrayRemoveIndex[T comparable](all []T, i int) []T
func GenerateId ¶
Generate an ID. The ID will follow the pattern {prefix}-{id} where the id is a randomly generated string of alphanumeric characters
func GeneratePassword ¶
func GetFieldString ¶
func IsZeroDate ¶
func NewByteReadCloser ¶
func NewByteReadCloser(data []byte) io.ReadCloser
func NewInstance ¶
func NewInstance(v interface{}) interface{}
func NewInstanceT ¶
func SetFieldString ¶
func ShutdownDocker ¶ added in v0.0.2
func StartContext ¶
func StartDocker ¶ added in v0.0.2
func StringFromP ¶ added in v0.0.2
func UnmarshallT ¶
Types ¶
type AfterInterceptor ¶ added in v0.0.2
type Attachment ¶ added in v0.0.2
type BeforeInterceptor ¶ added in v0.0.2
type ByteCounter ¶
type ByteCounter struct {
// contains filtered or unexported fields
}
func NewByteCounter ¶
func NewByteCounter(stream io.ReadCloser) *ByteCounter
func (*ByteCounter) Close ¶
func (bc *ByteCounter) Close() error
func (*ByteCounter) Total ¶
func (bc *ByteCounter) Total() int64
type Email ¶ added in v0.0.2
type GroupManager ¶ added in v0.0.2
type GroupManager interface {
// List all the groups available
ListGroups(ctx context.Context, uid string) ([]*models.Group, error)
// Get all the groups for a single user
GetUserGroups(ctx context.Context, uid string) ([]*models.Group, error)
// Create a new Group
NewGroup(ctx context.Context, grp *models.Group) (*models.Group, error)
// Update a group. This is generally just the name of the group.
UpdateGroup(ctx context.Context, grp *models.Group) (bool, error)
// Get all the members of a group. This returns partial users only,
// typically just the user id, name and email fields
GetGroupMembers(ctx context.Context, grpId string) ([]*models.User, error)
// Remove members from a group
RemoveMembers(ctx context.Context, groupId string, userIds []string) error
// Add member(s) to a group
AddMembers(ctx context.Context, groupId string, userIds []string) error
}
Manages groups that users are part of.This can be seperate from the user manager or it can be the same.
type Mailer ¶ added in v0.0.2
type Mailer struct {
Before []BeforeInterceptor[Email]
After []AfterInterceptor[Email]
Emailer Emailer
}
var DefaultEmailer *Mailer
type MultiErrors ¶ added in v0.0.2
type MultiErrors struct {
// contains filtered or unexported fields
}
Error Type
func (*MultiErrors) Append ¶ added in v0.0.2
func (e *MultiErrors) Append(err ...error)
Append new error
func (*MultiErrors) AsErr ¶ added in v0.0.2
func (e *MultiErrors) AsErr() error
func (*MultiErrors) Error ¶ added in v0.0.2
func (e *MultiErrors) Error() string
func (*MultiErrors) HasError ¶ added in v0.0.2
func (e *MultiErrors) HasError() bool
Check if it has errors
func (*MultiErrors) Len ¶ added in v0.0.2
func (e *MultiErrors) Len() int
Total lent of error in list
func (*MultiErrors) Line ¶ added in v0.0.2
func (e *MultiErrors) Line(w io.Writer)
Display errors in Line format
func (*MultiErrors) List ¶ added in v0.0.2
func (e *MultiErrors) List() []error
List all error items
func (*MultiErrors) Merge ¶ added in v0.0.2
func (e *MultiErrors) Merge(err *MultiErrors)
Merge Errors
func (*MultiErrors) String ¶ added in v0.0.2
func (e *MultiErrors) String() string
Return Stringer interface
func (*MultiErrors) Tab ¶ added in v0.0.2
func (e *MultiErrors) Tab(w io.Writer)
Display errors in tabulated format
type ProviderFactory ¶
type ProvidersRegistry ¶
func NewProviderRegistry ¶
func NewProviderRegistry[T any]() *ProvidersRegistry[T]
func (*ProvidersRegistry[T]) New ¶
func (pr *ProvidersRegistry[T]) New(name string, cfg interface{}) (T, error)
func (*ProvidersRegistry[T]) Register ¶
func (pr *ProvidersRegistry[T]) Register(name string, fn func(cfg interface{}) (T, error))
type SeekingBuffer ¶
type SeekingBuffer struct {
// contains filtered or unexported fields
}
func NewSeekingBuffer ¶
func NewSeekingBuffer(b []byte) *SeekingBuffer
type TemplatedEmail ¶ added in v0.0.2
type TemplatedEmail struct {
Email
BodyTemplate *template.Template
SubjectTemplate *template.Template
InlineStyles bool
}
func (*TemplatedEmail) Render ¶ added in v0.0.2
func (t *TemplatedEmail) Render(ctx context.Context, data interface{}) (email *Email, err error)
type UserJWT ¶
type UserJWT struct {
EXP int64 `json:"exp"`
IAT int64 `json:"iat"`
AuthTime int64 `json:"auth_time"`
JTI string `json:"jti"`
ISS string `json:"iss"`
AUD string `json:"aud"`
TYP string `json:"typ"`
AZP string `json:"azp"`
Nonce string `json:"nonce"`
SessionState string `json:"session_state"`
ACR string `json:"acr"`
AllowedOrigins []string `json:"allowed-origins"`
RealmAccess *UserJWTRealmAccess `json:"realm_access"`
ResourceAccess *UserJWTResourceAccess `json:"resource_access"`
Scope string `json:"scope"`
EmailVerified bool `json:"email_verified"`
Name string `json:"name"`
PreferredUserName string `json:"preferred_username"`
GivenName string `json:"given_name"`
FamilyName string `json:"family_name"`
Email string `json:"email"`
UPN string `json:"upn"`
}
func GetUserFromRequest ¶
func GetUserInfoFromToken ¶
GetUserInfoFromToken Gets a user information from the JWT (Authorization Header)
func ParseToken ¶
ParseToken Parses the id token from cognito
func (*UserJWT) IsAuthenticated ¶
type UserJWTRealmAccess ¶
type UserJWTRealmAccess struct {
Roles []string `json:"roles"`
}
type UserJWTResourceAccess ¶
type UserJWTResourceAccess struct {
Account *UserJWTResourceAccessAccount `json:"account"`
}
type UserJWTResourceAccessAccount ¶
type UserJWTResourceAccessAccount struct {
Roles []string `json:"roles"`
}
type UserManager ¶ added in v0.0.2
type UserManager interface {
ListUsers(ctx context.Context, page interface{}, filter interface{}) ([]*models.User, interface{}, error)
// Retrieves a specific user.
GetUser(ctx context.Context, uid string) (*models.User, error)
// NewUser creates a new user with the given information and returns the new user with any additional
// fields populated
NewUser(ctx context.Context, newUser *models.User) (*models.User, error)
UpdateUser(ctx context.Context, usr *models.User) error
Enable(ctx context.Context, uid string) error
Disable(ctx context.Context, uid string) error
DeleteUser(ctx context.Context, uid string) error
}
User interface manager
Source Files
¶
Click to show internal directories.
Click to hide internal directories.