oauthflow

package
v0.0.0-...-624bbc4 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/* #nosec */
	SigstoreDeviceURL = "https://oauth2.sigstore.dev/auth/device/code"
	/* #nosec */
	SigstoreTokenURL = "https://oauth2.sigstore.dev/auth/device/token"
)
View Source
const (
	PKCES256 = "S256"
)

Variables

View Source
var DefaultIDTokenGetter = &InteractiveIDTokenGetter{
	MessagePrinter: func(url string) { fmt.Fprintf(os.Stderr, "Your browser will now be opened to:\n%s\n", url) },
	HTMLPage:       htmlPage,
}

DefaultIDTokenGetter is the default implementation. The HTML page and message printed to the terminal can be customized.

Functions

func SubjectFromToken

func SubjectFromToken(tok *oidc.IDToken) (string, error)

Types

type DeviceFlowTokenGetter

type DeviceFlowTokenGetter struct {
	MessagePrinter func(string)
	Sleeper        func(time.Duration)
	Issuer         string
	CodeURL        string
	TokenURL       string
}

func NewDeviceFlowTokenGetter

func NewDeviceFlowTokenGetter(issuer, codeURL, tokenURL string) *DeviceFlowTokenGetter

func (*DeviceFlowTokenGetter) GetIDToken

func (d *DeviceFlowTokenGetter) GetIDToken(p *oidc.Provider, cfg oauth2.Config) (*OIDCIDToken, error)

type InteractiveIDTokenGetter

type InteractiveIDTokenGetter struct {
	MessagePrinter func(url string)
	HTMLPage       string
}

InteractiveIDTokenGetter is a type to get ID tokens for oauth flows

func (*InteractiveIDTokenGetter) GetIDToken

type OIDCIDToken

type OIDCIDToken struct {
	RawString string
	Subject   string
}

func OIDConnect

func OIDConnect(issuer string, id string, secret string, tg TokenGetter) (*OIDCIDToken, error)

type PKCE

type PKCE struct {
	Challenge string
	Method    string
	Value     string
}

func NewPKCE

func NewPKCE(provider *oidc.Provider) (*PKCE, error)

func (*PKCE) AuthURLOpts

func (p *PKCE) AuthURLOpts() []oauth2.AuthCodeOption

func (*PKCE) TokenURLOpts

func (p *PKCE) TokenURLOpts() []oauth2.AuthCodeOption

type StaticTokenGetter

type StaticTokenGetter struct {
	RawToken string
}

func (*StaticTokenGetter) GetIDToken

func (stg *StaticTokenGetter) GetIDToken(_ *oidc.Provider, _ oauth2.Config) (*OIDCIDToken, error)

type TokenGetter

type TokenGetter interface {
	GetIDToken(provider *oidc.Provider, config oauth2.Config) (*OIDCIDToken, error)
}

Jump to

Keyboard shortcuts

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