Documentation
¶
Overview ¶
This package is adapted from the `github.com/markbates/goth/gothic` to work with the Fiber web framework.
Index ¶
- Constants
- Variables
- func BeginAuthHandler(ctx *fiber.Ctx) error
- func CompleteUserAuth(ctx *fiber.Ctx, options ...CompleteUserAuthOptions) (goth.User, error)
- func GetAuthURL(ctx *fiber.Ctx) (string, error)
- func GetFromSession(key string, ctx *fiber.Ctx) (string, error)
- func GetProviderName(ctx *fiber.Ctx) (string, error)
- func GetState(ctx *fiber.Ctx) string
- func Logout(ctx *fiber.Ctx) error
- func SetState(ctx *fiber.Ctx) string
- func StoreInSession(key string, value string, ctx *fiber.Ctx) error
- type CompleteUserAuthOptions
Constants ¶
const SessionName = "_gothic_session"
Variables ¶
var ( SessionStore *session.Store ErrSessionNil = errors.New("goth/gothic: no SESSION_SECRET environment variable is set. The default cookie store is not available and any calls will fail. Ignore this warning if you are using a different store") )
Session can/should be set by applications using gothic. The default is a cookie store.
Functions ¶
func BeginAuthHandler ¶
See https://github.com/markbates/goth/examples/main.go to see this in action.
func CompleteUserAuth ¶
See https://github.com/markbates/goth/examples/main.go to see this in action.
func GetAuthURL ¶
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 ¶
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
Types ¶
type CompleteUserAuthOptions ¶
type CompleteUserAuthOptions struct {
// True if CompleteUserAuth should automatically end the user's session.
//
// Defaults to True.
ShouldLogout bool
}
Options that affect how CompleteUserAuth works.