Handbook
Glossary
sign-aws-request ( request service region creds -- request )
Vocabulary
aws
Inputs
request
an
object
service
an
object
region
an
object
creds
an
object
Outputs
request
an
object
Definition
USING:
accessors
checksums
checksums.hmac
checksums.sha
formatting
hex-strings
http
kernel
urls
urls.encoding
;
IN:
aws
::
sign-aws-request
( request service region creds -- request )
request
"Connection"
delete-header
request
url>>
host>>
"Host"
set-header
aws-timestamp
"X-Amz-Date"
set-header
"application/json"
"accept"
set-header
creds
session-token>>
"x-amz-security-token"
set-header
url>>
"DescribeKeyPairs"
"Action"
set-query-param
drop
request
post-data>>
sha-256
checksum-bytes
bytes>hex-string
:>
body-hex-hash request
dup
post-data>>
[
body-hex-hash
"x-amz-content-sha256"
set-header
]
when
header>>
[
make-canonical-headers
]
[
canonical-header-keys
]
bi
:>
( canonical-headers-string signed-headers-string )
aws-date
region service
"%s/%s/%s/aws4_request"
sprintf
:>
credential-scope-string request
[
method>>
]
[
url>>
path>>
]
[
url>>
query>>
assoc>query
]
tri
canonical-headers-string signed-headers-string body-hex-hash
"%s\n%s\n%s\n%s\n%s\n%s"
sprintf
sha-256
checksum-bytes
bytes>hex-string
:>
canonical-request-hash
"AWS4-HMAC-SHA256"
aws-timestamp
credential-scope-string
canonical-request-hash
"%s\n%s\n%s\n%s"
sprintf
:>
string-to-sign
"AWS4-HMAC-SHA256"
creds
access-key-id>>
credential-scope-string signed-headers-string string-to-sign
service region creds
aws4-signing-key
sha-256
hmac-bytes
bytes>hex-string
"%s Credential=%s/%s, SignedHeaders=%s, Signature=%s"
sprintf
:>
authorization-header-string request
authorization-header-string
"Authorization"
set-header
"close"
"Connection"
set-header
;