oidc

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Refresh(ctx context.Context, refreshToken string) (*TokenSet, error)
	Logout(idToken string) error
	GetTokenByAuthCode(ctx context.Context, in GetTokenByAuthCodeInput, localServerReadyChan chan<- string) (*TokenSet, error)
	GetAuthCodeURL(ctx context.Context, in GetAuthCodeURLInput) (string, error)
	ExchangeAuthCode(ctx context.Context, in ExchangeAuthCodeInput) (*TokenSet, error)
}

Client represents an OIDC Client

type ExchangeAuthCodeInput

type ExchangeAuthCodeInput struct {
	Code string
	// PKCE represents a set of PKCE parameters
	PKCEParams *oauth2params.PKCE
	// OIDC Nonce
	Nonce string
	// RedirectURI is the redirect url
	RedirectURI string
}

ExchangeAuthCodeInput holds the input parameters for ExchangeAuthCode()

type Factory

type Factory struct {
	Logger logger.Logger
}

func (*Factory) New

func (f *Factory) New(ctx context.Context, p Provider) (Client, error)

New creates a new OIDC Client

func (*Factory) SetLogger

func (f *Factory) SetLogger(l logger.Logger)

SetLogger sets the logger used for the factory

type FactoryClient

type FactoryClient interface {
	/// New creates a new OIDC Client
	New(ctx context.Context, p Provider) (Client, error)
	// SetLogger sets the logger used for authentication
	SetLogger(logger.Logger)
}

FactoryClient represents a Client factory

type GetAuthCodeURLInput

type GetAuthCodeURLInput struct {
	// RedirectURI is the redirect url
	// This is typicalle an URN such as urn:ietf:wg:oauth:2.0:oob
	RedirectURI string
	// PKCE represents a set of PKCE parameters
	PKCEParams *oauth2params.PKCE
	// OAuth 2.0 state
	State string
	// OIDC Nonce
	Nonce string
}

GetGetAuthCodeURL is the input given to GetAuthCodeURL

type GetTokenByAuthCodeInput

type GetTokenByAuthCodeInput struct {
	// BindAddress is the IP-address and port used by the redirect url server
	BindAddress string
	// RedirectURLHostname is the hostname of the redirect URL. You can set this
	// if your provider does not accept localhost.
	RedirectURLHostname string
	// PKCE represents a set of PKCE parameters
	PKCEParams *oauth2params.PKCE
	// OAuth 2.0 state
	State string
	// OIDC Nonce
	Nonce string
}

GetTokenByAuthCodeInput is the input given to GetTokenByAuthCode

type MockClient

type MockClient struct {
	mock.Mock
}

MockClient is an autogenerated mock type for the Client type

func NewMockClient

func NewMockClient(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockClient

NewMockClient creates a new instance of MockClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockClient) EXPECT

func (_m *MockClient) EXPECT() *MockClient_Expecter

func (*MockClient) ExchangeAuthCode

func (_m *MockClient) ExchangeAuthCode(ctx context.Context, in ExchangeAuthCodeInput) (*TokenSet, error)

ExchangeAuthCode provides a mock function with given fields: ctx, in

func (*MockClient) GetAuthCodeURL

func (_m *MockClient) GetAuthCodeURL(ctx context.Context, in GetAuthCodeURLInput) (string, error)

GetAuthCodeURL provides a mock function with given fields: ctx, in

func (*MockClient) GetTokenByAuthCode

func (_m *MockClient) GetTokenByAuthCode(ctx context.Context, in GetTokenByAuthCodeInput, localServerReadyChan chan<- string) (*TokenSet, error)

GetTokenByAuthCode provides a mock function with given fields: ctx, in, localServerReadyChan

func (*MockClient) Logout

func (_m *MockClient) Logout(idToken string) error

Logout provides a mock function with given fields: idToken

func (*MockClient) Refresh

func (_m *MockClient) Refresh(ctx context.Context, refreshToken string) (*TokenSet, error)

Refresh provides a mock function with given fields: ctx, refreshToken

type MockClient_ExchangeAuthCode_Call

type MockClient_ExchangeAuthCode_Call struct {
	*mock.Call
}

MockClient_ExchangeAuthCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ExchangeAuthCode'

func (*MockClient_ExchangeAuthCode_Call) Return

func (*MockClient_ExchangeAuthCode_Call) Run

func (*MockClient_ExchangeAuthCode_Call) RunAndReturn

type MockClient_Expecter

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

func (*MockClient_Expecter) ExchangeAuthCode

func (_e *MockClient_Expecter) ExchangeAuthCode(ctx interface{}, in interface{}) *MockClient_ExchangeAuthCode_Call

ExchangeAuthCode is a helper method to define mock.On call

  • ctx context.Context
  • in ExchangeAuthCodeInput

func (*MockClient_Expecter) GetAuthCodeURL

func (_e *MockClient_Expecter) GetAuthCodeURL(ctx interface{}, in interface{}) *MockClient_GetAuthCodeURL_Call

GetAuthCodeURL is a helper method to define mock.On call

  • ctx context.Context
  • in GetAuthCodeURLInput

func (*MockClient_Expecter) GetTokenByAuthCode

func (_e *MockClient_Expecter) GetTokenByAuthCode(ctx interface{}, in interface{}, localServerReadyChan interface{}) *MockClient_GetTokenByAuthCode_Call

GetTokenByAuthCode is a helper method to define mock.On call

  • ctx context.Context
  • in GetTokenByAuthCodeInput
  • localServerReadyChan chan<- string

func (*MockClient_Expecter) Logout

func (_e *MockClient_Expecter) Logout(idToken interface{}) *MockClient_Logout_Call

Logout is a helper method to define mock.On call

  • idToken string

func (*MockClient_Expecter) Refresh

func (_e *MockClient_Expecter) Refresh(ctx interface{}, refreshToken interface{}) *MockClient_Refresh_Call

Refresh is a helper method to define mock.On call

  • ctx context.Context
  • refreshToken string

type MockClient_GetAuthCodeURL_Call

type MockClient_GetAuthCodeURL_Call struct {
	*mock.Call
}

MockClient_GetAuthCodeURL_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAuthCodeURL'

func (*MockClient_GetAuthCodeURL_Call) Return

func (*MockClient_GetAuthCodeURL_Call) Run

func (*MockClient_GetAuthCodeURL_Call) RunAndReturn

type MockClient_GetTokenByAuthCode_Call

type MockClient_GetTokenByAuthCode_Call struct {
	*mock.Call
}

MockClient_GetTokenByAuthCode_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTokenByAuthCode'

func (*MockClient_GetTokenByAuthCode_Call) Return

func (*MockClient_GetTokenByAuthCode_Call) Run

func (*MockClient_GetTokenByAuthCode_Call) RunAndReturn

type MockClient_Logout_Call

type MockClient_Logout_Call struct {
	*mock.Call
}

MockClient_Logout_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Logout'

func (*MockClient_Logout_Call) Return

func (*MockClient_Logout_Call) Run

func (_c *MockClient_Logout_Call) Run(run func(idToken string)) *MockClient_Logout_Call

func (*MockClient_Logout_Call) RunAndReturn

func (_c *MockClient_Logout_Call) RunAndReturn(run func(string) error) *MockClient_Logout_Call

type MockClient_Refresh_Call

type MockClient_Refresh_Call struct {
	*mock.Call
}

MockClient_Refresh_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Refresh'

func (*MockClient_Refresh_Call) Return

func (*MockClient_Refresh_Call) Run

func (_c *MockClient_Refresh_Call) Run(run func(ctx context.Context, refreshToken string)) *MockClient_Refresh_Call

func (*MockClient_Refresh_Call) RunAndReturn

type MockFactoryClient

type MockFactoryClient struct {
	mock.Mock
}

MockFactoryClient is an autogenerated mock type for the FactoryClient type

func NewMockFactoryClient

func NewMockFactoryClient(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockFactoryClient

NewMockFactoryClient creates a new instance of MockFactoryClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockFactoryClient) EXPECT

func (*MockFactoryClient) New

New provides a mock function with given fields: ctx, p

func (*MockFactoryClient) SetLogger

func (_m *MockFactoryClient) SetLogger(_a0 logger.Logger)

SetLogger provides a mock function with given fields: _a0

type MockFactoryClient_Expecter

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

func (*MockFactoryClient_Expecter) New

func (_e *MockFactoryClient_Expecter) New(ctx interface{}, p interface{}) *MockFactoryClient_New_Call

New is a helper method to define mock.On call

  • ctx context.Context
  • p Provider

func (*MockFactoryClient_Expecter) SetLogger

func (_e *MockFactoryClient_Expecter) SetLogger(_a0 interface{}) *MockFactoryClient_SetLogger_Call

SetLogger is a helper method to define mock.On call

  • _a0 logger.Logger

type MockFactoryClient_New_Call

type MockFactoryClient_New_Call struct {
	*mock.Call
}

MockFactoryClient_New_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'New'

func (*MockFactoryClient_New_Call) Return

func (*MockFactoryClient_New_Call) Run

func (*MockFactoryClient_New_Call) RunAndReturn

type MockFactoryClient_SetLogger_Call

type MockFactoryClient_SetLogger_Call struct {
	*mock.Call
}

MockFactoryClient_SetLogger_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetLogger'

func (*MockFactoryClient_SetLogger_Call) Return

func (*MockFactoryClient_SetLogger_Call) Run

func (*MockFactoryClient_SetLogger_Call) RunAndReturn

type OIDCSlogAdapter

type OIDCSlogAdapter struct {
	Logger logger.Logger
}

OIDCSlogAdapter is an slog adapter used by retryablehttp

func (OIDCSlogAdapter) Debug

func (a OIDCSlogAdapter) Debug(msg string, keysAndValues ...interface{})

Debug logs messages at debug level

func (OIDCSlogAdapter) Error

func (a OIDCSlogAdapter) Error(msg string, keysAndValues ...interface{})

Error logs messages at error level

func (OIDCSlogAdapter) Info

func (a OIDCSlogAdapter) Info(msg string, keysAndValues ...interface{})

Info logs messages at info level

func (OIDCSlogAdapter) Warn

func (a OIDCSlogAdapter) Warn(msg string, keysAndValues ...interface{})

Warn logs messages at warn level

type Provider

type Provider struct {
	IssuerURL   string
	ClientID    string
	ExtraScopes []string
}

Provider represents an OICD provider

type TokenSet

type TokenSet struct {
	AccessToken  string
	IDToken      string
	RefreshToken string
}

TokenSet represents a set of ID token and refresh token

func (TokenSet) DecodeWithoutVerify

func (ts TokenSet) DecodeWithoutVerify() (*jwt.Claims, error)

DecodeWithoutVerify decodes the JWT string and returns the claims. Note that this method does not verify the signature and always trust it.

Jump to

Keyboard shortcuts

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