Documentation ¶
Index ¶
- Constants
- func IsPasswordOK(password string) error
- type AuthServer
- func (a *AuthServer) AllUsers() ([]model.AuthUser, error)
- func (a *AuthServer) AuthenticateRequest(w http.ResponseWriter, r *http.Request, allowTypes AuthType) *Credentials
- func (a *AuthServer) CreateKey(w http.ResponseWriter, r *http.Request, cred *Credentials)
- func (a *AuthServer) CreateUser(email, password, sitePermissions string) error
- func (a *AuthServer) EraseAllSessionsExceptCallingSession(cred *Credentials) error
- func (a *AuthServer) Login(w http.ResponseWriter, r *http.Request)
- func (a *AuthServer) Logout(w http.ResponseWriter, r *http.Request)
- func (a *AuthServer) SetPassword(userID int64, password string) error
- type AuthType
- type Credentials
Constants ¶
View Source
const (
SitePermissionAdmin = "a" // You can do anything
)
Site-wide (aka some kind of superuser) permissions. Stored in auth_user.site_permissions
Variables ¶
This section is empty.
Functions ¶
func IsPasswordOK ¶
Types ¶
type AuthServer ¶
type AuthServer struct {
// contains filtered or unexported fields
}
func NewAuthServer ¶
func (*AuthServer) AuthenticateRequest ¶
func (a *AuthServer) AuthenticateRequest(w http.ResponseWriter, r *http.Request, allowTypes AuthType) *Credentials
If authorization fails, sends a response to 'w', and returns nil If authorization succeeds, returns a non-nil Credentials
func (*AuthServer) CreateKey ¶
func (a *AuthServer) CreateKey(w http.ResponseWriter, r *http.Request, cred *Credentials)
func (*AuthServer) CreateUser ¶
func (a *AuthServer) CreateUser(email, password, sitePermissions string) error
func (*AuthServer) EraseAllSessionsExceptCallingSession ¶
func (a *AuthServer) EraseAllSessionsExceptCallingSession(cred *Credentials) error
Erase all sessions except the authentication mechanism that was used to issue this API request
func (*AuthServer) Login ¶
func (a *AuthServer) Login(w http.ResponseWriter, r *http.Request)
func (*AuthServer) Logout ¶
func (a *AuthServer) Logout(w http.ResponseWriter, r *http.Request)
func (*AuthServer) SetPassword ¶
func (a *AuthServer) SetPassword(userID int64, password string) error
type Credentials ¶
type Credentials struct { UserID int64 SitePermissions string AuthenticatedViaSessionCookie string // If session was authenticated via session cookie, this is pwdhash.HashSessionTokenBase64(cookie.Value) - aka the value in the DB AuthenticatedViaApiKey string // If session was authenticated via api key, this is pwdhash.HashSessionTokenBase64(key) - aka the value in the DB AuthenticatedViaUsernamePassword bool // If authenticated via username/password, this is true }
func (*Credentials) IsAdmin ¶
func (c *Credentials) IsAdmin() bool
func (*Credentials) PanicIfNotAdmin ¶
func (c *Credentials) PanicIfNotAdmin()
Click to show internal directories.
Click to hide internal directories.