credentials

package
v3.94.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSupportedOauth2TokenExchangeJwtAlgorithms added in v3.75.0

func GetSupportedOauth2TokenExchangeJwtAlgorithms() []string

GetSupportedOauth2TokenExchangeJwtAlgorithms returns supported algorithms for initializing OAuth 2.0 token exchange protocol credentials from config file

func NewAccessTokenCredentials added in v3.5.0

func NewAccessTokenCredentials(
	accessToken string, opts ...credentials.AccessTokenCredentialsOption,
) *credentials.AccessToken

NewAccessTokenCredentials makes access token credentials object Passed options redefines default values of credentials object internal fields

func NewAnonymousCredentials added in v3.5.0

func NewAnonymousCredentials(
	opts ...credentials.AnonymousCredentialsOption,
) *credentials.Anonymous

NewAnonymousCredentials makes anonymous credentials object Passed options redefines default values of credentials object internal fields

func NewFixedTokenSource added in v3.65.0

func NewFixedTokenSource(token, tokenType string) credentials.TokenSource

NewFixedTokenSource makes fixed token source for OAuth 2.0 token exchange credentials

func NewJWTTokenSource added in v3.65.0

func NewJWTTokenSource(opts ...credentials.JWTTokenSourceOption) (credentials.TokenSource, error)

NewJWTTokenSource makes JWT token source for OAuth 2.0 token exchange credentials

func NewStaticCredentials added in v3.42.3

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

NewStaticCredentials makes static credentials object

func WithAudience added in v3.65.0

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

func WithECPrivateKeyPEMContent added in v3.75.0

func WithECPrivateKeyPEMContent(key []byte) credentials.JWTTokenSourceOption

PrivateKey For EC signing methods: ES256, ES384, ES512

func WithECPrivateKeyPEMFile added in v3.75.0

func WithECPrivateKeyPEMFile(path string) credentials.JWTTokenSourceOption

PrivateKey For EC signing methods: ES256, ES384, ES512

func WithGrpcDialOptions added in v3.53.3

func WithGrpcDialOptions(opts ...grpc.DialOption) credentials.StaticCredentialsOption

WithGrpcDialOptions option append to static credentials object GRPC dial options

func WithHMACSecretKey added in v3.75.0

func WithHMACSecretKey(key []byte) credentials.JWTTokenSourceOption

Key For HMAC signing methods: HS256, HS384, HS512

func WithHMACSecretKeyBase64Content added in v3.75.0

func WithHMACSecretKeyBase64Content(base64KeyContent string) credentials.JWTTokenSourceOption

Key For HMAC signing methods: HS256, HS384, HS512

func WithHMACSecretKeyBase64File added in v3.75.0

func WithHMACSecretKeyBase64File(path string) credentials.JWTTokenSourceOption

Key For HMAC signing methods: HS256, HS384, HS512

func WithHMACSecretKeyFile added in v3.75.0

func WithHMACSecretKeyFile(path string) credentials.JWTTokenSourceOption

Key For HMAC signing methods: HS256, HS384, HS512

func WithID added in v3.65.0

ID

func WithIssuer added in v3.65.0

func WithIssuer(issuer string) credentials.JWTTokenSourceOption

Issuer

func WithKeyID added in v3.65.0

KeyID

func WithPrivateKey added in v3.65.0

func WithPrivateKey(key interface{}) credentials.JWTTokenSourceOption

PrivateKey

func WithRSAPrivateKeyPEMContent added in v3.65.0

func WithRSAPrivateKeyPEMContent(key []byte) credentials.JWTTokenSourceOption

PrivateKey For RSA signing methods: RS256, RS384, RS512, PS256, PS384, PS512

func WithRSAPrivateKeyPEMFile added in v3.65.0

func WithRSAPrivateKeyPEMFile(path string) credentials.JWTTokenSourceOption

PrivateKey For RSA signing methods: RS256, RS384, RS512, PS256, PS384, PS512

func WithSigningMethod added in v3.65.0

func WithSigningMethod(method jwt.SigningMethod) credentials.JWTTokenSourceOption

SigningMethod

func WithSigningMethodName added in v3.75.0

func WithSigningMethodName(method string) credentials.JWTTokenSourceOption

SigningMethod

func WithSourceInfo added in v3.5.0

func WithSourceInfo(sourceInfo string) credentials.SourceInfoOption

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

func WithSubject added in v3.65.0

func WithSubject(subject string) credentials.JWTTokenSourceOption

Subject

func WithTokenTTL added in v3.65.0

TokenTTL

Types

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

func NewOauth2TokenExchangeCredentials added in v3.65.0

func NewOauth2TokenExchangeCredentials(
	opts ...credentials.Oauth2TokenExchangeCredentialsOption,
) (Credentials, error)

NewOauth2TokenExchangeCredentials makes OAuth 2.0 token exchange protocol credentials object https://www.rfc-editor.org/rfc/rfc8693

func NewOauth2TokenExchangeCredentialsFile added in v3.75.0

func NewOauth2TokenExchangeCredentialsFile(
	configFilePath string,
	opts ...credentials.Oauth2TokenExchangeCredentialsOption,
) (Credentials, error)

NewOauth2TokenExchangeCredentialsFile makes OAuth 2.0 token exchange protocol credentials object from config file https://www.rfc-editor.org/rfc/rfc8693 Config file must be a valid json file

Fields of json file

grant-type:           [string] Grant type option (default: "urn:ietf:params:oauth:grant-type:token-exchange")
res:                  [string | list of strings] Resource option (optional)
aud:                  [string | list of strings] Audience option for token exchange request (optional)
scope:                [string | list of strings] Scope option (optional)
requested-token-type: [string] Requested token type option (default: "urn:ietf:params:oauth:token-type:access_token")
subject-credentials:  [creds_json] Subject credentials options (optional)
actor-credentials:    [creds_json] Actor credentials options (optional)
token-endpoint:       [string] Token endpoint

Fields of creds_json (JWT):

type:                 [string] Token source type. Set JWT
alg:                  [string] Algorithm for JWT signature.
							   Supported algorithms can be listed
							   with GetSupportedOauth2TokenExchangeJwtAlgorithms()
private-key:          [string] (Private) key in PEM format (RSA, EC) or Base64 format (HMAC) for JWT signature
kid:                  [string] Key id JWT standard claim (optional)
iss:                  [string] Issuer JWT standard claim (optional)
sub:                  [string] Subject JWT standard claim (optional)
aud:                  [string | list of strings] Audience JWT standard claim (optional)
jti:                  [string] JWT ID JWT standard claim (optional)
ttl:                  [string] Token TTL (default: 1h)

Fields of creds_json (FIXED):

type:                 [string] Token source type. Set FIXED
token:                [string] Token value
token-type:           [string] Token type value. It will become
							   subject_token_type/actor_token_type parameter
							   in token exchange request (https://www.rfc-editor.org/rfc/rfc8693)

type Oauth2TokenExchangeCredentialsOption added in v3.65.0

type Oauth2TokenExchangeCredentialsOption = credentials.Oauth2TokenExchangeCredentialsOption

func WithActorToken added in v3.65.0

ActorTokenSource

func WithFixedActorToken added in v3.65.0

func WithFixedActorToken(token, tokenType string) Oauth2TokenExchangeCredentialsOption

ActorTokenSource

func WithFixedSubjectToken added in v3.65.0

func WithFixedSubjectToken(token, tokenType string) Oauth2TokenExchangeCredentialsOption

SubjectTokenSource

func WithGrantType added in v3.65.0

func WithGrantType(grantType string) Oauth2TokenExchangeCredentialsOption

GrantType

func WithJWTActorToken added in v3.65.0

ActorTokenSource

func WithJWTSubjectToken added in v3.65.0

SubjectTokenSource

func WithRequestTimeout added in v3.65.0

func WithRequestTimeout(timeout time.Duration) Oauth2TokenExchangeCredentialsOption

RequestTimeout

func WithRequestedTokenType added in v3.65.0

func WithRequestedTokenType(requestedTokenType string) Oauth2TokenExchangeCredentialsOption

RequestedTokenType

func WithResource added in v3.65.0

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

Resource

func WithScope added in v3.65.0

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

Scope

func WithSubjectToken added in v3.65.0

func WithSubjectToken(subjectToken credentials.TokenSource) Oauth2TokenExchangeCredentialsOption

SubjectTokenSource

func WithSyncExchangeTimeout added in v3.75.0

func WithSyncExchangeTimeout(timeout time.Duration) Oauth2TokenExchangeCredentialsOption

SyncExchangeTimeout

func WithTokenEndpoint added in v3.65.0

func WithTokenEndpoint(endpoint string) Oauth2TokenExchangeCredentialsOption

TokenEndpoint

type Token added in v3.65.0

type Token = credentials.Token

type TokenSource added in v3.65.0

type TokenSource = credentials.TokenSource

Jump to

Keyboard shortcuts

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