on master help sign in
Drop OAuth1 and AWS request signing

These should be implemented separately. AWS signing doesn't play well with all ‘RequestBody’ options for example, so it should be rather an external package that would require more manual work from user.

commitbd509a6cb98a20bb5c0931ada714af1c28a4805f authormrkkrp <markkarpov@opmbx.org> dateWed 9 Nov 2016, 23:56 (10 years ago) parentb94e47f
6 files changed+16−104
.travis.yml+1−1 Network/HTTP/Req.hs−28 Network/HTTP/Req/AWS.hs−28 Network/HTTP/Req/OAuth1.hs−28 pure-tests/Network/HTTP/ReqSpec.hs−4 req.cabal+15−15
.travis.yml+1−1
@@ -33,7 +33,7 @@ script:
3333 - cabal build
3434 - cabal test --show-details=always
3535 - cabal sdist
36− - cabal haddock | grep "100%" | wc -l | grep "3"
36+ - cabal haddock | grep "100%" | wc -l | grep "1"
3737
3838after_script:
3939 - cabal install hpc-coveralls
Network/HTTP/Req.hs−28
@@ -168,10 +168,8 @@ module Network.HTTP.Req
168168 -- *** Authentication
169169 -- $authentication
170170 , basicAuth
171− , oAuth1
172171 , oAuth2Bearer
173172 , oAuth2Token
174− , awsAuth
175173 -- *** Other
176174 , port
177175 , decompress
@@ -237,8 +235,6 @@ import qualified Network.Connection as NC
237235import qualified Network.HTTP.Client as L
238236import qualified Network.HTTP.Client.Internal as LI
239237import qualified Network.HTTP.Client.TLS as L
240−import qualified Network.HTTP.Req.AWS as AWS
241−import qualified Network.HTTP.Req.OAuth1 as OAuth1
242238import qualified Network.HTTP.Types as Y
243239
244240#if MIN_VERSION_base(4,9,0)
@@ -1059,19 +1055,6 @@ basicAuth
10591055basicAuth username password = asFinalizer
10601056 (L.applyBasicAuth username password)
10611057
1062−-- | OAuth 1 authentication 'Option'.
1063−--
1064−-- See also: <https://en.wikipedia.org/wiki/OAuth>.
1065−
1066−oAuth1
1067− :: ByteString -- ^ Consumer token
1068− -> ByteString -- ^ Consumer secret
1069− -> ByteString -- ^ OAuth token
1070− -> ByteString -- ^ OAuth token secret
1071− -> Option scheme
1072−oAuth1 ctoken csecret otoken osecret = asFinalizer
1073− (OAuth1.signRequest ctoken csecret otoken osecret)
1074−
10751058-- | The 'Option' adds an OAuth2 bearer token. This is treated by many
10761059-- services as the equivalent of a username and password.
10771060--
@@ -1103,17 +1086,6 @@ oAuth2Token
11031086oAuth2Token token = asFinalizer
11041087 (attachHeader "Authorization" ("token " <> token))
11051088
1106−-- | The 'Option' adds AWS v4 request signature.
1107−--
1108−-- See also: <https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html>.
1109−
1110−awsAuth
1111− :: ByteString -- ^ AWS access key
1112− -> ByteString -- ^ AWS secret access key
1113− -> Option 'Https -- ^ Auth 'Option'
1114−awsAuth accessKey secretKey = asFinalizer
1115− (AWS.signRequest accessKey secretKey)
1116−
11171089----------------------------------------------------------------------------
11181090-- Request — Optional parameters — Other
11191091
Network/HTTP/Req/AWS.hsdeleted−28
@@ -1,28 +0,0 @@
1−-- |
2−-- Module : Network.HTTP.Req.AWS
3−-- Copyright : © 2016 Mark Karpov
4−-- License : BSD 3 clause
5−--
6−-- Maintainer : Mark Karpov <markkarpov@openmailbox.org>
7−-- Stability : experimental
8−-- Portability : portable
9−--
10−-- Implementation of AWS v4 request signature.
11−
12−module Network.HTTP.Req.AWS
13− ( signRequest )
14−where
15−
16−import Data.ByteString (ByteString)
17−import Network.HTTP.Client
18−
19−-- | Sign a given request following AWS v4 request signing specification:
20−--
21−-- See also: <https://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html>
22−
23−signRequest
24− :: ByteString -- ^ AWS access key
25− -> ByteString -- ^ AWS secret access key
26− -> Request -- ^ 'Request' to sign
27− -> Request -- ^ Resulting request
28−signRequest = undefined -- TODO
Network/HTTP/Req/OAuth1.hsdeleted−28
@@ -1,28 +0,0 @@
1−-- |
2−-- Module : Network.HTTP.Req.OAuth1
3−-- Copyright : © 2016 Mark Karpov
4−-- License : BSD 3 clause
5−--
6−-- Maintainer : Mark Karpov <markkarpov@openmailbox.org>
7−-- Stability : experimental
8−-- Portability : portable
9−--
10−-- Implementation of OAuth 1.0 signing.
11−
12−module Network.HTTP.Req.OAuth1
13− ( signRequest )
14−where
15−
16−import Data.ByteString (ByteString)
17−import Network.HTTP.Client
18−
19−-- | Sign a given request using OAuth 1.0 signing algorithm.
20−
21−signRequest
22− :: ByteString -- ^ Consumer token
23− -> ByteString -- ^ Consumer secret
24− -> ByteString -- ^ OAuth token
25− -> ByteString -- ^ OAuth token secret
26− -> Request -- ^ 'Request' to sign
27− -> Request -- ^ Resulting request
28−signRequest = undefined -- TODO
pure-tests/Network/HTTP/ReqSpec.hs−4
@@ -249,8 +249,6 @@ spec = do
249249 (basicAuth username0 password0 <> basicAuth username1 password1)
250250 lookup "Authorization" (L.requestHeaders request) `shouldBe`
251251 pure (basicAuthHeader username0 password0)
252− describe "oAuth1" $
253− it "does something right" pending -- TODO
254252 describe "oAuth2Bearer" $ do
255253 it "sets Authorization header to correct value" $
256254 property $ \token -> do
@@ -297,8 +295,6 @@ spec = do
297295 (oAuth2Token token0 <> oAuth2Token token1)
298296 lookup "Authorization" (L.requestHeaders request) `shouldBe`
299297 pure ("token " <> token0)
300− describe "awsAuth" $
301− it "does something right" pending -- TODO
302298 describe "port" $
303299 it "sets port overwriting the defaults" $
304300 property $ \n -> do
req.cabal+15−15
@@ -58,25 +58,25 @@ flag dev
5858 default: False
5959
6060library
61− build-depends: aeson >= 0.11 && < 1.1
62− , base >= 4.7 && < 5.0
63− , blaze-builder >= 0.3 && < 0.5
64− , bytestring >= 0.10.8 && < 0.11
65− , case-insensitive >= 0.2 && < 1.3
66− , connection >= 0.2.2 && < 0.3
61+ build-depends: aeson >= 0.11 && < 1.1
62+ , base >= 4.7 && < 5.0
63+ , blaze-builder >= 0.3 && < 0.5
64+ , bytestring >= 0.10.8 && < 0.11
65+ , case-insensitive >= 0.2 && < 1.3
66+ , connection >= 0.2.2 && < 0.3
67+ , cryptonite
6768 , data-default-class
68− , http-api-data >= 0.2 && < 0.4
69− , http-client >= 0.5 && < 0.6
70− , http-client-tls >= 0.3.2 && < 0.4
71− , http-types >= 0.8 && < 10.0
72− , mtl >= 2.0 && < 3.0
73− , text >= 0.2 && < 1.3
74− , transformers >= 0.4 && < 0.6
69+ , http-api-data >= 0.2 && < 0.4
70+ , http-client >= 0.5 && < 0.6
71+ , http-client-tls >= 0.3.2 && < 0.4
72+ , http-types >= 0.8 && < 10.0
73+ , mtl >= 2.0 && < 3.0
74+ , text >= 0.2 && < 1.3
75+ , time >= 1.2 && < 1.7
76+ , transformers >= 0.4 && < 0.6
7577 if !impl(ghc >= 8.0)
7678 build-depends: semigroups == 0.18.*
7779 exposed-modules: Network.HTTP.Req
78− other-modules: Network.HTTP.Req.AWS
79− , Network.HTTP.Req.OAuth1
8080 if flag(dev)
8181 ghc-options: -Wall -Werror
8282 else