authctl

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthCodeOpts

type AuthCodeOpts struct {
	Browser *BrowserOpts

	BindAddress            []string
	AuthenticationTimeout  time.Duration
	OpenURLAfterAuth       string
	RedirectURLHostname    string
	AuthRequestExtraParams map[string]string
}

type AuthResult

type AuthResult struct {
	AlreadyHasValidToken bool
	Token                oidc.Token
}

AuthResult represents an output DTO of the Authentication use-case.

type AuthenticateOpts

type AuthenticateOpts struct {
	OIDCConfig         oidc.Config
	GrantOpts          *GrantOpts
	CachedToken        *oidc.Token // optional
	CachedTokenReserve time.Duration
	ForceRefresh       bool
}

type BrowserOpts

type BrowserOpts struct {
	SkipOpenBrowser bool
	BrowserCommand  string
}

type ClientCredentialsOpts

type ClientCredentialsOpts struct{}

type DeviceOpts

type DeviceOpts struct {
	Browser *BrowserOpts
}

type GrantOpts

type GrantOpts struct {
	AuthCodeOpts          *AuthCodeOpts
	PasswordOpts          *PasswordOpts
	DeviceOpts            *DeviceOpts
	ClientCredentialsOpts *ClientCredentialsOpts
}

type PasswordOpts

type PasswordOpts struct {
	Username string
	Password string // If empty, read a password using Reader.ReadPassword()
}

type Service

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

func New

func New(browser browser.Opener, reader ioreader.Reader, logger logger.LogWriter, clock clock.Clock) *Service

func (*Service) Authenticate

func (s *Service) Authenticate(ctx context.Context, opts AuthenticateOpts) (*AuthResult, error)

Authenticate provides the internal use-case of authentication.

If the IDToken is not set, it performs the authentication flow. If the IDToken is valid, it does nothing. If the IDtoken has expired and the RefreshToken is set, it refreshes the token. If the RefreshToken has expired, it performs the authentication flow.

The authentication flow is determined as:

If the Username is not set, it performs the authorization code flow. Otherwise, it performs the resource owner password credentials flow. If the Password is not set, it asks a password by the prompt.

Jump to

Keyboard shortcuts

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