identity.go (1290B)
1 package auth 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/aws/smithy-go" 8 ) 9 10 // Identity contains information that identifies who the user making the 11 // request is. 12 type Identity interface { 13 Expiration() time.Time 14 } 15 16 // IdentityResolver defines the interface through which an Identity is 17 // retrieved. 18 type IdentityResolver interface { 19 GetIdentity(context.Context, smithy.Properties) (Identity, error) 20 } 21 22 // IdentityResolverOptions defines the interface through which an entity can be 23 // queried to retrieve an IdentityResolver for a given auth scheme. 24 type IdentityResolverOptions interface { 25 GetIdentityResolver(schemeID string) IdentityResolver 26 } 27 28 // AnonymousIdentity is a sentinel to indicate no identity. 29 type AnonymousIdentity struct{} 30 31 var _ Identity = (*AnonymousIdentity)(nil) 32 33 // Expiration returns the zero value for time, as anonymous identity never 34 // expires. 35 func (*AnonymousIdentity) Expiration() time.Time { 36 return time.Time{} 37 } 38 39 // AnonymousIdentityResolver returns AnonymousIdentity. 40 type AnonymousIdentityResolver struct{} 41 42 var _ IdentityResolver = (*AnonymousIdentityResolver)(nil) 43 44 // GetIdentity returns AnonymousIdentity. 45 func (*AnonymousIdentityResolver) GetIdentity(_ context.Context, _ smithy.Properties) (Identity, error) { 46 return &AnonymousIdentity{}, nil 47 }