gothic_fiber

package
v0.0.0-...-b5db161 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

This package is adapted from the `github.com/markbates/goth/gothic` to work with the Fiber web framework.

Index

Constants

View Source
const SessionName = "_gothic_session"

Variables

View Source
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

func BeginAuthHandler(ctx *fiber.Ctx) error

See https://github.com/markbates/goth/examples/main.go to see this in action.

func CompleteUserAuth

func CompleteUserAuth(ctx *fiber.Ctx, options ...CompleteUserAuthOptions) (goth.User, error)

See https://github.com/markbates/goth/examples/main.go to see this in action.

func GetAuthURL

func GetAuthURL(ctx *fiber.Ctx) (string, error)

I would recommend using the BeginAuthHandler instead of doing all of these steps yourself, but that's entirely up to you.

func GetFromSession

func GetFromSession(key string, ctx *fiber.Ctx) (string, error)

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

func GetProviderName(ctx *fiber.Ctx) (string, error)

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(ctx *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 Logout

func Logout(ctx *fiber.Ctx) error

Logout invalidates a user session.

func SetState

func SetState(ctx *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

func StoreInSession(key string, value string, ctx *fiber.Ctx) error

StoreInSession stores a specified key/value pair in the session.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL