summaryrefslogtreecommitdiff
path: root/aws
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2021-08-10 19:04:28 +0200
committerRicardo Wurmus <rekado@elephly.net>2021-08-10 19:04:28 +0200
commitf32bea12333e1054b97ab50e58a72636edabb5b7 (patch)
tree63d1e1dcd899ae000804c80386559fd07fa0dbdc /aws
parent6c765e5e1d28d44413ed095885eb40e8d3d27ea5 (diff)
request: Move credential-scope to separate procedure.HEADmaster
Diffstat (limited to 'aws')
-rw-r--r--aws/request.scm19
1 files changed, 12 insertions, 7 deletions
diff --git a/aws/request.scm b/aws/request.scm
index d82df4c..f67d1ef 100644
--- a/aws/request.scm
+++ b/aws/request.scm
@@ -182,6 +182,12 @@ strings."
(signing-key (sign kservice "aws4_request")))
(hexify (sign signing-key string-to-sign))))
+(define (credential-scope date-stamp region service-name)
+ (string-join (list date-stamp
+ region
+ service-name
+ "aws4_request") "/"))
+
(define* (sign-headers headers
#:key
(method "GET")
@@ -238,15 +244,14 @@ used for presigned URLs."
signed-headers
payload-hash)
"\n"))
- (credential-scope
- (string-join (list date-stamp
- region
- service-name
- "aws4_request") "/"))
+ (scope
+ (credential-scope date-stamp
+ region
+ service-name))
(string-to-sign
(string-join (list %algorithm
amz-date
- credential-scope
+ scope
(hexify (sha256 (string->utf8 canonical-request))))
"\n"))
(signature
@@ -262,7 +267,7 @@ used for presigned URLs."
;; signed-headers values, as noted earlier. Order here is not
;; significant.
(cons `(authorization . (,(string->symbol %algorithm)
- (Credential . ,(string-append access-key "/" credential-scope))
+ (Credential . ,(string-append access-key "/" scope))
(SignedHeaders . ,signed-headers)
(Signature . ,signature)))
(filter cdr headers))))