Skip to content

Commit

Permalink
Additional options
Browse files Browse the repository at this point in the history
  • Loading branch information
UgnineSirdis committed Apr 11, 2024
1 parent 8371f8d commit 9813cfd
Show file tree
Hide file tree
Showing 5 changed files with 400 additions and 57 deletions.
52 changes: 44 additions & 8 deletions credentials/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import (
"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials"
)

type Oauth2TokenExchangeCredentialsOption = credentials.Oauth2TokenExchangeCredentialsOption

type TokenSource = credentials.TokenSource

type Token = credentials.Token

// WithSourceInfo option append to credentials object the source info for reporting source info details on error case
func WithSourceInfo(sourceInfo string) credentials.SourceInfoOption {
return credentials.WithSourceInfo(sourceInfo)
Expand All @@ -20,45 +26,65 @@ func WithGrpcDialOptions(opts ...grpc.DialOption) credentials.StaticCredentialsO
}

// TokenEndpoint
func WithTokenEndpoint(endpoint string) credentials.Oauth2TokenExchangeCredentialsOption {
func WithTokenEndpoint(endpoint string) Oauth2TokenExchangeCredentialsOption {
return credentials.WithTokenEndpoint(endpoint)
}

// GrantType
func WithGrantType(grantType string) credentials.Oauth2TokenExchangeCredentialsOption {
func WithGrantType(grantType string) Oauth2TokenExchangeCredentialsOption {
return credentials.WithGrantType(grantType)
}

// Resource
func WithResource(resource string) credentials.Oauth2TokenExchangeCredentialsOption {
func WithResource(resource string) Oauth2TokenExchangeCredentialsOption {
return credentials.WithResource(resource)
}

// RequestedTokenType
func WithRequestedTokenType(requestedTokenType string) credentials.Oauth2TokenExchangeCredentialsOption {
func WithRequestedTokenType(requestedTokenType string) Oauth2TokenExchangeCredentialsOption {
return credentials.WithRequestedTokenType(requestedTokenType)
}

// Scope
func WithScope(scope ...string) credentials.Oauth2TokenExchangeCredentialsOption {
func WithScope(scope ...string) Oauth2TokenExchangeCredentialsOption {
return credentials.WithScope(scope...)
}

// RequestTimeout
func WithRequestTimeout(timeout time.Duration) credentials.Oauth2TokenExchangeCredentialsOption {
func WithRequestTimeout(timeout time.Duration) Oauth2TokenExchangeCredentialsOption {
return credentials.WithRequestTimeout(timeout)
}

// SubjectTokenSource
func WithSubjectToken(subjectToken credentials.TokenSource) credentials.Oauth2TokenExchangeCredentialsOption {
func WithSubjectToken(subjectToken credentials.TokenSource) Oauth2TokenExchangeCredentialsOption {
return credentials.WithSubjectToken(subjectToken)
}

// SubjectTokenSource
func WithFixedSubjectToken(token, tokenType string) Oauth2TokenExchangeCredentialsOption {
return credentials.WithFixedSubjectToken(token, tokenType)
}

// SubjectTokenSource
func WithJWTSubjectToken(opts ...credentials.JWTTokenSourceOption) Oauth2TokenExchangeCredentialsOption {
return credentials.WithJWTSubjectToken(opts...)
}

// ActorTokenSource
func WithActorToken(actorToken credentials.TokenSource) credentials.Oauth2TokenExchangeCredentialsOption {
func WithActorToken(actorToken credentials.TokenSource) Oauth2TokenExchangeCredentialsOption {
return credentials.WithActorToken(actorToken)
}

// ActorTokenSource
func WithFixedActorToken(token, tokenType string) Oauth2TokenExchangeCredentialsOption {
return credentials.WithFixedActorToken(token, tokenType)
}

// ActorTokenSource
func WithJWTActorToken(opts ...credentials.JWTTokenSourceOption) Oauth2TokenExchangeCredentialsOption {
return credentials.WithJWTActorToken(opts...)
}

// Audience
type oauthCredentialsAndJWTCredentialsOption interface {
credentials.Oauth2TokenExchangeCredentialsOption
Expand Down Expand Up @@ -103,3 +129,13 @@ func WithKeyID(id string) credentials.JWTTokenSourceOption {
func WithPrivateKey(key interface{}) credentials.JWTTokenSourceOption {
return credentials.WithPrivateKey(key)
}

// PrivateKey
func WithRSAPrivateKeyPEMContent(key []byte) credentials.JWTTokenSourceOption {
return credentials.WithRSAPrivateKeyPEMContent(key)
}

// PrivateKey
func WithRSAPrivateKeyPEMFile(path string) credentials.JWTTokenSourceOption {
return credentials.WithRSAPrivateKeyPEMFile(path)
}
Loading

0 comments on commit 9813cfd

Please sign in to comment.