github.com/ydb-platform/ydb-go-sdk/v3@v3.89.2/credentials/options.go (about)

     1  package credentials
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/golang-jwt/jwt/v4"
     7  	"google.golang.org/grpc"
     8  
     9  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/credentials"
    10  )
    11  
    12  type Oauth2TokenExchangeCredentialsOption = credentials.Oauth2TokenExchangeCredentialsOption
    13  
    14  type TokenSource = credentials.TokenSource
    15  
    16  type Token = credentials.Token
    17  
    18  // WithSourceInfo option append to credentials object the source info for reporting source info details on error case
    19  func WithSourceInfo(sourceInfo string) credentials.SourceInfoOption {
    20  	return credentials.WithSourceInfo(sourceInfo)
    21  }
    22  
    23  // WithGrpcDialOptions option append to static credentials object GRPC dial options
    24  func WithGrpcDialOptions(opts ...grpc.DialOption) credentials.StaticCredentialsOption {
    25  	return credentials.WithGrpcDialOptions(opts...)
    26  }
    27  
    28  // TokenEndpoint
    29  func WithTokenEndpoint(endpoint string) Oauth2TokenExchangeCredentialsOption {
    30  	return credentials.WithTokenEndpoint(endpoint)
    31  }
    32  
    33  // GrantType
    34  func WithGrantType(grantType string) Oauth2TokenExchangeCredentialsOption {
    35  	return credentials.WithGrantType(grantType)
    36  }
    37  
    38  // Resource
    39  func WithResource(resource string, resources ...string) Oauth2TokenExchangeCredentialsOption {
    40  	return credentials.WithResource(resource, resources...)
    41  }
    42  
    43  // RequestedTokenType
    44  func WithRequestedTokenType(requestedTokenType string) Oauth2TokenExchangeCredentialsOption {
    45  	return credentials.WithRequestedTokenType(requestedTokenType)
    46  }
    47  
    48  // Scope
    49  func WithScope(scope string, scopes ...string) Oauth2TokenExchangeCredentialsOption {
    50  	return credentials.WithScope(scope, scopes...)
    51  }
    52  
    53  // RequestTimeout
    54  func WithRequestTimeout(timeout time.Duration) Oauth2TokenExchangeCredentialsOption {
    55  	return credentials.WithRequestTimeout(timeout)
    56  }
    57  
    58  // SyncExchangeTimeout
    59  func WithSyncExchangeTimeout(timeout time.Duration) Oauth2TokenExchangeCredentialsOption {
    60  	return credentials.WithSyncExchangeTimeout(timeout)
    61  }
    62  
    63  // SubjectTokenSource
    64  func WithSubjectToken(subjectToken credentials.TokenSource) Oauth2TokenExchangeCredentialsOption {
    65  	return credentials.WithSubjectToken(subjectToken)
    66  }
    67  
    68  // SubjectTokenSource
    69  func WithFixedSubjectToken(token, tokenType string) Oauth2TokenExchangeCredentialsOption {
    70  	return credentials.WithFixedSubjectToken(token, tokenType)
    71  }
    72  
    73  // SubjectTokenSource
    74  func WithJWTSubjectToken(opts ...credentials.JWTTokenSourceOption) Oauth2TokenExchangeCredentialsOption {
    75  	return credentials.WithJWTSubjectToken(opts...)
    76  }
    77  
    78  // ActorTokenSource
    79  func WithActorToken(actorToken credentials.TokenSource) Oauth2TokenExchangeCredentialsOption {
    80  	return credentials.WithActorToken(actorToken)
    81  }
    82  
    83  // ActorTokenSource
    84  func WithFixedActorToken(token, tokenType string) Oauth2TokenExchangeCredentialsOption {
    85  	return credentials.WithFixedActorToken(token, tokenType)
    86  }
    87  
    88  // ActorTokenSource
    89  func WithJWTActorToken(opts ...credentials.JWTTokenSourceOption) Oauth2TokenExchangeCredentialsOption {
    90  	return credentials.WithJWTActorToken(opts...)
    91  }
    92  
    93  // Audience
    94  type oauthCredentialsAndJWTCredentialsOption interface {
    95  	credentials.Oauth2TokenExchangeCredentialsOption
    96  	credentials.JWTTokenSourceOption
    97  }
    98  
    99  func WithAudience(audience string, audiences ...string) oauthCredentialsAndJWTCredentialsOption {
   100  	return credentials.WithAudience(audience, audiences...)
   101  }
   102  
   103  // Issuer
   104  func WithIssuer(issuer string) credentials.JWTTokenSourceOption {
   105  	return credentials.WithIssuer(issuer)
   106  }
   107  
   108  // Subject
   109  func WithSubject(subject string) credentials.JWTTokenSourceOption {
   110  	return credentials.WithSubject(subject)
   111  }
   112  
   113  // ID
   114  func WithID(id string) credentials.JWTTokenSourceOption {
   115  	return credentials.WithID(id)
   116  }
   117  
   118  // TokenTTL
   119  func WithTokenTTL(ttl time.Duration) credentials.JWTTokenSourceOption {
   120  	return credentials.WithTokenTTL(ttl)
   121  }
   122  
   123  // KeyID
   124  func WithKeyID(id string) credentials.JWTTokenSourceOption {
   125  	return credentials.WithKeyID(id)
   126  }
   127  
   128  // SigningMethod
   129  func WithSigningMethod(method jwt.SigningMethod) credentials.JWTTokenSourceOption {
   130  	return credentials.WithSigningMethod(method)
   131  }
   132  
   133  // SigningMethod
   134  func WithSigningMethodName(method string) credentials.JWTTokenSourceOption {
   135  	return credentials.WithSigningMethodName(method)
   136  }
   137  
   138  // PrivateKey
   139  func WithPrivateKey(key interface{}) credentials.JWTTokenSourceOption {
   140  	return credentials.WithPrivateKey(key)
   141  }
   142  
   143  // PrivateKey
   144  // For RSA signing methods: RS256, RS384, RS512, PS256, PS384, PS512
   145  func WithRSAPrivateKeyPEMContent(key []byte) credentials.JWTTokenSourceOption {
   146  	return credentials.WithRSAPrivateKeyPEMContent(key)
   147  }
   148  
   149  // PrivateKey
   150  // For RSA signing methods: RS256, RS384, RS512, PS256, PS384, PS512
   151  func WithRSAPrivateKeyPEMFile(path string) credentials.JWTTokenSourceOption {
   152  	return credentials.WithRSAPrivateKeyPEMFile(path)
   153  }
   154  
   155  // PrivateKey
   156  // For EC signing methods: ES256, ES384, ES512
   157  func WithECPrivateKeyPEMContent(key []byte) credentials.JWTTokenSourceOption {
   158  	return credentials.WithECPrivateKeyPEMContent(key)
   159  }
   160  
   161  // PrivateKey
   162  // For EC signing methods: ES256, ES384, ES512
   163  func WithECPrivateKeyPEMFile(path string) credentials.JWTTokenSourceOption {
   164  	return credentials.WithECPrivateKeyPEMFile(path)
   165  }
   166  
   167  // Key
   168  // For HMAC signing methods: HS256, HS384, HS512
   169  func WithHMACSecretKey(key []byte) credentials.JWTTokenSourceOption {
   170  	return credentials.WithHMACSecretKey(key)
   171  }
   172  
   173  // Key
   174  // For HMAC signing methods: HS256, HS384, HS512
   175  func WithHMACSecretKeyBase64Content(base64KeyContent string) credentials.JWTTokenSourceOption {
   176  	return credentials.WithHMACSecretKeyBase64Content(base64KeyContent)
   177  }
   178  
   179  // Key
   180  // For HMAC signing methods: HS256, HS384, HS512
   181  func WithHMACSecretKeyFile(path string) credentials.JWTTokenSourceOption {
   182  	return credentials.WithHMACSecretKeyFile(path)
   183  }
   184  
   185  // Key
   186  // For HMAC signing methods: HS256, HS384, HS512
   187  func WithHMACSecretKeyBase64File(path string) credentials.JWTTokenSourceOption {
   188  	return credentials.WithHMACSecretKeyBase64File(path)
   189  }