utils

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MinRsaPublicKeyBits = 2048

Variables

View Source
var ErrApplicationKeyNotFound = fmt.Errorf("application key: %w", ErrHttpNotFound)
View Source
var ErrApplicationNotFound = fmt.Errorf("application: %w", ErrHttpNotFound)
View Source
var ErrCredentialNotFound = fmt.Errorf("credential: %w", ErrHttpNotFound)
View Source
var (
	ErrDecodingToken = errors.New("error decoding token")
)
View Source
var ErrFileNotFoud = fmt.Errorf("file: %w", ErrHttpNotFound)
View Source
var ErrGroupNotFound = fmt.Errorf("group: %w", ErrHttpNotFound)
View Source
var ErrHttpBadRequest = errors.New("bad request")
View Source
var ErrHttpConflict = errors.New("conflict")
View Source
var ErrHttpNotFound = errors.New("not found")
View Source
var ErrHttpServiceUnavailable = errors.New("service unavailable")
View Source
var ErrHttpUnauthorized = errors.New("unauthorized")
View Source
var ErrIdentityProviderExists = fmt.Errorf("identity provider already exists: %w", ErrHttpConflict)
View Source
var ErrIdentityProviderNotFound = fmt.Errorf("identity provider: %w", ErrHttpNotFound)
View Source
var ErrInvalidUuid = fmt.Errorf("invalid uuid: %w", ErrHttpBadRequest)
View Source
var ErrPasswordRuleNotFound = fmt.Errorf("password rule: %w", ErrHttpNotFound)
View Source
var ErrProjectNotFound = fmt.Errorf("project: %w", ErrHttpNotFound)
View Source
var ErrRegistrationNotEnabled = fmt.Errorf("registration is not enabled: %w", ErrHttpBadRequest)
View Source
var ErrResourceServerNotFound = fmt.Errorf("resource server: %w", ErrHttpNotFound)
View Source
var ErrResourceServerScopeNotFound = fmt.Errorf("resource server scope: %w", ErrHttpNotFound)
View Source
var ErrRoleNotFound = fmt.Errorf("role: %w", ErrHttpNotFound)
View Source
var ErrSessionNotFound = fmt.Errorf("session: %w", ErrHttpNotFound)
View Source
var ErrTemplateNotFound = fmt.Errorf("template: %w", ErrHttpNotFound)
View Source
var ErrUserApplicationMetadataNotFound = fmt.Errorf("user application metadata: %w", ErrHttpNotFound)
View Source
var ErrUserNotFound = fmt.Errorf("user: %w", ErrHttpNotFound)
View Source
var ErrVirtualServerNotFound = fmt.Errorf("virtual server: %w", ErrHttpNotFound)

Functions

func CheapCompareHash

func CheapCompareHash(input string, hash string) bool

func CheapHash

func CheapHash(input string) string

func CompareHash

func CompareHash(password string, hashedPassword string) bool

func EmptyIfNil

func EmptyIfNil[T any](input []T) []T

func GetSecureRandomBytes

func GetSecureRandomBytes(length int) []byte

func HandleHttpError

func HandleHttpError(w http.ResponseWriter, err error)

func HashPassword

func HashPassword(password string) string

func JsonMergePatch

func JsonMergePatch(base map[string]any, patch map[string]any) map[string]any

func MapPtr

func MapPtr[TIn any, TOut any](v *TIn, mapping func(TIn) TOut) *TOut

func MapSlice

func MapSlice[T any, R any](input []T, fn func(T) R) []R

func NilIfZero

func NilIfZero[T comparable](v T) *T

func PanicOnError

func PanicOnError(f func() error, msg string)

func ParseAndValidatePublicKeyPem added in v0.6.3

func ParseAndValidatePublicKeyPem(publicKeyPem string) (any, error)

func ParsePublicKeyPem added in v0.6.3

func ParsePublicKeyPem(publicKeyPem string) (any, error)

func Ptr

func Ptr[T any](v T) *T

func TrimSpace

func TrimSpace(s *string) *string

func TypeOf

func TypeOf[T any]() reflect.Type

func Unwrap

func Unwrap[T any](t T, err error) T

Unwrap returns the value t if err is nil, otherwise it panics. This helper is intended for use in test scenarios or one-off scripts where immediate failure is desired on error. Do not use in production code.

func ValidateDto

func ValidateDto(s any) error

func ValidatePublicKey added in v0.6.3

func ValidatePublicKey(publicKey any) error

func Zero

func Zero[T any]() T

func ZeroIfNil

func ZeroIfNil[T comparable](v *T) T

Types

type SplitToken

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

func DecodeSplitToken

func DecodeSplitToken(base64Token string) (SplitToken, error)

func NewSplitToken

func NewSplitToken(id string, secret string) SplitToken

func (*SplitToken) Encode

func (t *SplitToken) Encode() string

func (*SplitToken) Id

func (t *SplitToken) Id() string

func (*SplitToken) Secret

func (t *SplitToken) Secret() string

Jump to

Keyboard shortcuts

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