Skip to content

Commit

Permalink
fix: fixed sts client caching (#195)
Browse files Browse the repository at this point in the history
fix: fixed Sts Client Caching

Co-authored-by: Ayushi Sharma <[email protected]>
  • Loading branch information
ayushi0014 and Ayushi Sharma authored Dec 23, 2024
1 parent df093f6 commit dd17ff7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/stsClient/stsClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewSTSClient(userAccessKeyID, userSecretAccessKey, regionID string) (*clien
}

func (s *Sts) GetSTSClient(clientIdentifier, userAccessKeyID, userSecret, regionID string) (*client.Client, error) {
if c, ok := s.clients[clientIdentifier]; ok {
if c, ok := s.clients[clientIdentifier]; ok && s.IsSTSTokenValid(clientIdentifier) {
return c.client, nil
}

Expand Down
8 changes: 3 additions & 5 deletions plugins/providers/maxcompute/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,8 @@ func (p *provider) getRamRoleAndStsClientID(clientType string, creds *credential
}

func (p *provider) getCachedOdpsClient(ramRole, stsClientID, urn string) (*odps.Odps, bool) {
if c, ok := p.odpsClients[ramRole]; ok {
if c.stsClientExist && p.sts.IsSTSTokenValid(stsClientID) {
return c.client, true
}
c, ok := p.odpsClients[ramRole]
if ramRole != "" && ok && c.stsClientExist && p.sts.IsSTSTokenValid(stsClientID) {
return c.client, true
}

Expand All @@ -474,7 +472,7 @@ func (p *provider) getCachedOdpsClient(ramRole, stsClientID, urn string) (*odps.

func (p *provider) getCachedRestClient(ramRole, stsClientID, urn string) (*maxcompute.Client, bool) {
c, ok := p.restClients[ramRole]
if ok && c.stsClientExist && p.sts.IsSTSTokenValid(stsClientID) {
if ramRole != "" && ok && c.stsClientExist && p.sts.IsSTSTokenValid(stsClientID) {
return c.client, true
}

Expand Down
6 changes: 2 additions & 4 deletions plugins/providers/oss/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,8 @@ func (p *provider) getOSSClient(pc *domain.ProviderConfig, ramRole string) (*oss
}

func (p *provider) getCachedOSSClient(ramRole, stsClientID, urn string) (*oss.Client, bool) {
if c, ok := p.ossClients[ramRole]; ok {
if c.stsClientExist && p.sts.IsSTSTokenValid(stsClientID) {
return c.client, true
}
c, ok := p.ossClients[ramRole]
if ramRole != "" && ok && c.stsClientExist && p.sts.IsSTSTokenValid(stsClientID) {
return c.client, true
}

Expand Down

0 comments on commit dd17ff7

Please sign in to comment.