Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
/checkouts
/classes
/target
/.idea
*.iml
14 changes: 8 additions & 6 deletions src/aws_simple_sign/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,13 @@
{:ref-time (java.util.Date.) ; timestamp incorporated into the signature
:expires \"3600\" ; signature expires x seconds after ref-time
:region \"us-east-1\" ; signature locked to AWS region
:method \"GET\"} ; http method the url is to be called with
:method \"GET\" ; http method the url is to be called with
:query-params {}} ; extra query params e.g. {\"response-content-type\" \"text/csv\"}

By default credentials are read from standard AWS location."
([credentials url]
(presign credentials url {}))
([credentials url {:keys [ref-time region expires method]
([credentials url {:keys [ref-time region expires method query-params]
:or {ref-time (Date.) region "us-east-1" expires "3600" method "GET"}}]
(let [url-obj (URL. url)
port (.getPort url-obj)
Expand All @@ -216,10 +217,11 @@
service "s3"
timestamp (.format formatter (.toInstant ^Date ref-time))
scope (str (subs timestamp 0 8) "/" region "/" service "/aws4_request")
query-params (conj {"X-Amz-Algorithm" algorithm
"X-Amz-Credential" (str (:aws/access-key-id credentials) "/" scope)
"X-Amz-Date" timestamp
"X-Amz-SignedHeaders" "host"}
query-params (conj (merge query-params
{"X-Amz-Algorithm" algorithm
"X-Amz-Credential" (str (:aws/access-key-id credentials) "/" scope)
"X-Amz-Date" timestamp
"X-Amz-SignedHeaders" "host"})
(when-let [session-token (:aws/session-token credentials)]
["X-Amz-Security-Token" session-token])
(when expires
Expand Down