Help us shape the future of Go! Take the 2026 Go Developer Survey

auth

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialsFactory

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

CredentialsFactory creates TokenProviders using the new Credentials and AuthProvider stores. This replaces the old Factory that used AuthorizationStore.

func NewCredentialsFactory

func NewCredentialsFactory(
	credentialsStore driven.CredentialsStore,
	authProviderStore driven.AuthProviderStore,
) *CredentialsFactory

NewCredentialsFactory creates a token provider factory using the new stores.

func (*CredentialsFactory) CreateTokenProvider

func (f *CredentialsFactory) CreateTokenProvider(
	ctx context.Context,
	credentialsID string,
	authProviderID string,
) (driven.TokenProvider, error)

CreateTokenProvider creates the appropriate TokenProvider for a source's credentials. It uses the source's CredentialsID and AuthProviderID to determine the token provider type. Returns NullTokenProvider for empty credentials IDs (e.g., filesystem sources).

func (*CredentialsFactory) CreateTokenProviderForSource

func (f *CredentialsFactory) CreateTokenProviderForSource(
	ctx context.Context,
	source domain.Source,
) (driven.TokenProvider, error)

CreateTokenProviderForSource creates a TokenProvider for a given source. This is a convenience method that extracts the IDs from the source.

type CredentialsOAuthProvider

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

CredentialsOAuthProvider provides OAuth access tokens with automatic refresh. Uses the new Credentials and AuthProvider stores instead of AuthorizationStore.

func NewCredentialsOAuthProvider

func NewCredentialsOAuthProvider(
	credentialsID string,
	credentialsStore driven.CredentialsStore,
	authProviderID string,
	authProviderStore driven.AuthProviderStore,
) *CredentialsOAuthProvider

NewCredentialsOAuthProvider creates a token provider for OAuth-based authentication using the new Credentials and AuthProvider stores.

func (*CredentialsOAuthProvider) AuthMethod

func (p *CredentialsOAuthProvider) AuthMethod() domain.AuthMethod

AuthMethod returns AuthMethodOAuth.

func (*CredentialsOAuthProvider) AuthorizationID

func (p *CredentialsOAuthProvider) AuthorizationID() string

AuthorizationID returns the credentials ID (for compatibility).

func (*CredentialsOAuthProvider) GetToken

func (p *CredentialsOAuthProvider) GetToken(ctx context.Context) (string, error)

GetToken returns a valid access token, refreshing if necessary.

func (*CredentialsOAuthProvider) InvalidateCache

func (p *CredentialsOAuthProvider) InvalidateCache()

InvalidateCache clears the cached token.

func (*CredentialsOAuthProvider) IsAuthenticated

func (p *CredentialsOAuthProvider) IsAuthenticated() bool

IsAuthenticated returns true if the credentials have valid tokens.

type CredentialsPATProvider

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

CredentialsPATProvider provides static Personal Access Tokens. Uses the new Credentials store instead of AuthorizationStore. PATs don't expire and don't require refresh.

func NewCredentialsPATProvider

func NewCredentialsPATProvider(
	credentialsID string,
	credentialsStore driven.CredentialsStore,
) *CredentialsPATProvider

NewCredentialsPATProvider creates a token provider for PAT-based authentication using the new Credentials store.

func (*CredentialsPATProvider) AuthMethod

func (p *CredentialsPATProvider) AuthMethod() domain.AuthMethod

AuthMethod returns AuthMethodPAT.

func (*CredentialsPATProvider) AuthorizationID

func (p *CredentialsPATProvider) AuthorizationID() string

AuthorizationID returns the credentials ID (for compatibility).

func (*CredentialsPATProvider) GetToken

func (p *CredentialsPATProvider) GetToken(ctx context.Context) (string, error)

GetToken returns the PAT token. PATs don't expire, so no refresh logic is needed.

func (*CredentialsPATProvider) IsAuthenticated

func (p *CredentialsPATProvider) IsAuthenticated() bool

IsAuthenticated returns true if valid PAT credentials exist.

type Factory

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

Factory creates TokenProviders for sources with credentials.

func NewFactory

func NewFactory(
	credentialsStore driven.CredentialsStore,
	authProviderStore driven.AuthProviderStore,
) *Factory

NewFactory creates a token provider factory.

func (*Factory) CreateTokenProvider

func (f *Factory) CreateTokenProvider(ctx context.Context, source *domain.Source) (driven.TokenProvider, error)

CreateTokenProvider creates the appropriate TokenProvider for a source. Uses the new Credentials system (CredentialsID + AuthProviderID). Returns NullTokenProvider for sources without credentials.

func (*Factory) CreateTokenProviderForCredentials

func (f *Factory) CreateTokenProviderForCredentials(
	ctx context.Context,
	credentialsID string,
	authProviderID string,
) (driven.TokenProvider, error)

CreateTokenProviderForCredentials creates a TokenProvider from credentials ID and auth provider ID. This is useful when you have the IDs directly rather than a Source object.

type NullTokenProvider

type NullTokenProvider struct{}

NullTokenProvider is for connectors that require no authentication. Used by filesystem connector and other local data sources.

func NewNullTokenProvider

func NewNullTokenProvider() *NullTokenProvider

NewNullTokenProvider creates a token provider for no-auth connectors.

func (*NullTokenProvider) AuthMethod

func (p *NullTokenProvider) AuthMethod() domain.AuthMethod

AuthMethod returns AuthMethodNone.

func (*NullTokenProvider) AuthorizationID

func (p *NullTokenProvider) AuthorizationID() string

AuthorizationID returns an empty string since there's no authorization.

func (*NullTokenProvider) GetToken

func (p *NullTokenProvider) GetToken(_ context.Context) (string, error)

GetToken returns an empty string since no authentication is needed.

func (*NullTokenProvider) IsAuthenticated

func (p *NullTokenProvider) IsAuthenticated() bool

IsAuthenticated always returns true since no-auth is always "authenticated".

Jump to

Keyboard shortcuts

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