Skip to content

Commit

Permalink
Make sure Token and Expiry can be set properly (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored and nitisht committed Jan 28, 2019
1 parent 17db16b commit 32eb22e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 30 deletions.
19 changes: 4 additions & 15 deletions pkg/credentials/sts_client_grants.go
Expand Up @@ -60,19 +60,8 @@ type ClientGrantsResult struct {

// ClientGrantsToken - client grants token with expiry.
type ClientGrantsToken struct {
token string
expiry int
}

// Token - access token returned after authenticating client grants.
func (c *ClientGrantsToken) Token() string {
return c.token
}

// Expiry - expiry for the access token returned after authenticating
// client grants.
func (c *ClientGrantsToken) Expiry() string {
return fmt.Sprintf("%d", c.expiry)
Token string
Expiry int
}

// A STSClientGrants retrieves credentials from Minio service, and keeps track if
Expand Down Expand Up @@ -123,8 +112,8 @@ func getClientGrantsCredentials(clnt *http.Client, endpoint string,

v := url.Values{}
v.Set("Action", "AssumeRoleWithClientGrants")
v.Set("Token", accessToken.Token())
v.Set("DurationSeconds", accessToken.Expiry())
v.Set("Token", accessToken.Token)
v.Set("DurationSeconds", fmt.Sprintf("%d", accessToken.Expiry))
v.Set("Version", "2011-06-15")

u, err := url.Parse(endpoint)
Expand Down
19 changes: 4 additions & 15 deletions pkg/credentials/sts_web_identity.go
Expand Up @@ -53,19 +53,8 @@ type WebIdentityResult struct {

// WebIdentityToken - web identity token with expiry.
type WebIdentityToken struct {
token string
expiry int
}

// Token - access token returned after authenticating web identity.
func (c *WebIdentityToken) Token() string {
return c.token
}

// Expiry - expiry for the access token returned after authenticating
// web identity.
func (c *WebIdentityToken) Expiry() string {
return fmt.Sprintf("%d", c.expiry)
Token string
Expiry int
}

// A STSWebIdentity retrieves credentials from Minio service, and keeps track if
Expand Down Expand Up @@ -115,8 +104,8 @@ func getWebIdentityCredentials(clnt *http.Client, endpoint string,

v := url.Values{}
v.Set("Action", "AssumeRoleWithWebIdentity")
v.Set("WebIdentityToken", idToken.Token())
v.Set("DurationSeconds", idToken.Expiry())
v.Set("WebIdentityToken", idToken.Token)
v.Set("DurationSeconds", fmt.Sprintf("%d", idToken.Expiry))
v.Set("Version", "2011-06-15")

u, err := url.Parse(endpoint)
Expand Down

0 comments on commit 32eb22e

Please sign in to comment.