deviceauth

package
v0.51.2 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthenticationTimedout = fmt.Errorf("authentication timed out")
	ErrCodeRejected           = fmt.Errorf("confirmation code rejected")
)

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	VerifyDevice(ctx context.Context) (*DeviceVerification, error)
	GetAccessTokenForDevice(ctx context.Context, v DeviceVerification) (string, error)
}

Authenticator is the interface for authentication via device oauth

type DeviceAuthenticator

type DeviceAuthenticator struct {
	BaseURL  *url.URL
	Clock    clock.Clock
	ClientID string
	// contains filtered or unexported fields
}

DeviceAuthenticator performs the authentication flow for logging in.

func New

func New(authURL string) (*DeviceAuthenticator, error)

New returns an instance of the DeviceAuthenticator

func (*DeviceAuthenticator) GetAccessTokenForDevice

func (d *DeviceAuthenticator) GetAccessTokenForDevice(ctx context.Context, v *DeviceVerification) (*oauth.TokenResponse, error)

GetAccessTokenForDevice uses the device verification response to fetch an access token.

func (*DeviceAuthenticator) VerifyDevice

func (d *DeviceAuthenticator) VerifyDevice(ctx context.Context, redirectURL string) (*DeviceVerification, error)

VerifyDevice performs the device verification API calls.

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode              string `json:"device_code"`
	UserCode                string `json:"user_code"`
	VerificationURI         string `json:"verification_uri"`
	VerificationCompleteURI string `json:"verification_uri_complete"`
	ExpiresIn               int    `json:"expires_in"`
	PollingInterval         int    `json:"interval"`
}

DeviceCodeResponse encapsulates the response for obtaining a device code.

type DeviceVerification

type DeviceVerification struct {
	DeviceCode              string
	UserCode                string
	VerificationURL         string
	VerificationCompleteURL string
	CheckInterval           time.Duration
	ExpiresAt               time.Time
}

DeviceVerification represents the response from verifying a device.

Jump to

Keyboard shortcuts

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