Documentation ¶
Index ¶
- func GetRedirector(r *http.Request) func()
- func RandomString(length int) string
- type AuthManager
- type AuthProvider
- type CookieManager
- func (cm *CookieManager) ClearCookie(w http.ResponseWriter, name string)
- func (cm *CookieManager) ReadCookie(r *http.Request, name string, maxAge int, dst interface{}) error
- func (cm *CookieManager) ReadCookiePlain(r *http.Request, name string) (string, error)
- func (cm *CookieManager) SetCookie(w http.ResponseWriter, name string, maxAge int, dat interface{}) error
- func (cm *CookieManager) SetCookiePlain(w http.ResponseWriter, name string, maxAge int, value string)
- type FormProvider
- type HTTPProvider
- type Logoutable
- type Option
- type Role
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRedirector ¶
func RandomString ¶
RandomString returns a random string of bytes length long, base64 encoded.
Types ¶
type AuthManager ¶
type AuthManager interface { AddProvider(string, AuthProvider) LoginHandler() http.Handler Wrapper(required Role) func(http.Handler) http.Handler Wrap(next http.Handler, required Role) http.Handler WrapFunc(next http.HandlerFunc, required Role) http.Handler }
func New ¶
func New(opts ...Option) (AuthManager, error)
type AuthProvider ¶
type AuthProvider interface { //Retreive a user from the current http request if present. GetUser(r *http.Request) (*User, error) }
AuthProvider is any source of user authentication. These core methods must be implemented by all providers.
type CookieManager ¶
type CookieManager struct {
// contains filtered or unexported fields
}
func GetCookieManager ¶
func GetCookieManager(r *http.Request) *CookieManager
func (*CookieManager) ClearCookie ¶
func (cm *CookieManager) ClearCookie(w http.ResponseWriter, name string)
func (*CookieManager) ReadCookie ¶
func (*CookieManager) ReadCookiePlain ¶
func (*CookieManager) SetCookie ¶
func (cm *CookieManager) SetCookie(w http.ResponseWriter, name string, maxAge int, dat interface{}) error
func (*CookieManager) SetCookiePlain ¶
func (cm *CookieManager) SetCookiePlain(w http.ResponseWriter, name string, maxAge int, value string)
type FormProvider ¶
type FormProvider interface { AuthProvider GetRequiredFields() []string HandlePost(http.ResponseWriter, *http.Request) }
FormProvider is a provider that accepts login info from an html form.
type HTTPProvider ¶
type HTTPProvider interface { AuthProvider http.Handler }
HTTPProvider is a provider that provides an http handler form managing its own login endpoints, for example oauth. Will receive all calls to /{providerName}/*
type Logoutable ¶
type Logoutable interface { //Logout allows the provider to delete any relevant cookies or session data in order to log the user out. //The provider should not otherwise write to the response, or redirect Logout(w http.ResponseWriter, r *http.Request) }
type Option ¶
type Option func(*authManager) error
func CookieDuration ¶
func CookieSecret ¶
func LoginTemplate ¶
type Role ¶
type Role uint32
Role is a number representing a permission level. Specific roles will be defined by the host application. It is intended to be a bitmask. Each user will have a certain permission level associated, as can any endpoint or content. If the user permissions and the content requirement have any common bits (user & content != 0), then access will be granted.