Struct: credentials.Expiry

import "../ibm-cos-sdk-go/aws/credentials"

Overview

A Expiry provides shared expiration logic to be used by credentials providers to implement expiry functionality.

The best method to use this struct is as an anonymous field within the provider's struct.

Example:

type EC2RoleProvider struct { Expiry ... }

Implemented Interfaces

s3crypto.Cipher, credentials.Expirer, s3manager.ReadSeekerWriteTo, s3manager.WriterReadFrom

Method Summary collapse

Method Details

func (e *Expiry) ExpiresAt() time.Time

ExpiresAt returns the expiration time of the credential



207
208
209
// File 'aws/credentials/credentials.go', line 207

func (e *Expiry) ExpiresAt() time.Time { return e.expiration }

func (e *Expiry) IsExpired() bool

IsExpired returns if the credentials are expired.



198
199
200
201
202
203
204
// File 'aws/credentials/credentials.go', line 198

func (e *Expiry) IsExpired() bool { curTime := e.CurrentTime if curTime == nil { curTime = time.Now } return e.expiration.Before(curTime()) }

func (e *Expiry) SetExpiration(expiration time.Time, window time.Duration)

SetExpiration sets the expiration IsExpired will check when called.

If window is greater than 0 the expiration time will be reduced by the window value.

Using a window is helpful to trigger credentials to expire sooner than the expiration time given to ensure no requests are made with expired tokens.



188
189
190
191
192
193
194
195
// File 'aws/credentials/credentials.go', line 188

func (e *Expiry) SetExpiration(expiration time.Time, window time.Duration) { // Passed in expirations should have the monotonic clock values stripped. // This ensures time comparisons will be based on wall-time. e.expiration = expiration.Round(0) if window > 0 { e.expiration = e.expiration.Add(-window) } }