Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Remove AWS4AuthLayer and HTTP.request extension #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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: 0 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ The AWSAuth package implements AWS authentication.
Currently this consists of AWS Signature v4 signing for HTTP requests sent to AWS.

```@docs
AWSAuth.AWS4AuthLayer
AWSAuth.SignatureV4.HTTP.request
AWSAuth.SignatureV4.sign!
```
2 changes: 1 addition & 1 deletion src/AWSAuth.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module AWSAuth

export SignatureV4, AWS4AuthLayer
export SignatureV4

include("signaturev4.jl")

Expand Down
30 changes: 2 additions & 28 deletions src/signaturev4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,10 @@ using Dates
using HTTP
using HTTP.Pairs
using HTTP.URIs
using HTTP: Headers, Layer, Request
using HTTP: Headers
using IniFile
using MbedTLS

export AWS4AuthLayer

"""
AWS4AuthLayer{Next} <: HTTP.Layer

Abstract type used by [`HTTP.request`](@ref) to add an
[AWS Signature v4](http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html)
authentication layer to the request.
"""
abstract type AWS4AuthLayer{Next<:Layer} <: Layer end

"""
HTTP.request(::Type{AWS4AuthLayer}, url::HTTP.URI, req::HTTP.Request, body) -> HTTP.Response

Perform the given request, adding a layer of AWS authentication using
[AWS Signature v4](http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).
An "Authorization" header to the request.
"""
function HTTP.request(::Type{AWS4AuthLayer{Next}}, url::URI, req::Request, body; kw...) where Next
if !haskey(kw, :aws_access_key_id) && !haskey(ENV, "AWS_ACCESS_KEY_ID")
kw = merge(dot_aws_credentials(), kw)
end
sign!(req.method, url, req.headers, req.body; kw...)
return HTTP.request(Next, url, req, body; kw...)
end

# Normalize whitespace to the form required in the canonical headers.
# Note that the expected format for multiline headers seems not to be explicitly
# documented, but Amazon provides a test case for it, so we'll match that behavior.
Expand Down Expand Up @@ -212,4 +186,4 @@ function dot_aws_credentials()::NamedTuple
return credentials
end

end # module AWS4AuthRequest
end # module