Skip to content

Commit

Permalink
provider: add STSTokenProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
mozillazg committed Aug 31, 2023
1 parent c57a438 commit ecd0068
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pkg/credentials/provider/ststoken_provider.go
@@ -0,0 +1,29 @@
package provider

import (
"context"
"errors"
)

type STSTokenProvider struct {
cred *Credentials
}

func NewSTSTokenProvider(accessKeyId, accessKeySecret, securityToken string) *STSTokenProvider {
return &STSTokenProvider{
cred: &Credentials{
AccessKeyId: accessKeyId,
AccessKeySecret: accessKeySecret,
SecurityToken: securityToken,
},
}
}

func (a *STSTokenProvider) Credentials(ctx context.Context) (*Credentials, error) {
if a.cred.AccessKeyId == "" || a.cred.AccessKeySecret == "" || a.cred.SecurityToken == "" {
return nil, NewNotEnableError(
errors.New("AccessKeyId, AccessKeySecret or SecurityToken is empty"))
}

return a.cred, nil
}

0 comments on commit ecd0068

Please sign in to comment.