Documentation ¶
Index ¶
- Constants
- func AutoMigrateModels(db *gorm.DB) error
- type Model
- type Provider
- func (a Provider) AddAppUserContext(next http.Handler) http.Handler
- func (a Provider) CreateUser(user User) (User, error)
- func (a Provider) GetAllUsers() ([]User, error)
- func (a Provider) GetUserBySSOID(ssoID string) (User, error)
- func (a Provider) GetUserFromContext(ctx context.Context) User
- func (a Provider) IsAuthenticated(req *http.Request) bool
- func (a Provider) IssueSession() http.Handler
- func (a Provider) LogoutHandler(w http.ResponseWriter, req *http.Request)
- func (a Provider) WithUserFromSession(s interface{}) (User, error)
- type ProviderSession
- type User
Constants ¶
const (
// AppUserKey is the session key for the app user
AppUserKey key = "AppUser"
)
Variables ¶
This section is empty.
Functions ¶
func AutoMigrateModels ¶
AutoMigrateModels ensures all models are present in the database
Types ¶
type Model ¶
type Model struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created"` UpdatedAt time.Time `json:"updated"` DeletedAt *time.Time `json:"-"` }
Model is the basic data layout to be inherited
type Provider ¶
type Provider struct { DB *gorm.DB Session ProviderSession }
Provider is a struct for auth
func CreateProvider ¶
func CreateProvider(db *gorm.DB, sessionStore *sessions.CookieStore, sessionName, sessionSecret, sessionUserKey string) Provider
CreateProvider will initialize and return a new Provider
func (Provider) AddAppUserContext ¶
AddAppUserContext adds user information context
func (Provider) CreateUser ¶
CreateUser creates a new user in the database
func (Provider) GetAllUsers ¶
GetAllUsers returns all users
func (Provider) GetUserBySSOID ¶
GetUserBySSOID returns a user by SSOID if it exists
func (Provider) GetUserFromContext ¶
GetUserFromContext loads a user from context where it can
func (Provider) IsAuthenticated ¶
IsAuthenticated returns true if the user has a signed session cookie.
func (Provider) IssueSession ¶
IssueSession issues a cookie session after successful Google login
func (Provider) LogoutHandler ¶
func (a Provider) LogoutHandler(w http.ResponseWriter, req *http.Request)
LogoutHandler destroys the session on POSTs and redirects to home.
func (Provider) WithUserFromSession ¶
WithUserFromSession loads a user from a session where it can
type ProviderSession ¶
type ProviderSession struct { Store *sessions.CookieStore Name string Secret string UserKey string }
ProviderSession is a struct for a session