appauth

package
v0.0.0-...-63a0d86 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package userauth implements the OAuth2 native app authorization described in rfc8252. This helps CLI client to get access token.

It uses loopback device and by default uses any free port according to https://datatracker.ietf.org/doc/html/rfc8252#section-7.3

To configure this, you'll need to add a couple of redirect URLs like http://127.0.0.1:<your-port> into the okta application sign-in redirect URIs. And use WithLocalServerBindAddress to configure the context to only uses ports list from your assigned list.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures optional field for TokenSource, it's an interface with private function, hence can only be created within the pkg.

func Timeout

func Timeout(t time.Duration) Option

Timeout sets additional timeout for the token polling process.

func UseBindAddress

func UseBindAddress(addresses []string) Option

UseBindAddress provides a way to bind local server on pre-configured addresses.

The RFC8252 requires port to be any port when using loopback interface redirection, hence the default behavior is using first free port and 127.0.0.1 address https://datatracker.ietf.org/doc/html/rfc8252#section-7.3

In case running it in container, it will need to bind on 0.0.0.0 or other addresses.

func UseHTTPClient

func UseHTTPClient(c *http.Client) Option

UseHTTPClient sets http client used to make http requests.

func UseRedirectHostname

func UseRedirectHostname(hostname string) Option

UseRedirectHostname provides a way to set redirect hostname.

The RFC8252 requires 127.0.0.1 address to for safety reason. You can set this if your provider does not accept 127.0.0.1

func UseURLOpener

func UseURLOpener(o types.URLOpener) Option

UseURLOpener sets URL opener for tokensource

type TokenSource

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

func NewImplicit

func NewImplicit(authEndpoint string, tokenEndpoint string, clientID string, clientSecret string, scopes []string, opts ...Option) *TokenSource

func NewPKCE

func NewPKCE(authEndpoint string, tokenEndpoint string, clientID string, scopes []string, opts ...Option) *TokenSource

func (*TokenSource) Token

func (s *TokenSource) Token() (*oauth2.Token, error)

Jump to

Keyboard shortcuts

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