on ec9d13c help sign in
stackage/patching/patches/authenticate-oauth-1.4.0.8.patch
147 lines 6.8 kB history raw
1diff -ru orig/authenticate-oauth.cabal new/authenticate-oauth.cabal
2--- orig/authenticate-oauth.cabal 2014-02-21 07:19:28.878548521 +0200
3+++ new/authenticate-oauth.cabal 2014-02-21 07:19:28.000000000 +0200
4@@ -19,7 +19,7 @@
5 , transformers >= 0.1 && < 0.4
6 , bytestring >= 0.9
7 , crypto-pubkey-types >= 0.1 && < 0.5
8- , RSA >= 1.2 && < 1.3
9+ , RSA >= 1.2 && < 2.1
10 , time
11 , data-default
12 , base64-bytestring >= 0.1 && < 1.1
13diff -ru orig/Web/Authenticate/OAuth.hs new/Web/Authenticate/OAuth.hs
14--- orig/Web/Authenticate/OAuth.hs 2014-02-21 07:19:28.874548521 +0200
15+++ new/Web/Authenticate/OAuth.hs 2014-02-21 07:19:28.000000000 +0200
16@@ -1,5 +1,5 @@
17-{-# LANGUAGE CPP, DeriveDataTypeable, FlexibleContexts, MultiParamTypeClasses #-}
18-{-# LANGUAGE OverloadedStrings, StandaloneDeriving #-}
19+{-# LANGUAGE DeriveDataTypeable, OverloadedStrings, StandaloneDeriving, FlexibleContexts #-}
20+{-# LANGUAGE CPP #-}
21 {-# OPTIONS_GHC -Wall -fno-warn-orphans #-}
22 module Web.Authenticate.OAuth
23 ( -- * Data types
24@@ -15,48 +15,50 @@
25 authorizeUrl, authorizeUrl', getAccessToken, getTemporaryCredential,
26 getTokenCredential, getTemporaryCredentialWithScope,
27 getAccessTokenProxy, getTemporaryCredentialProxy,
28- getTokenCredentialProxy,
29+ getTokenCredentialProxy,
30 getAccessToken', getTemporaryCredential',
31 -- * Utility Methods
32 paramEncode, addScope, addMaybeProxy
33 ) where
34-import Blaze.ByteString.Builder (toByteString, Builder)
35-import Codec.Crypto.RSA (ha_SHA1, rsassa_pkcs1_v1_5_sign)
36-import Control.Exception
37-import Control.Monad
38-import Control.Monad.IO.Class (MonadIO, liftIO)
39-import Control.Monad.Trans.Control
40-import Control.Monad.Trans.Resource
41-import Crypto.Types.PubKey.RSA (PrivateKey (..), PublicKey (..))
42-import Data.ByteString.Base64
43-import qualified Data.ByteString.Char8 as BS
44-import qualified Data.ByteString.Lazy.Char8 as BSL
45-import Data.Char
46-import Data.Conduit (Source, ($$), ($=))
47-import Data.Conduit.Blaze (builderToByteString)
48-import qualified Data.Conduit.List as CL
49-import Data.Default
50-import Data.Digest.Pure.SHA
51-import qualified Data.IORef as I
52-import Data.List (sortBy)
53-import Data.Maybe
54-import Data.Time
55-import Network.HTTP.Conduit
56-import Network.HTTP.Types (SimpleQuery, parseSimpleQuery)
57-import Network.HTTP.Types (Header)
58-import Network.HTTP.Types (renderSimpleQuery, status200)
59-import Numeric
60-import System.Random
61-#if MIN_VERSION_base(4,7,0)
62-import Data.Data hiding (Proxy (..))
63-#else
64+import Network.HTTP.Conduit
65 import Data.Data
66+import qualified Data.ByteString.Char8 as BS
67+import qualified Data.ByteString.Lazy.Char8 as BSL
68+import Data.Maybe
69+import Network.HTTP.Types (parseSimpleQuery, SimpleQuery)
70+import Control.Exception
71+import Control.Monad
72+import Data.List (sortBy)
73+import System.Random
74+import Data.Char
75+import Data.Digest.Pure.SHA
76+import Data.ByteString.Base64
77+import Data.Time
78+import Numeric
79+#if MIN_VERSION_RSA(2, 0, 0)
80+import Codec.Crypto.RSA (rsassa_pkcs1_v1_5_sign, hashSHA1)
81+#else
82+import Codec.Crypto.RSA (rsassa_pkcs1_v1_5_sign, ha_SHA1)
83 #endif
84+import Crypto.Types.PubKey.RSA (PrivateKey(..), PublicKey(..))
85+import Network.HTTP.Types (Header)
86+import Blaze.ByteString.Builder (toByteString)
87+import Control.Monad.IO.Class (MonadIO)
88+import Network.HTTP.Types (renderSimpleQuery, status200)
89+import Data.Conduit (($$), ($=), Source)
90+import qualified Data.Conduit.List as CL
91+import Data.Conduit.Blaze (builderToByteString)
92+import Blaze.ByteString.Builder (Builder)
93+import Control.Monad.IO.Class (liftIO)
94+import Control.Monad.Trans.Control
95+import Control.Monad.Trans.Resource
96+import Data.Default
97+import qualified Data.IORef as I
99 -- | Data type for OAuth client (consumer).
100---
101--- The constructor for this data type is not exposed.
102--- Instead, you should use the 'def' method or 'newOAuth' function to retrieve a default instance,
103+--
104+-- The constructor for this data type is not exposed.
105+-- Instead, you should use the 'def' method or 'newOAuth' function to retrieve a default instance,
106 -- and then use the records below to make modifications.
107 -- This approach allows us to add configuration options without breaking backwards compatibility.
108 data OAuth = OAuth { oauthServerName :: String -- ^ Service name (default: @\"\"@)
109@@ -71,7 +73,7 @@
110 , oauthAuthorizeUri :: String
111 -- ^ Uri to authorize (default: @\"\"@).
112 -- You MUST specify if you use 'authorizeUrl' or 'authorizeZUrl'';
113- -- otherwise you can just leave this empty.
114+ -- otherwise you can just leave this empty.
115 , oauthSignatureMethod :: SignMethod
116 -- ^ Signature Method (default: 'HMACSHA1')
117 , oauthConsumerKey :: BS.ByteString
118@@ -188,7 +190,7 @@
119 getTemporaryCredential' hook oa manager = do
120 let req = fromJust $ parseUrl $ oauthRequestUri oa
121 crd = maybe id (insert "oauth_callback") (oauthCallback oa) $ emptyCredential
122- req' <- signOAuth oa crd $ hook (req { method = "POST" })
123+ req' <- signOAuth oa crd $ hook (req { method = "POST" })
124 rsp <- httpLbs req' manager
125 if responseStatus rsp == status200
126 then do
127@@ -211,7 +213,7 @@
128 -> String -- ^ URL to authorize
129 authorizeUrl' f oa cr = oauthAuthorizeUri oa ++ BS.unpack (renderSimpleQuery True queries)
130 where fixed = ("oauth_token", token cr):f oa cr
131- queries =
132+ queries =
133 case oauthCallback oa of
134 Nothing -> fixed
135 Just callback -> ("oauth_callback", callback):fixed
136@@ -346,7 +348,11 @@
137 PLAINTEXT ->
138 return $ BS.intercalate "&" $ map paramEncode [oauthConsumerSecret oa, tokenSecret tok]
139 RSASHA1 pr ->
140+#if MIN_VERSION_RSA(2, 0, 0)
141+ liftM (encode . toStrict . rsassa_pkcs1_v1_5_sign hashSHA1 pr) (getBaseString tok req)
142+#else
143 liftM (encode . toStrict . rsassa_pkcs1_v1_5_sign ha_SHA1 pr) (getBaseString tok req)
144+#endif
146 #if MIN_VERSION_http_conduit(2, 0, 0)
147 addAuthHeader :: BS.ByteString -> Credential -> Request -> Request