Documentation
¶
Index ¶
- type AuthConfig
- func (a *AuthConfig) EnsureLogin(w http.ResponseWriter, r *http.Request) bool
- func (a *AuthConfig) EnsureLoginMiddleware(next http.Handler) http.Handler
- func (a *AuthConfig) EnsureReasonableDefaults()
- func (a *AuthConfig) ExtractUserInfo(w http.ResponseWriter, r *http.Request)
- func (a *AuthConfig) GetLoggedInUserId(r *http.Request) string
- type AuthDB
- func (adb *AuthDB) DeleteAuthFlowById(entityId string) bool
- func (adb *AuthDB) EnsureChannel(provider string, loginId string, params utils.StrMap) (*Channel, bool)
- func (adb *AuthDB) EnsureIdentity(idType string, idKey string, params utils.StrMap) (*Identity, bool)
- func (adb *AuthDB) GetAuthFlowById(entityId string) (*AuthFlow, error)
- func (adb *AuthDB) GetChannel(provider string, loginId string) (*Channel, error)
- func (adb *AuthDB) GetIdentity(idType string, idKey string) (*Identity, error)
- func (adb *AuthDB) SaveAuthFlow(entity *AuthFlow) (err error)
- func (adb *AuthDB) SaveChannel(entity *Channel) (err error)
- func (adb *AuthDB) SaveIdentity(entity *Identity) (err error)
- type AuthFlow
- type CallbackRequest
- type Channel
- type Identity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthConfig ¶ added in v0.0.88
type AuthConfig struct { RequestVars *gohttp.RequestVarMap SessionGetter func(r *http.Request, param string) any CallbackURLParam string DefaultRedirectURL string GetRedirURL func(r *http.Request) string UserParamName string NoLoginRedirect bool }
func (*AuthConfig) EnsureLogin ¶ added in v0.0.88
func (a *AuthConfig) EnsureLogin(w http.ResponseWriter, r *http.Request) bool
func (*AuthConfig) EnsureLoginMiddleware ¶ added in v0.0.97
func (a *AuthConfig) EnsureLoginMiddleware(next http.Handler) http.Handler
*
- Redirects users to login screen of they are not logged in
- @param req Request object
- @param res Response object
- @param next next function
func (*AuthConfig) EnsureReasonableDefaults ¶ added in v0.0.89
func (a *AuthConfig) EnsureReasonableDefaults()
*
- Ensures that config values have reasonable defaults.
func (*AuthConfig) ExtractUserInfo ¶ added in v0.0.89
func (a *AuthConfig) ExtractUserInfo(w http.ResponseWriter, r *http.Request)
*
- Extracts user info from the request and saves it into current user.
- Can be used by further middleware down the line to get the request's
- user info
func (*AuthConfig) GetLoggedInUserId ¶ added in v0.0.89
func (a *AuthConfig) GetLoggedInUserId(r *http.Request) string
type AuthDB ¶ added in v0.0.8
type AuthDB struct {
// contains filtered or unexported fields
}
func (*AuthDB) DeleteAuthFlowById ¶ added in v0.0.8
func (*AuthDB) EnsureChannel ¶ added in v0.0.8
func (*AuthDB) EnsureIdentity ¶ added in v0.0.8
func (*AuthDB) GetAuthFlowById ¶ added in v0.0.8
func (*AuthDB) GetChannel ¶ added in v0.0.8
func (*AuthDB) GetIdentity ¶ added in v0.0.8
func (*AuthDB) SaveAuthFlow ¶ added in v0.0.8
*
- Creates a new auth session object to track a login request.
func (*AuthDB) SaveChannel ¶ added in v0.0.8
func (*AuthDB) SaveIdentity ¶ added in v0.0.8
type AuthFlow ¶
type AuthFlow struct { dal.BaseEntity // A unique Auth Session ID ID string // Kind of login being done Provider string // When this Auth session expires; ExpiresIn time.Time // 300 // Handler that will continue the flow after a successful AuthFlow. HandlerName string // "login" // Parameters for the handler to continue with. HandlerParams dal.JsonField `gorm:"type:text"` }
type CallbackRequest ¶
type CallbackRequest struct { Hostname string Path string // Method to call the callback URL on Method string // Headers for this request Headers utils.StrMap // contains filtered or unexported fields }
func (*CallbackRequest) FullURL ¶
func (c *CallbackRequest) FullURL() string
type Channel ¶
type Channel struct { dal.BaseEntity Provider string `gorm:"primaryKey"` LoginId string `gorm:"primaryKey"` /** * Credentials for this channel (like access tokens, hashed passwords etc). */ Credentials dal.JsonField `gorm:"type:text"` /** * Profile as passed by the provider of the channel. */ Profile dal.JsonField `gorm:"type:text"` /** * When does this channel expire and needs another login/auth. */ ExpiresAt time.Time // The identity that this channel is verifying. IdentityKey string }
*
- Channel's represented federated verification objects. For example a Google
- Signin would ensure that the user that goes through this flow will end up
- with a Google signin Channel - which would verify a particular identity type.
func NewChannel ¶ added in v0.0.8
func (*Channel) HasIdentity ¶
type Identity ¶
type Identity struct { dal.BaseEntity // Type of identity being verified (eg email, phone etc). IdentityType string `gorm:"primaryKey"` // The key specific to the identity (eg an email address or a phone number etc). // // type + key should be unique through out the system. IdentityKey string `gorm:"primaryKey"` // The primary user that this identity can be associated with. // Identities do not need to be explicitly associted with a user especially // in systems where a single Identity can be used to front several users PrimaryUser string }
*
- An identify is a unique global "address" corresponding to a user.
- For example the identify abc@example.com is a unique identify regardless
- of which Channel is verifying it. Multiple channels can verify the same
- entity, eg open auth by github, FB or Google can verify the same email
- address.
func NewIdentity ¶ added in v0.0.8
Click to show internal directories.
Click to hide internal directories.