Documentation
¶
Index ¶
- Variables
- func CheckoutMFA(userID uint64, extentionType string) (string, error)
- func ClearMFA(userID uint64, extentionType string) error
- func ConfirmMFA(userID uint64, extentionType string) error
- func CreateAffiliation(affiliation *Affiliation) error
- func DeleteTmpEntry(userID uint64, extentionType, indexKey string) error
- func EnabledMFA(userID uint64) ([]string, error)
- func InitMFA(userID uint64, extentionType, extentionData string) error
- func InsertTmpEntry(userID uint64, extentionType, indexKey, storedValue string) error
- func MFAEnabled(userID uint64, extentionType string) (bool, error)
- func ReadTmpEntry(userID uint64, extentionType, indexKey string) (string, error)
- func Setup(dbConn *sql.DB, tblPrefixOverride string)
- func UpdateMFA(userID uint64, extentionType, extentionData string) error
- func UpdateTmpEntry(userID uint64, extentionType, indexKey, storedValue string) error
- type Affiliation
- type MultiFactorAuthentication
- type Role
- type User
- func (user *User) CreateUser() error
- func (user *User) Info() (*UserInfo, error)
- func (user *User) NewUserInfo(info *UserInfo) error
- func (user *User) UpdateInfo(info *UserInfo) error
- func (user *User) UpdateUser() error
- func (user *User) UserEmailExists() (bool, error)
- func (user *User) WipeUserData() error
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAffiliationNameEmpty = errors.New("auth: affiliation name is empty") ErrAffiliationOwnerUserIDEmpty = errors.New("auth: affiliation owner user id is empty") ErrAffiliationStreetAddressEmpty = errors.New("auth: affiliation street address is empty") ErrAffiliationCityEmpty = errors.New("auth: affiliation city is empty") ErrAffiliationStateEmpty = errors.New("auth: affiliation state is empty") ErrAffiliationCountryISOEmpty = errors.New("auth: affiliation country iso is empty") ErrAffiliationZipCodeEmpty = errors.New("auth: affiliation zip code is empty") ErrAffiliationContactEmailEmpty = errors.New("auth: affiliation contact email is empty") )
Functions ¶
func CreateAffiliation ¶
func CreateAffiliation(affiliation *Affiliation) error
func DeleteTmpEntry ¶
Delete
func EnabledMFA ¶
func InsertTmpEntry ¶
*********** Temporary Database *********** Create
func ReadTmpEntry ¶
Read
func UpdateTmpEntry ¶
Update
Types ¶
type Affiliation ¶
type Affiliation struct {
Name string
ParentID uint64
OwnerUserID uint64 // must be a valid user id with a wallet (to be shared among users with permission)
StreetAddress string
Suite string
City string
State string
CountryISO string
ZipCode string
ContactEmail string
// contains filtered or unexported fields
}
func GetAffiliationByID ¶
func GetAffiliationByID(id uint64) (*Affiliation, error)
func (*Affiliation) Parent ¶
func (affiliation *Affiliation) Parent() (*Affiliation, error)
func (*Affiliation) UpdateAffiliation ¶
func (affiliation *Affiliation) UpdateAffiliation() error
type MultiFactorAuthentication ¶
type MultiFactorAuthentication interface {
Registered(userID uint64) bool
// Register associate a MFA credential to user
InitSignUp(userID uint64, username string) (map[string]interface{}, error)
CompleteSignUp(userID uint64, mfaConf map[string]string) error
// Challenge is called when user try to verify identity using the selected MFA.
NewChallenge(userID uint64) (map[string]interface{}, error)
SubmitChallenge(userID uint64, challengeResponse map[string]string) error
// Remove the MFA credential from the database
Remove(userID uint64) error
}
type Role ¶
type Role uint32
const ( /************ Global Role ************/ GLOBAL_EVALUATION_USER Role = 1 << iota // EVALUATION_USER may not order products GLOBAL_PRODUCTION_USER // PRODUCTION_USER may order products GLOBAL_INTERNAL_USER // STAGING_USER may order products free of charge GLOBAL_ADMIN // ADMIN owns all access to management interface /************ Exemptional Role ************/ EXEMPT_MARKETING_CONTACT // User won't be contacted for marketing purposes EXEMPT_BILLING_CONTACT // User won't be notified for billing updates EXEMPT_SUPPORT_CONTACT // User won't be notified for supporting case updates /************ Affiliation Role ************/ // Affiliations (enterprises) may purchase products and set them // to be shared by users AFFILIATION_ACCOUNT_USER // ACCOUNT_USER is a user belong to an enterprise AFFILIATION_ACCOUNT_ADMIN // ACCOUNT_ADMIN may create users and manage users (assigning roles, etc) AFFILIATION_PRODUCT_USER // PRODUCT_USER may only view(and use) products AFFILIATION_PRODUCT_ADMIN // PRODUCT_ADMIN may create and edit shared products AFFILIATION_BILLING_USER // BILLING_USER may purchase products with Affiliation-owned wallet AFFILIATION_BILLING_ADMIN // BILLING_ADMIN may deposit funds into Affiliation-owned wallet and view/manage associated products ROLELESS Role = 0 )
Known roles as unambiguous binary flags allowing cascading
func (Role) RemoveRole ¶
type User ¶
type User struct {
Email string `json:"email"`
Password string `json:"password"` // HMAC-Hashed
Role Role `json:"role"`
AffiliationID uint64 `json:"affiliation"`
// contains filtered or unexported fields
}
func GetUserByEmailPassword ¶
GetUserByEmail should be called for user login return nil, err when error/mismatch
func GetUserByID ¶
GetUserByID should be called only after the user has been authenticated (Token validated)
func GetUsersByAffiliationID ¶
func (*User) CreateUser ¶
CreateUser should be called when registering a new user
func (*User) NewUserInfo ¶
func (*User) UpdateInfo ¶
func (*User) UserEmailExists ¶
UserEmailExists should be called before submitting user creation form.
type UserInfo ¶
type UserInfo struct {
// Personal Info - Mandatory
FirstName string `json:"first_name"` // Preferred First Name
LastName string `json:"last_name"` // Preferred Last Name
// Billing Info - Optional
StreetAddress string `json:"street_address"`
Suite string `json:"suite"`
City string `json:"city"`
State string `json:"state"`
CountryISO string `json:"country_iso"`
ZipCode string `json:"zip_code"`
}
Click to show internal directories.
Click to hide internal directories.