Documentation ¶
Index ¶
- Constants
- Variables
- func BeginAuthHandler(c *fiber.Ctx) error
- func CompleteUserAuth(c *fiber.Ctx) (soth.User, error)
- func GetAuthURL(c *fiber.Ctx) (string, error)
- func GetFromSession(key string, c *fiber.Ctx) (string, error)
- func GetProviderName(c *fiber.Ctx) (string, error)
- func GetState(c *fiber.Ctx) string
- func Init(sessionSettings config.SessionSettings)
- func Logout(c *fiber.Ctx) error
- func SetProvider(c *fiber.Ctx, provider string)
- func SetState(c *fiber.Ctx) string
- func StoreInSession(key string, value string, c *fiber.Ctx) error
- type Params
Constants ¶
const ( SessionName string = "_sac_session" // ProviderParamKey can be used as a key in context when passing in a provider ProviderParamKey key = iota )
Variables ¶
var ( // Session can/should be set by applications using sothic. SessionStore *session.Store )
Functions ¶
func BeginAuthHandler ¶
func BeginAuthHandler(c *fiber.Ctx) error
BeginAuthHandler is a convenience handler for starting the authentication process.
It expects to be able to get the name of the provider from the path parameter ":provider" or as set by SetProvider.
BeginAuthHandler will redirect the user to the appropriate authentication end-point for the requested provider.
See https://github.com/markbates/goth/examples/main.go to see this in action.
func CompleteUserAuth ¶
CompleteUserAuth does what it says on the tin. It completes the authentication process and fetches all of the basic information about the user from the provider.
It expects to be able to get the name of the provider from the path parameter ":provider" or as set by SetProvider.
This method automatically ends the session. You can prevent this behavior by passing in options. Please note that any options provided in addition to the first will be ignored.
See https://github.com/markbates/goth/examples/main.go to see this in action.
func GetAuthURL ¶
GetAuthURL starts the authentication process with the requested provided. It will return a URL that should be used to send users to.
It expects to be able to get the name of the provider from the query parameters as either "provider" or ":provider".
I would recommend using the BeginAuthHandler instead of doing all of these steps yourself, but that's entirely up to you.
func GetFromSession ¶
GetFromSession retrieves a previously-stored value from the session. If no value has previously been stored at the specified key, it will return an error.
func GetProviderName ¶
GetProviderName is a function used to get the name of a provider for a given request. By default, this provider is fetched from the URL query string. If you provide it in a different way, assign your own function to this variable that returns the provider name for your request.
func GetState ¶
func GetState(c *fiber.Ctx) string
GetState gets the state returned by the provider during the callback. This is used to prevent CSRF attacks, see http://tools.ietf.org/html/rfc6749#section-10.12
func Init ¶
func Init(sessionSettings config.SessionSettings)
MUST be called before using the package
func SetProvider ¶
func SetProvider(c *fiber.Ctx, provider string)
func SetState ¶
func SetState(c *fiber.Ctx) string
SetState sets the state string associated with the given request. If no state string is associated with the request, one will be generated. This state is sent to the provider and can be retrieved during the callback.
func StoreInSession ¶
StoreInSession stores a specified key/value pair in the session.