Documentation
¶
Index ¶
- func GetAuthUser(ses *sessions.Session) *authUser
- func GetOAuth2AuthParams(ses *sessions.Session) url.Values
- func GetOauth2Client(ses *sessions.Session) *types.AuthClient
- func HumanSessionStore(store store.AuthSessions, opt options.AuthOpt) *humanSessionStore
- func IsOauth2ClientAuthorized(ses *sessions.Session) bool
- func IsPermLogin(ses *sessions.Session) (p bool)
- func NewAuthUser(s *settings.Settings, u *types.User, perm bool) *authUser
- func SetOauth2AuthParams(ses *sessions.Session, val url.Values)
- func SetOauth2Client(ses *sessions.Session, val *types.AuthClient)
- func SetOauth2ClientAuthorized(ses *sessions.Session, val bool)
- type Alert
- type AuthReq
- func (req AuthReq) Context() context.Context
- func (req *AuthReq) GetKV() map[string]string
- func (req *AuthReq) PopAlerts() []Alert
- func (req *AuthReq) PopKV() map[string]string
- func (req *AuthReq) PushAlert(text string)
- func (req *AuthReq) PushDangerAlert(text string)
- func (req *AuthReq) SetAlerts(aa ...Alert)
- func (req *AuthReq) SetInternalError(err error) bool
- func (req *AuthReq) SetKV(val map[string]string)
- type ExtraReqInfo
- type SessionManager
- func (m *SessionManager) DeleteByID(ctx context.Context, sessionID string) (err error)
- func (m *SessionManager) DeleteByUserID(ctx context.Context, userID uint64) (err error)
- func (m *SessionManager) Get(r *http.Request) *sessions.Session
- func (m *SessionManager) Save(w http.ResponseWriter, r *http.Request)
- func (m *SessionManager) Search(ctx context.Context, userID uint64) (set []*types.AuthSession, err error)
- func (m SessionManager) Store() sessions.Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAuthUser ¶
GetUser is wrapper to get value from session
func GetOAuth2AuthParams ¶
GetOAuth2AuthParams is wrapper to get value from session
func GetOauth2Client ¶
func GetOauth2Client(ses *sessions.Session) *types.AuthClient
GetOauth2Client is wrapper to get value from session
func HumanSessionStore ¶
func HumanSessionStore(store store.AuthSessions, opt options.AuthOpt) *humanSessionStore
func IsOauth2ClientAuthorized ¶
IsOauth2ClientAuthorized is wrapper to get value from session
func IsPermLogin ¶
IsPermLogin decodes remember-me flag from the session and returns true if set
func SetOauth2AuthParams ¶
SetOauth2AuthParams is a session value setting wrapper for Oauth2AuthParams
func SetOauth2Client ¶
func SetOauth2Client(ses *sessions.Session, val *types.AuthClient)
SetOauth2Client is a session value setting wrapper for Oauth2Client
func SetOauth2ClientAuthorized ¶
SetOauth2ClientAuthorized is a session value setting wrapper for Oauth2ClientAuthorized
Types ¶
type AuthReq ¶
type AuthReq struct {
// HTTP request sent
Request *http.Request
Response http.ResponseWriter
// Sessions
Session *sessions.Session
// Authenticated user
AuthUser *authUser
// Current client (when in oauth2 flow)
Client *types.AuthClient
Locale localeService
// Redirect to
RedirectTo string
// Template to render
Template string
// Data to render with the template
Data map[string]interface{}
// handling flash alerts of all types
//
// should not be used for form errors; store them into sep. session keys
PrevAlerts, NewAlerts []Alert
// HTTP status to send
Status int
}
auth context simplifies auth request & response handling
func (*AuthReq) PushDangerAlert ¶
func (*AuthReq) SetInternalError ¶
type ExtraReqInfo ¶
ExtraReqInfo serves as transport struct for additional request information we want to store with the oauth2 token
There is effortless way to extend token info that is created inside go-oauth2 lib so we'll attach this struct to (request's) context with middleware (see MountHttpRoutes) and unpack from context when token is created in HumanTokenStore.Create()
ExtraReqInfo struct also serves as context value key!
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(store store.AuthSessions, opt options.AuthOpt, log *zap.Logger) *SessionManager
func (*SessionManager) DeleteByID ¶
func (m *SessionManager) DeleteByID(ctx context.Context, sessionID string) (err error)
DeleteByID removes session by it's ID
func (*SessionManager) DeleteByUserID ¶
func (m *SessionManager) DeleteByUserID(ctx context.Context, userID uint64) (err error)
DeleteByUserID removes session by user ID
func (*SessionManager) Save ¶
func (m *SessionManager) Save(w http.ResponseWriter, r *http.Request)
func (*SessionManager) Search ¶
func (m *SessionManager) Search(ctx context.Context, userID uint64) (set []*types.AuthSession, err error)
Returns all users sessions
func (SessionManager) Store ¶
func (m SessionManager) Store() sessions.Store