auth

package
v0.0.42 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package auth is a generated GoMock package.

Package auth is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileTokenSourceBuilder

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

FileTokenSourceBuilder contains the logic needed to create a token source that reads tokens from a file.

func NewFileTokenSource

func NewFileTokenSource() *FileTokenSourceBuilder

NewFileTokenSource creates a builder that can then be used to configure and create a token source that reads tokens from a file. The token source will monitor the file's modification time and only reload the token when the file has changed.

func (*FileTokenSourceBuilder) Build

func (b *FileTokenSourceBuilder) Build() (result TokenSource, err error)

Build uses the data stored in the builder to build a new file token source.

func (*FileTokenSourceBuilder) SetFile

SetFile sets the path to the file containing the access token. This is mandatory.

func (*FileTokenSourceBuilder) SetLogger

SetLogger sets the logger. This is mandatory.

type MemoryTokenStoreBuilder

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

MemoryTokenStoreBuilder contains the logic needed to create a token store that saves tokens in memory only.

func NewMemoryTokenStore

func NewMemoryTokenStore() *MemoryTokenStoreBuilder

NewMemoryTokenStore creates a builder that can then be used to configure and create a memory token store.

func (*MemoryTokenStoreBuilder) Build

func (b *MemoryTokenStoreBuilder) Build() (result TokenStore, err error)

Build uses the data stored in the builder to build a new memory token store.

func (*MemoryTokenStoreBuilder) SetLogger

SetLogger sets the logger. This is mandatory.

type MockTokenSource

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

MockTokenSource is a mock of TokenSource interface.

func NewMockTokenSource

func NewMockTokenSource(ctrl *gomock.Controller) *MockTokenSource

NewMockTokenSource creates a new mock instance.

func (*MockTokenSource) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTokenSource) Token

func (m *MockTokenSource) Token(ctx context.Context) (*Token, error)

Token mocks base method.

type MockTokenSourceMockRecorder

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

MockTokenSourceMockRecorder is the mock recorder for MockTokenSource.

func (*MockTokenSourceMockRecorder) Token

func (mr *MockTokenSourceMockRecorder) Token(ctx any) *gomock.Call

Token indicates an expected call of Token.

type MockTokenStore

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

MockTokenStore is a mock of TokenStore interface.

func NewMockTokenStore

func NewMockTokenStore(ctrl *gomock.Controller) *MockTokenStore

NewMockTokenStore creates a new mock instance.

func (*MockTokenStore) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockTokenStore) Load

func (m *MockTokenStore) Load(ctx context.Context) (*Token, error)

Load mocks base method.

func (*MockTokenStore) Save

func (m *MockTokenStore) Save(ctx context.Context, tokens *Token) error

Save mocks base method.

type MockTokenStoreMockRecorder

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

MockTokenStoreMockRecorder is the mock recorder for MockTokenStore.

func (*MockTokenStoreMockRecorder) Load

func (mr *MockTokenStoreMockRecorder) Load(ctx any) *gomock.Call

Load indicates an expected call of Load.

func (*MockTokenStoreMockRecorder) Save

func (mr *MockTokenStoreMockRecorder) Save(ctx, tokens any) *gomock.Call

Save indicates an expected call of Save.

type ScriptTokenSourceBuilder

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

ScriptTokenSourceBuilder contains the logic needed to create a token source that executes an external script to generate the token.

func NewScriptTokenSource

func NewScriptTokenSource() *ScriptTokenSourceBuilder

NewScriptTokenSource creates a builder that can then be used to configure and create a token source that executes a script to generate the token.

func (*ScriptTokenSourceBuilder) Build

func (b *ScriptTokenSourceBuilder) Build() (result TokenSource, err error)

Build uses the data stored in the builder to build a new script token source.

func (*ScriptTokenSourceBuilder) SetLogger

SetLogger sets the logger. This is mandatory.

func (*ScriptTokenSourceBuilder) SetScript

SetScript sets script that will be used to generate new tokens. This is mandatory.

func (*ScriptTokenSourceBuilder) SetStore

SetStore sets the token store that will be used to load and save tokens. This is mandatory.

type StaticTokenSourceBuilder

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

StaticTokenSourceBuilder contains the logic needed to create a token source that always returns the same token.

func NewStaticTokenSource

func NewStaticTokenSource() *StaticTokenSourceBuilder

NewStaticTokenSource creates a builder that can then be used to configure and create a token source that always returns the same static token.

func (*StaticTokenSourceBuilder) Build

func (b *StaticTokenSourceBuilder) Build() (result TokenSource, err error)

Build uses the data stored in the builder to build a new static token source.

func (*StaticTokenSourceBuilder) SetLogger

SetLogger sets the logger. This is mandatory.

func (*StaticTokenSourceBuilder) SetToken

SetToken sets the token that will be returned by this token source. This is mandatory.

type Token

type Token struct {
	// Access is the access token.
	Access string

	// Refresh is the refresh token.
	Refresh string

	// Expiry is the expiry time of the token.
	Expiry time.Time
}

Token is a struct that represents a token that can be used to authenticate requests.

func (*Token) Expired

func (t *Token) Expired() bool

Expired returns true if the token is expired, false otherwise.

func (*Token) Valid

func (t *Token) Valid() bool

Valid returns true if the token is valid, false otherwise.

type TokenCredentialsBuilder

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

TokenCredentialsBuilder contains the logic needed to create credentials that implement the gRPC PerRPCCredentials interface by delegating to our internal TokenSource interface.

func NewTokenCredentials

func NewTokenCredentials() *TokenCredentialsBuilder

NewTokenCredentials creates a builder that can then be used to configure and create token credentials that implement the gRPC PerRPCCredentials interface.

func (*TokenCredentialsBuilder) Build

Build uses the data stored in the builder to build new token credentials.

func (*TokenCredentialsBuilder) SetLogger

SetLogger sets the logger. This is mandatory.

func (*TokenCredentialsBuilder) SetSource

SetSource sets the internal token source to delegate to. This is mandatory.

type TokenSource

type TokenSource interface {
	// Token returns the token for the token source.
	Token(ctx context.Context) (result *Token, err error)
}

TokenSource is the interface that defines the methods that are common to all the token sources.

type TokenStore

type TokenStore interface {
	// Load loads the tokens from the store.
	Load(ctx context.Context) (result *Token, err error)

	// Save saves the tokens to the store.
	Save(ctx context.Context, tokens *Token) error
}

TokenStore is the interface that defines the methods that are used to load/save tokens from/to persistent storage.

Jump to

Keyboard shortcuts

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