Documentation
¶
Index ¶
- Constants
- Variables
- type Alternative
- type Marshaller
- type MasterRune
- type MidState
- type ObtainValue
- type Restriction
- func MakeRestriction(alternatives []Alternative) (*Restriction, error)
- func MakeRestrictionFromString(str string, allowIDField bool) (*Restriction, string, error)
- func MakeRestrictionsFromString(str string) ([]Restriction, error)
- func MustMakeRestrictionsFromString(str string) []Restriction
- func UniqueID(uniqueID any, version any) (*Restriction, error)
- type Rune
- func FromAuthCode(authcode []byte, restrictions []Restriction) (*Rune, error)
- func FromBase64(str string) (*Rune, error)
- func FromString(str string) (*Rune, error)
- func MakeRune(authbase []byte, uniqueid, version any, restrictions []Restriction) (*Rune, error)
- func MustGetFromBase64(str string) Rune
- func MustGetFromString(str string) Rune
- func (r *Rune) AddRestriction(restriction Restriction) error
- func (r *Rune) Check(vals map[string]any) error
- func (r *Rune) Evaluate(vals map[string]any) (bool, string)
- func (r *Rune) GetAuthCode() []byte
- func (r *Rune) GetRestricted(restrictions ...Restriction) (*Rune, error)
- func (r *Rune) GetUniqueID() int
- func (r *Rune) GetVersion() int
- func (r *Rune) MustGetRestrictedFromString(str string) Rune
- func (r *Rune) String() string
- func (r *Rune) ToBase64() string
- func (r *Rune) ToBase64Internal(trim bool) string
- type Sha256
- func (s *Sha256) AddPadding() error
- func (s *Sha256) GetLen() uint64
- func (s *Sha256) GetMidState() *MidState
- func (s *Sha256) GetSum() [OutputSize]byte
- func (s *Sha256) Reset()
- func (s *Sha256) SetLen(len uint64)
- func (s *Sha256) SetMidState(state *MidState) error
- func (s *Sha256) Write(p []byte) (nn int, err error)
Constants ¶
const ( // ChunkSize is chunk size in bytes ChunkSize = 64 // OutputSize is size of SHA256 checksum in bytes. OutputSize = 32 // Magic256 is the magic for SHA256 Magic256 = "sha\x03" )
Variables ¶
var ( // ErrTooLongSecret represents an error where secret was too long ErrTooLongSecret = errors.New("too long secret") // ErrTooShortSecret represents an error where secret was too short ErrTooShortSecret = errors.New("too short secret") ErrUnauthorizedRune = errors.New("unauthorized rune") )
var ( // ErrInvalidRune represents the error when rune could not be parsed ErrInvalidRune = errors.New("invalid rune") )
var KnownConditions = []string{"!", "=", "/", "^", "$", "~", "<", ">", "}", "{", "#"}
KnownConditions are the currently known conditions
Functions ¶
This section is empty.
Types ¶
type Alternative ¶
Alternative struct
func MakeAlternative ¶
MakeAlternative returns a new Alternative
func MakeAlternativeFromString ¶
func MakeAlternativeFromString(str string, allowIDField bool) (*Alternative, string, error)
MakeAlternativeFromString returns a new alternativee from a string
func (*Alternative) Evaluate ¶
func (a *Alternative) Evaluate(vals map[string]any) (bool, string)
Evaluate evaluates the alternative
func (*Alternative) IsUniqueID ¶
func (a *Alternative) IsUniqueID() bool
IsUniqueID - is this alternative the unique id
func (*Alternative) String ¶
func (a *Alternative) String() string
String returns a string representation
type Marshaller ¶
Marshaller is the interface for marshalling
type MasterRune ¶
MasterRune struct
func MakeMasterRune ¶
func MakeMasterRune(seedsecret []byte, uniqueid, version any, restrictions []Restriction) (*MasterRune, error)
MakeMasterRune creates a new master rune
func MustMakeMasterRune ¶
func MustMakeMasterRune(seedsecret []byte) MasterRune
MustMakeMasterRune is a helper constructor for creating a master rune
func (*MasterRune) Check ¶
func (r *MasterRune) Check(rune *Rune, vals map[string]any) error
Check checks rune
func (*MasterRune) IsRuneAuthorized ¶
func (r *MasterRune) IsRuneAuthorized(other *Rune) bool
IsRuneAuthorized check whether rune is authorized
type ObtainValue ¶
type ObtainValue func() any
ObtainValue is the signature of a function to get current value
type Restriction ¶
type Restriction struct {
Alternatives []Alternative
}
Restriction struct
func MakeRestriction ¶
func MakeRestriction(alternatives []Alternative) (*Restriction, error)
MakeRestriction from alternatives
func MakeRestrictionFromString ¶
func MakeRestrictionFromString(str string, allowIDField bool) (*Restriction, string, error)
MakeRestrictionFromString returns a new restriction from a string
func MakeRestrictionsFromString ¶
func MakeRestrictionsFromString(str string) ([]Restriction, error)
MakeRestrictionsFromString creates restrictionn from string representation
func MustMakeRestrictionsFromString ¶
func MustMakeRestrictionsFromString(str string) []Restriction
MustMakeRestrictionsFromString creates restrictionn from string representation
func UniqueID ¶
func UniqueID(uniqueID any, version any) (*Restriction, error)
UniqueID is a helper method to create an unique id restriction
func (*Restriction) Evaluate ¶
func (r *Restriction) Evaluate(vals map[string]any) (bool, string)
Evaluate evaluates the restriction
func (*Restriction) String ¶
func (r *Restriction) String() string
String returns a string representation
type Rune ¶
type Rune struct { Sha256 *Sha256 Restrictions []Restriction }
Rune struct
func FromAuthCode ¶
func FromAuthCode(authcode []byte, restrictions []Restriction) (*Rune, error)
FromAuthCode create a new rune from auth code
func FromBase64 ¶
FromBase64 returns a new rune from base64 encoded string representation
func FromString ¶
FromString returns a new rune from string representation
func MakeRune ¶
func MakeRune(authbase []byte, uniqueid, version any, restrictions []Restriction) (*Rune, error)
MakeRune creates a new rune
func MustGetFromBase64 ¶
MustGetFromBase64 returns a new rune from base64 representation
func MustGetFromString ¶
MustGetFromString returns a new rune from string representation
func (*Rune) AddRestriction ¶
func (r *Rune) AddRestriction(restriction Restriction) error
AddRestriction adds a new restriction
func (*Rune) GetRestricted ¶
func (r *Rune) GetRestricted(restrictions ...Restriction) (*Rune, error)
GetRestricted obtains a restricted rune
func (*Rune) GetUniqueID ¶
GetUniqueID gets the uniqueID of a rune or -1
func (*Rune) GetVersion ¶
GetVersion gets the version of a rune or default (0)
func (*Rune) MustGetRestrictedFromString ¶
MustGetRestrictedFromString obtains a restricted rune
func (*Rune) ToBase64Internal ¶
ToBase64Internal returns the base64 encoded representation of rune
type Sha256 ¶
type Sha256 struct {
// contains filtered or unexported fields
}
Sha256 struct
func (*Sha256) AddPadding ¶
AddPadding adds necessary padding at the end of a chunk
func (*Sha256) GetMidState ¶
GetMidState - get the internal state
func (*Sha256) SetMidState ¶
SetMidState - updates internal state