sothic

package
v0.0.0-...-f828163 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionName string = "_sac_session"

	// ProviderParamKey can be used as a key in context when passing in a provider
	ProviderParamKey key = iota
)

Variables

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

func CompleteUserAuth(c *fiber.Ctx) (soth.User, error)

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

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

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

func GetFromSession(key string, c *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(c *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(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 Logout

func Logout(c *fiber.Ctx) error

Logout invalidates a user session.

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

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

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

Types

type Params

type Params struct {
	// contains filtered or unexported fields
}

func (*Params) Get

func (p *Params) Get(key string) string

Jump to

Keyboard shortcuts

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