userauth

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: May 3, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCallbackAddr = ":4445"

DefaultCallbackAddr is the default address:host on which a local http.Server will be started. It can be overridden using WithCallbackAddr.

View Source
const DefaultRedirectURL = "http://localhost:4445/callback"

DefaultRedirectURL is the default RedirectURL that the oauth2 flow will use. It can be overridden using WithRedirectURL.

Variables

This section is empty.

Functions

func TokenSource

func TokenSource(ctx context.Context, clientID, clientSecret string, opts ...Option) oauth2.TokenSource

TokenSource returns an oauth2.TokenSource that will provide tokens using the three legged oauth2 flow.

Types

type AuthCodeURLHandler

type AuthCodeURLHandler interface {
	AuthCodeURL(string)
}

An AuthCodeURLHandler is asynchronously passed the AuthCodeURL when Token() is called

type AuthCodeURLHandlerFunc

type AuthCodeURLHandlerFunc func(string)

The AuthCodeURLHandlerFunc type is an adapter to allow the use of ordinary functions as AuthCodeURLHandlers. If f is a function with the appropriate signature, AuthCodeURLHandlerFunc(f) is a Handler that calls f.

func (AuthCodeURLHandlerFunc) AuthCodeURL

func (f AuthCodeURLHandlerFunc) AuthCodeURL(u string)

AuthCodeURL calls f(u)

type Option

type Option func(*userAccreditor)

An Option is used to configure the oauth2 user credential flow.

func WithAuthCodeURLHandler

func WithAuthCodeURLHandler(val AuthCodeURLHandler) Option

WithAuthCodeURLHandler returns an Option that will cause the passed in handler to be called in a new goroutine with the value of the URL that should be opened. This allows programmatic user authentication (e.g. without interacting with the browser). Overrides WithoutOpen().

func WithCallbackAddr

func WithCallbackAddr(val string) Option

WithCallbackAddr returns an Option that specifies the address:host on which a local http.Server will be configured to listen for the redirect. It should be reachable by going to the RedirectURL.

func WithDebug

func WithDebug(val io.Writer) Option

WithDebug returns an option that causes incoming http.Requests to the callback server to be logged to the writer.

func WithEndpoint

func WithEndpoint(val oauth2.Endpoint) Option

WithEndpoint returns an Option that specifies the oauth2 endpoint that will be used to get tokens. By default it uses zapi.Endpoint.

func WithIgnoreErrors

func WithIgnoreErrors() Option

WithIgnoreErrors returns an Option that prevents redirect uris from the server containing errors from stopping the listener server. This should only be used for testing.

func WithRedirectURL

func WithRedirectURL(val string) Option

WithRedirectURL returns an Option that specifies the RedirectURL that will be used by the oauth2 flow. The client must be configured on the oauth2 server to permit this value or else the flow will fail.

func WithScope

func WithScope(val ...string) Option

WithScope returns an Option that specifies the scopes that will be requested for the token. If not specified, zapi.DefaultScopes will be used.

func WithoutOpen

func WithoutOpen() Option

WithoutOpen returns an Option that will prevent a browser window from being opened automatically and will instead direct the user to open the url emitted on stderr.

Jump to

Keyboard shortcuts

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