Documentation
¶
Overview ¶
This file taken with some modification from authboss github.com/go-authboss
Index ¶
- func DecodeFromString(token string) ([]byte, error)
- func GetInfo(info map[string]interface{}, name string) interface{}
- func GetInfoString(info map[string]interface{}, name string) string
- func GetInfoStrings(info map[string]interface{}, name string) []string
- type AuthError
- type AuthStorer
- type Backender
- type CookieStorer
- type Crypter
- type CryptoHashStore
- type Emailer
- type LoginSession
- type Mailer
- type SendGridSender
- type SessionBackender
- type SmtpSender
- type TemplateNames
- type User
- type UserBackender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeFromString ¶
func GetInfoString ¶
GetInfoString will return the named info as a string
func GetInfoStrings ¶
GetInfoStrings will return the named info as an array of strings
Types ¶
type AuthError ¶
type AuthError struct {
// contains filtered or unexported fields
}
AuthError struct holds detailed auth error info
type AuthStorer ¶
type AuthStorer interface {
GetSession(w http.ResponseWriter, r *http.Request) (*LoginSession, error)
GetBasicAuth(w http.ResponseWriter, r *http.Request) (*LoginSession, error)
OAuthLogin(w http.ResponseWriter, r *http.Request) (string, error)
Login(w http.ResponseWriter, r *http.Request) (*LoginSession, error)
Register(w http.ResponseWriter, r *http.Request, email string, templates TemplateNames, emailSubject string, info map[string]interface{}) error
RequestPasswordReset(w http.ResponseWriter, r *http.Request, email string, templates TemplateNames, emailSubject string, info map[string]interface{}) error
Logout(w http.ResponseWriter, r *http.Request) error
CreateProfile(w http.ResponseWriter, r *http.Request) (*LoginSession, error)
VerifyEmail(w http.ResponseWriter, r *http.Request, emailVerificationCode, templateName, emailSubject string) (string, *User, error)
VerifyPasswordReset(w http.ResponseWriter, r *http.Request, emailVerificationCode string) (string, *User, error)
CreateSecondaryEmail(w http.ResponseWriter, r *http.Request, templateName, emailSubject string) error
SetPrimaryEmail(w http.ResponseWriter, r *http.Request, templateName, emailSubject string) error
UpdatePassword(w http.ResponseWriter, r *http.Request) (*LoginSession, error)
}
AuthStorer interface provides the necessary functionality to get and store authentication information
func NewAuthStore ¶
func NewAuthStore(b Backender, mailer Mailer, customPrefix, cookieDomain string, cookieKey []byte) AuthStorer
NewAuthStore is used to create an AuthStorer for most authentication needs
type Backender ¶
type Backender interface {
Clone() Backender
// contains filtered or unexported methods
}
Backender interface contains all the methods needed to read and write users, sessions and logins
func NewBackend ¶
func NewBackend(u UserBackender, s SessionBackender) Backender
NewBackend returns a Backender from a UserBackender, LoginBackender and SessionBackender
func NewBackendMemory ¶
NewBackendMemory creates a memory-backed Backender
type CookieStorer ¶
type CookieStorer interface {
Get(w http.ResponseWriter, r *http.Request, key string, result interface{}) error
Put(w http.ResponseWriter, r *http.Request, key string, value interface{}) error
PutWithExpire(w http.ResponseWriter, r *http.Request, key string, expireMins int, value interface{}) error
Delete(w http.ResponseWriter, key string)
}
CookieStorer interface provides the necessary methods for handling cookies
type Crypter ¶
type Crypter interface {
HashEquals(token, tokenHash string) error
Hash(token string) (string, error)
}
Crypter interface is used to store the password hash and to compare two password hashes together for equality
type CryptoHashStore ¶
type CryptoHashStore struct {
Crypter
}
func (*CryptoHashStore) HashEquals ¶
func (c *CryptoHashStore) HashEquals(token, tokenHash string) error
type Emailer ¶
Emailer struct contains parsed glob of email templates a Sender interface to send emails
func (*Emailer) SendMessage ¶
SendMessage prepares an email with the provided template and passes it to Send for mailing
type LoginSession ¶
type LoginSession struct {
UserID string `bson:"userID" json:"userID"`
Email string `bson:"email" json:"email"`
Info map[string]interface{} `bson:"info" json:"info"`
SessionHash string `bson:"_id" json:"sessionHash"`
CSRFToken string `bson:"csrfToken" json:"csrfToken"`
RenewTimeUTC time.Time `bson:"renewTimeUTC" json:"renewTimeUTC"`
ExpireTimeUTC time.Time `bson:"expireTimeUTC" json:"expireTimeUTC"`
}
LoginSession is the struct which holds session information
func (*LoginSession) GetInfo ¶
func (l *LoginSession) GetInfo(name string) interface{}
GetInfo will return the named info as an interface{}
func (*LoginSession) GetInfoString ¶
func (l *LoginSession) GetInfoString(name string) string
GetInfoString will return the named info as a string
func (*LoginSession) GetInfoStrings ¶
func (l *LoginSession) GetInfoStrings(name string) []string
GetInfoStrings will return the named info as an array of strings
type Mailer ¶
type Mailer interface {
SendMessage(to, templateName, emailSubject string, data interface{}) error
}
Mailer interface includes method needed to send communication to users on account updates
type SendGridSender ¶
func (*SendGridSender) Send ¶
func (s *SendGridSender) Send(to, subject, body string) error
Send mails the provided email body to recipient at "to" with subject "subject"
type SessionBackender ¶
type SessionBackender interface {
// contains filtered or unexported methods
}
SessionBackender interface holds methods for session management
func NewBackendRedisSession ¶
func NewBackendRedisSession(server string, port int, password string, maxIdle, maxConnections int, keyPrefix string) SessionBackender
NewBackendRedisSession returns a SessionBackender for Redis
type SmtpSender ¶
type SmtpSender struct {
SMTPServer string
SMTPPort int
SMTPFromEmail string
SMTPPassword string
EmailFromDisplayName string
}
func (*SmtpSender) Send ¶
func (s *SmtpSender) Send(to, subject, body string) error
Send mails the provided email body to recipient at "to" with subject "subject"
type TemplateNames ¶
TemplateNames contains the names of the html email templates to be used on Success and/or Failure conditions
type User ¶
type User struct {
UserID string `json:"userID"`
Email string `json:"email"`
Info map[string]interface{} `json:"info"`
}
User is the struct which holds user information
func (*User) GetInfoString ¶
GetInfoString will return the named info as a string
func (*User) GetInfoStrings ¶
GetInfoStrings will return the named info as an array of strings
type UserBackender ¶
type UserBackender interface {
// contains filtered or unexported methods
}
UserBackender interface holds methods for user management