manager

package
v27.4.0-rc.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDeviceLoginStartFail = errors.New("failed to start device code flow login")

Functions

This section is empty.

Types

type OAuthManager

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

OAuthManager is the manager responsible for handling authentication flows with the oauth tenant.

func New

func New(options OAuthManagerOptions) *OAuthManager

func NewManager

func NewManager(store credentials.Store) *OAuthManager

func (*OAuthManager) LoginDevice

func (m *OAuthManager) LoginDevice(ctx context.Context, w io.Writer) (*types.AuthConfig, error)

LoginDevice launches the device authentication flow with the tenant, printing instructions to the provided writer and attempting to open the browser for the user to authenticate. After the user completes the browser login, LoginDevice uses the retrieved tokens to create a Hub PAT which is returned to the caller. The retrieved tokens are stored in the credentials store (under a separate key), and the refresh token is concatenated with the client ID.

func (*OAuthManager) Logout

func (m *OAuthManager) Logout(ctx context.Context) error

Logout fetches the refresh token from the store and revokes it with the configured oauth tenant. The stored access and refresh tokens are then erased from the store. If the refresh token is not found in the store, an error is not returned.

type OAuthManagerOptions

type OAuthManagerOptions struct {
	Store       credentials.Store
	Audience    string
	ClientID    string
	Scopes      []string
	Tenant      string
	DeviceName  string
	OpenBrowser func(string) error
}

OAuthManagerOptions are the options used for New to create a new auth manager.

Jump to

Keyboard shortcuts

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