credentials

package
v3.80.12 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubjectTokenSourceType = 1
	ActorTokenSourceType   = 2
)
View Source
const TokenRefreshDivisor = 10

Variables

This section is empty.

Functions

func AccessError

func AccessError(msg string, err error, opts ...authErrorOption) error

func GetSupportedOauth2TokenExchangeJwtAlgorithms

func GetSupportedOauth2TokenExchangeJwtAlgorithms() []string

func IsAccessError

func IsAccessError(err error) bool

func NewFixedTokenSource

func NewFixedTokenSource(token, tokenType string) *fixedTokenSource

func NewJWTTokenSource

func NewJWTTokenSource(opts ...JWTTokenSourceOption) (*jwtTokenSource, error)

func NewOauth2TokenExchangeCredentials

func NewOauth2TokenExchangeCredentials(
	opts ...Oauth2TokenExchangeCredentialsOption,
) (*oauth2TokenExchange, error)

func NewOauth2TokenExchangeCredentialsFile

func NewOauth2TokenExchangeCredentialsFile(
	configFilePath string,
	opts ...Oauth2TokenExchangeCredentialsOption,
) (*oauth2TokenExchange, error)

func WithActorToken

func WithActorToken(actorToken TokenSource) *tokenSourceOption

ActorTokenSource

func WithAddress

func WithAddress(address string) addressAuthErrorOption

func WithAudience

func WithAudience(audience string, audiences ...string) audienceOption

func WithCredentials

func WithCredentials(credentials Credentials) credentialsUnauthenticatedErrorOption

func WithDatabase

func WithDatabase(database string) databaseAuthErrorOption

func WithECPrivateKeyPEMContent

func WithECPrivateKeyPEMContent(key []byte) *ecPrivateKeyPemContentOption

func WithECPrivateKeyPEMFile

func WithECPrivateKeyPEMFile(path string) *ecPrivateKeyPemFileOption

func WithEndpoint

func WithEndpoint(endpoint string) endpointAuthErrorOption

func WithFixedActorToken

func WithFixedActorToken(token, tokenType string) *tokenSourceOption

func WithFixedSubjectToken

func WithFixedSubjectToken(token, tokenType string) *tokenSourceOption

func WithGrantType

func WithGrantType(grantType string) grantTypeOption

func WithGrpcDialOptions

func WithGrpcDialOptions(opts ...grpc.DialOption) grpcDialOptionsOption

func WithHMACSecretKey

func WithHMACSecretKey(key []byte) *hmacSecretKeyContentOption

func WithHMACSecretKeyBase64Content

func WithHMACSecretKeyBase64Content(base64KeyContent string) *hmacSecretKeyBase64ContentOption

func WithHMACSecretKeyBase64File

func WithHMACSecretKeyBase64File(path string) *hmacSecretKeyBase64FileOption

func WithHMACSecretKeyFile

func WithHMACSecretKeyFile(path string) *hmacSecretKeyFileOption

func WithID

func WithID(id string) idOption

func WithIssuer

func WithIssuer(issuer string) issuerOption

func WithJWTActorToken

func WithJWTActorToken(opts ...JWTTokenSourceOption) *tokenSourceOption

func WithJWTSubjectToken

func WithJWTSubjectToken(opts ...JWTTokenSourceOption) *tokenSourceOption

func WithKeyID

func WithKeyID(id string) keyIDOption

func WithNodeID

func WithNodeID(id uint32) authErrorOption

func WithPrivateKey

func WithPrivateKey(key interface{}) *privateKeyOption

func WithRSAPrivateKeyPEMContent

func WithRSAPrivateKeyPEMContent(key []byte) *rsaPrivateKeyPemContentOption

func WithRSAPrivateKeyPEMFile

func WithRSAPrivateKeyPEMFile(path string) *rsaPrivateKeyPemFileOption

func WithRequestTimeout

func WithRequestTimeout(timeout time.Duration) requestTimeoutOption

func WithRequestedTokenType

func WithRequestedTokenType(requestedTokenType string) requestedTokenTypeOption

func WithResource

func WithResource(resource string, resources ...string) resourceOption

func WithScope

func WithScope(scope string, scopes ...string) scopeOption

func WithSigningMethod

func WithSigningMethod(method jwt.SigningMethod) *signingMethodOption

func WithSigningMethodName

func WithSigningMethodName(method string) *signingMethodNameOption

func WithSubject

func WithSubject(subject string) subjectOption

func WithSubjectToken

func WithSubjectToken(subjectToken TokenSource) *tokenSourceOption

func WithSyncExchangeTimeout

func WithSyncExchangeTimeout(timeout time.Duration) syncExchangeTimeoutOption

func WithTokenEndpoint

func WithTokenEndpoint(endpoint string) tokenEndpointOption

func WithTokenTTL

func WithTokenTTL(ttl time.Duration) tokenTTLOption

Types

type AccessToken

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

AccessToken implements Credentials interface with static authorization parameters.

func NewAccessTokenCredentials

func NewAccessTokenCredentials(token string, opts ...AccessTokenCredentialsOption) *AccessToken

func (AccessToken) String

func (c AccessToken) String() string

Token implements Credentials.

func (AccessToken) Token

func (c AccessToken) Token(_ context.Context) (string, error)

Token implements Credentials.

type AccessTokenCredentialsOption

type AccessTokenCredentialsOption interface {
	ApplyAccessTokenCredentialsOption(c *AccessToken)
}

type Anonymous

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

Anonymous implements Credentials interface with Anonymous access

func NewAnonymousCredentials

func NewAnonymousCredentials(opts ...AnonymousCredentialsOption) *Anonymous

func (Anonymous) String

func (c Anonymous) String() string

Token implements Credentials.

func (Anonymous) Token

func (c Anonymous) Token(_ context.Context) (string, error)

Token implements Credentials.

type AnonymousCredentialsOption

type AnonymousCredentialsOption interface {
	ApplyAnonymousCredentialsOption(c *Anonymous)
}

type Credentials

type Credentials interface {
	// Token must return actual token or error
	Token(ctx context.Context) (string, error)
}

Credentials is an interface of YDB credentials required for connect with YDB

type JWTTokenSourceOption

type JWTTokenSourceOption interface {
	ApplyJWTTokenSourceOption(s *jwtTokenSource) error
}

type Oauth2TokenExchangeCredentialsOption

type Oauth2TokenExchangeCredentialsOption interface {
	ApplyOauth2CredentialsOption(c *oauth2TokenExchange) error
}

type SourceInfoOption

type SourceInfoOption string

func WithSourceInfo

func WithSourceInfo(sourceInfo string) SourceInfoOption

WithSourceInfo option append to credentials object the source info for reporting source info details on error case

func (SourceInfoOption) ApplyAccessTokenCredentialsOption

func (sourceInfo SourceInfoOption) ApplyAccessTokenCredentialsOption(h *AccessToken)

func (SourceInfoOption) ApplyAnonymousCredentialsOption

func (sourceInfo SourceInfoOption) ApplyAnonymousCredentialsOption(h *Anonymous)

func (SourceInfoOption) ApplyOauth2CredentialsOption

func (sourceInfo SourceInfoOption) ApplyOauth2CredentialsOption(h *oauth2TokenExchange) error

func (SourceInfoOption) ApplyStaticCredentialsOption

func (sourceInfo SourceInfoOption) ApplyStaticCredentialsOption(h *Static)

type Static

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

Static implements Credentials interface with static authorization parameters.

func NewStaticCredentials

func NewStaticCredentials(user, password, endpoint string, opts ...StaticCredentialsOption) *Static

func (*Static) String

func (c *Static) String() string

func (*Static) Token

func (c *Static) Token(ctx context.Context) (token string, err error)

type StaticCredentialsOption

type StaticCredentialsOption interface {
	ApplyStaticCredentialsOption(c *Static)
}

type Token

type Token struct {
	Token string

	// token type according to OAuth 2.0 token exchange protocol
	// https://www.rfc-editor.org/rfc/rfc8693#TokenTypeIdentifiers
	// for example urn:ietf:params:oauth:token-type:jwt
	TokenType string
}

type TokenSource

type TokenSource interface {
	Token() (Token, error)
}

Jump to

Keyboard shortcuts

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