fc @ s d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m Z m Z d Z d Z d Z
d e j j f d YZ
d S( iN( t urlparse( t quotet unquotes UNSIGNED-PAYLOADc C s% t j | | j d t j j S( sf
Copied from https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
s utf-8( t hmact newt encodet hashlibt sha256t digest( t keyt msg( ( sN /usr/lib/python2.7/site-packages/redhat_support_lib/infrastructure/aws_auth.pyt sign) s c C sM t d | j d | } t | | } t | | } t | d } | S( sf
Copied from https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
t AWS4s utf-8t aws4_request( R R ( R t dateStampt
regionNamet serviceNamet kDatet kRegiont kServicet kSigning( ( sN /usr/lib/python2.7/site-packages/redhat_support_lib/infrastructure/aws_auth.pyt getSignatureKey0 s
t AWSRequestsAuthc B s\ e Z d Z d d d d d Z d Z d Z d Z e d Z e d Z
RS( s
Auth class that allows us to connect to AWS services
via Amazon's signature version 4 signing process
Adapted from https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
c
C sU | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ | | _ d S( s
Example usage for talking to an AWS Elasticsearch Service:
AWSRequestsAuth(aws_access_key='YOURKEY',
aws_secret_access_key='YOURSECRET',
aws_host='search-service-foobar.us-east-1.es.amazonaws.com',
aws_region='us-east-1',
aws_service='es',
aws_token='...')
The aws_token is optional and is used only if you are using STS
temporary credentials.
N( t aws_access_keyt aws_secret_access_keyt aws_hostt
aws_regiont servicet aws_tokent ss_algorithmt encryption_keyt encryption_key_md5(
t selfR R R R t aws_serviceR R R R ( ( sN /usr/lib/python2.7/site-packages/redhat_support_lib/infrastructure/aws_auth.pyt __init__C s c C s# | j | } | j j | | S( s
Adds the authorization headers required by Amazon's signature
version 4 signing process to the request.
Adapted from https://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
( t get_aws_request_headers_handlert headerst update( R t rt aws_headers( ( sN /usr/lib/python2.7/site-packages/redhat_support_lib/infrastructure/aws_auth.pyt __call__d s c C s+ | j d | d | j d | j d | j S( sN
Override get_aws_request_headers_handler() if you have a
subclass that needs to call get_aws_request_headers() with
an arbitrary set of AWS credentials. The default implementation
calls get_aws_request_headers() with self.aws_access_key,
self.aws_secret_access_key, and self.aws_token
R&