Documentation ¶
Index ¶
Constants ¶
View Source
const ( KeyUserID = "_auth_user_id" KeyCSRFToken = "_csrf_token" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthStore ¶
type AuthStore interface { UserStore GroupStore PermissionStore }
type GroupStore ¶
type Permission ¶
type PermissionStore ¶
type PermissionStore interface { Permissions(context.Context) ([]Permission, error) PermissionByID(context.Context, int64) (Permission, error) PermissionByCode(context.Context, string) (Permission, error) }
type Session ¶
type Session interface { // ID() returns the unique opaque if for the session. This id should be stored // in cookie etc. SessionKey() string // SetValue() stores a value in the session against the passed key. This will // be in store till the session is destroyed or till DeleteValue() is called. // Can return an error in case persistence fails. If this method is called // multiple times with same key, value keeps overwriting the old value. SetValue(ctx context.Context, key string, value interface{}) error // DeleteValue() removes the key from the session. If key is not present no // error is returned, only when there is an error during saving the session an // error is returned. //DeleteValue(key string) error // GetValue() returns a value, or ErrNotFound if there is no such value in the // session. GetValue(string) ([]byte, error) // GetInt() returns the value as Int, it will return ErrNotInt in case the // value stored is not an int. GetInt64(string) (int64, error) // GetString() returns the value as string, it will return ErrNotInt in case // the value stored is not a string. GetString(string) (string, error) GetUser(context.Context) (User, error) // Destroy() destroys the session from session store. Any calls to any method // session object after that may lead to error or crash. Destroy(context.Context) error Store() SessionStore String() string }
type SessionStore ¶
type SessionStore interface { // If GetSession on store is called with id of a destroyed session, a fresh // session is created and returned. GetSessionBySessionKey(ctx context.Context, key string) (Session, error) CreateSession(context.Context) (Session, error) DestroySession(ctx context.Context, id string) error }
func NewFakeSessionStore ¶
func NewFakeSessionStore() SessionStore
NewSessionStore creates a session store. It varifies that the session related table exists (but not if the table schema is correct).
type User ¶
type User interface { ID() int64 Field(string) (interface{}, bool) Email() string CheckPassword(string) bool Roles() ([]string, error) Permissions() ([]Permission, error) HasRole(context.Context, int64) (bool, error) HasPermission(string) (bool, error) SetName(string, bool) error SetEmail(string, bool) error SetPassword(string, bool) error Save(context.Context) error RefreshFromDB(context.Context) error Deactivate(reason string) error IsSuperUser() bool }
type UserStore ¶
type UserStore interface { GetOrCreateUser(context.Context, map[string]interface{}) (User, error) UserByID(context.Context, int64) (User, error) UserByAPIKey(context.Context, string) (User, error) UserByPhone(context.Context, string) (User, error) UserByEmail(context.Context, string) (User, error) Authenticate(context.Context, string, string) (User, error) }
Click to show internal directories.
Click to hide internal directories.