strategy

package
v0.0.0-...-3a2841b Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnauthorized is returned when the user was not authenticated.
	ErrUnauthorized = errors.New("you are not the user you told me you were")

	// ErrUnknown is returned when a user seems to have appeared in the middle of
	// an auth flow.
	ErrUnknown = errors.New("how did you get here?")
)

Functions

This section is empty.

Types

type Strategies

type Strategies []Strategy

Strategies is a list of Strategy.

func (Strategies) IsAllowed

func (strategies Strategies) IsAllowed(link string) (found Strategy, ok bool)

IsAllowed checks whether a strategy exists for the profile link that can be used to authenticate against it.

type Strategy

type Strategy interface {
	// Name returns a unique lowercase alpha string naming the Strategy. This will
	// be passed around as the "provider" parameter.
	Name() string

	// Match determines from the found profile whether this Strategy can be used.
	Match(profile *url.URL) bool

	// Redirect returns the URL to redirect the user to begin the authentication flow.
	Redirect(me, profile string) (redirectURL string, err error)

	// Callback handles the user's return from the 3rd party auth provider. It
	// returns the profile URL for the authenticated user, hopefully matching the
	// rel="me" link earlier. If it does not match then the user who authenticated
	// with the OAuth provider is different to the user attempting to authenticate
	// with relme-auth.
	Callback(form url.Values) (string, error)
}

Strategy is something that can provide authentication for a user.

func Flickr

func Flickr(baseURL string, store strategyStore, id, secret string, httpClient *http.Client) Strategy

Flickr provides a strategy for authenticating with https://www.flickr.com.

func GitHub

func GitHub(store strategyStore, id, secret string) Strategy

GitHub provides a strategy for authenticating with https://github.com.

func PGP

func PGP(store strategyStore, baseURI, id string, httpClient *http.Client) Strategy

PGP provides a strategy for authenticating with a pgpkey.

func True

func True(baseURL string) Strategy

True should only be used for testing purposes, it says that everyone is authenticated!

func Twitter

func Twitter(baseURL string, store strategyStore, id, secret string, httpClient *http.Client) Strategy

Twitter provides a strategy for authenticating with https://twitter.com.

Jump to

Keyboard shortcuts

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