device

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: MIT Imports: 12 Imported by: 1

README

OAuth2 Device Authorization Flow go module

This go module is a helper to implement OAuth2 Device authentication in command line interfaces (or any other input constrained device).

This is the authorization flow the AWS cli uses for SSO.

device flow sequence diagram

Providers

The module has two providers, Auth0 and Okta, and a third which is yet to be implemented.

Auth0

This provider is fully functional. Setup instructions.

Okta

This provider is fully functional. Setup instructions.

Google

To be implemented. Setup instructions.

Documentation

Index

Constants

View Source
const GrantType = "urn:ietf:params:oauth:grant-type:device_code"

Variables

View Source
var (
	// ErrAccessDenied is returned when the user denies the app access to their account.
	ErrAccessDenied = errors.New("access denied by user")
)

Functions

This section is empty.

Types

type Authorizer

type Authorizer struct {
	*Config
}

func NewAuthorizer

func NewAuthorizer(config *Config) *Authorizer

func (*Authorizer) Refresh

func (a *Authorizer) Refresh(ctx context.Context) error

func (*Authorizer) RequestCode

func (a *Authorizer) RequestCode(ctx context.Context) (Code, error)

func (*Authorizer) Revoke

func (a *Authorizer) Revoke(ctx context.Context) error

func (*Authorizer) WaitForAuthorization

func (a *Authorizer) WaitForAuthorization(ctx context.Context, code Code) (oauth2.Token, error)

type Code

type Code struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri"`
	VerificationURIComplete string `json:"verification_uri_complete"`
	ExpiresIn               int64  `json:"expires_in"`
	Interval                int64  `json:"interval"`
}

type Config

type Config struct {
	OAuth2Config oauth2.Config
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(providerName, org, clientID string) (*Config, error)

type Error

type Error struct {
	ErrorCode    string   `json:"ErrorCode"`
	ErrorSummary string   `json:"errorSummary"`
	ErrorCauses  []string `json:"errorCauses"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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