oauthclient

package
v0.0.0-...-324ef76 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConfig

type ClientConfig struct {
	URL          string
	ClientID     string
	ClientSecret string
	PKCE         bool
	Scope        string
	RedirectURI  string
}

ClientConfig configuration for the OAuthClient

type ClientSession

type ClientSession struct {
	ExpiresAt        time.Time `json:"expiresAt"`
	AccessToken      string    `json:"accessToken"`
	RefreshToken     string    `json:"refreshToken"`
	AuthorizedScopes string    `json:"authorizedScopes"`
	// contains filtered or unexported fields
}

type OAuthClient

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

OAuthClient a new oauth client to talk with fleetcommand

func New

func New(config ClientConfig) (*OAuthClient, error)

New Returns a new OAuthClient

func (*OAuthClient) BuildAuthorizeURL

func (o *OAuthClient) BuildAuthorizeURL() string

BuildAuthorizeURL builds the authorize url the user would visit to grant authorization

func (*OAuthClient) CompleteAuthorization

func (o *OAuthClient) CompleteAuthorization(code string) error

CompleteAuthorization exchanges authorization code for access token and refresh (if offline_access scope was used)

func (*OAuthClient) GetAccessToken

func (o *OAuthClient) GetAccessToken(limitScope string, forceRefresh bool) (accessToken string, err error)

GetAccessToken if current token has desired scopes and hasn't expired will be returned, otherwise refreshToken if available will be used to obtain a valid accessToken

func (*OAuthClient) GetSessionInfo

func (o *OAuthClient) GetSessionInfo() (*ClientSession, error)

func (*OAuthClient) HasActiveSession

func (o *OAuthClient) HasActiveSession() bool

HasActiveSession returns true if there is an active session

func (*OAuthClient) IsValidState

func (o *OAuthClient) IsValidState(state string) bool

IsValidState compares state to stored state to see if valid

func (*OAuthClient) NewSession

func (o *OAuthClient) NewSession() error

NewSession initializes a new session

func (*OAuthClient) RestoreSession

func (o *OAuthClient) RestoreSession(session ClientSession) error

func (*OAuthClient) Revoke

func (o *OAuthClient) Revoke() error

Revoke invalidates the token or logs out

Jump to

Keyboard shortcuts

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