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 ¶
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 ¶
func (a *AuthConfig) EnsureLogin(w http.ResponseWriter, r *http.Request) bool
func (*AuthConfig) EnsureLoginMiddleware ¶
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 ¶
func (a *AuthConfig) EnsureReasonableDefaults()
*
- Ensures that config values have reasonable defaults.
func (*AuthConfig) ExtractUserInfo ¶
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 ¶
func (a *AuthConfig) GetLoggedInUserId(r *http.Request) string
type AuthDB ¶
type AuthDB struct {
// contains filtered or unexported fields
}
func (*AuthDB) DeleteAuthFlowById ¶
func (*AuthDB) EnsureChannel ¶
func (*AuthDB) EnsureIdentity ¶
func (*AuthDB) GetAuthFlowById ¶
func (*AuthDB) GetChannel ¶
func (*AuthDB) GetIdentity ¶
func (*AuthDB) SaveChannel ¶
func (*AuthDB) SaveIdentity ¶
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 (*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 ¶
Click to show internal directories.
Click to hide internal directories.