auth.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package auth
  2. import (
  3. "github.com/aws/smithy-go/auth"
  4. smithyhttp "github.com/aws/smithy-go/transport/http"
  5. )
  6. // HTTPAuthScheme is the SDK's internal implementation of smithyhttp.AuthScheme
  7. // for pre-existing implementations where the signer was added to client
  8. // config. SDK clients will key off of this type and ensure per-operation
  9. // updates to those signers persist on the scheme itself.
  10. type HTTPAuthScheme struct {
  11. schemeID string
  12. signer smithyhttp.Signer
  13. }
  14. var _ smithyhttp.AuthScheme = (*HTTPAuthScheme)(nil)
  15. // NewHTTPAuthScheme returns an auth scheme instance with the given config.
  16. func NewHTTPAuthScheme(schemeID string, signer smithyhttp.Signer) *HTTPAuthScheme {
  17. return &HTTPAuthScheme{
  18. schemeID: schemeID,
  19. signer: signer,
  20. }
  21. }
  22. // SchemeID identifies the auth scheme.
  23. func (s *HTTPAuthScheme) SchemeID() string {
  24. return s.schemeID
  25. }
  26. // IdentityResolver gets the identity resolver for the auth scheme.
  27. func (s *HTTPAuthScheme) IdentityResolver(o auth.IdentityResolverOptions) auth.IdentityResolver {
  28. return o.GetIdentityResolver(s.schemeID)
  29. }
  30. // Signer gets the signer for the auth scheme.
  31. func (s *HTTPAuthScheme) Signer() smithyhttp.Signer {
  32. return s.signer
  33. }
  34. // WithSigner returns a new instance of the auth scheme with the updated signer.
  35. func (s *HTTPAuthScheme) WithSigner(signer smithyhttp.Signer) *HTTPAuthScheme {
  36. return NewHTTPAuthScheme(s.schemeID, signer)
  37. }