Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Errors ErrRequestGrant = errors.New("Request does not match grant") )
var GrantStrings = map[Grant]string{ GrantUnknown: "unknown", GrantNone: "none", GrantSetOTP: "otp", GrantOTPValidate: "otp-validate", GrantOTPQR: "otp-qr", GrantUsersRefresh: "users-refresh", GrantKeysRegister: "keys-register", GrantOTP: "otp-all", GrantAuthenticated: "authenticated", }
GrantStrings map a basic access grant to a string representation.
Functions ¶
func ContainsGrant ¶
ContainsGrant return nil if the given request's context contains the given access grant. Otherwise an error is returned.
func IsCustomGrantsSet ¶
func IsCustomGrantsSet() bool
IsCustomGrantsSet is a conveniance function that returns true if custom user grants are set.
func SetCustomGrants ¶
SetCustomGrants sets additional user grants. The number of grants are limited by MaxCustomGrants. Using this function will remove any existing custom grants.
Types ¶
type Grant ¶
type Grant uint64
Grant represents an access grant for interacting with the authentication service.
const ( GrantDelimiter = "," MaxCustomGrants = 8 // bits // Grant Sections GrantSectionOTP Grant = 0x00000000000000FE GrantSectionUsers Grant = 0x000000000000FF00 GrantSectionKeys Grant = 0x0000000000FF0000 GrantSectionCustom Grant = 0x00000000FF000000 GrantSectionReserved Grant = 0xFFFFFFFF00000000 // No grants GrantUnknown Grant = 0x00000000 GrantNone Grant = 0x00000001 // OTP grants GrantSetOTP Grant = 0x00000002 GrantOTPValidate Grant = 0x00000004 GrantOTPQR Grant = 0x00000008 GrantOTP Grant = GrantSetOTP | GrantOTPValidate | GrantOTPQR // User grants GrantUsersRefresh Grant = 0x00000100 GrantUsers Grant = GrantUsersRefresh // Key grants GrantKeysRegister Grant = 0x00010000 GrantKeys Grant = GrantKeysRegister // Authenticated grants GrantAuthenticated Grant = GrantOTP | GrantUsers | GrantKeys // Reserved GrantFull Grant = 0xFFFFFFFE GrantMax Grant = 0xFFFFFFFF )
func GetCustomGrant ¶
GetCustomGrant returns the custom user grants currently set. Passing grant names will limit the result to those grants.
func ToGrant ¶
ToGrant returns an access grant for the given string. The string may be comma-separated to include multiple grants; E.g. "otp-validate,otp-qr".
func (Grant) Clean ¶
Clean returns a grant "cleansed" of unused/reserved bits. If the grant contains a self-terminating grant (E.g. GrantNone), that is returned instead.