Skip to content

Commit e8dda55

Browse files
authored
Merge pull request #344 from phadej/http-client-0.6
Http client 0.6
2 parents 66eb08c + 738e08a commit e8dda55

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Changes for next
2+
3+
- Allow http-client-0.6
4+
5+
- Change to use `cryptohash-sha1` (before `cryptohash`)
6+
17
## Changes for 0.20
28

39
- Add ratelimit endpoint

github.cabal

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,11 @@ Library
149149
base-compat >=0.10.4 && <0.11,
150150
base16-bytestring >=0.1.1.6 && <0.2,
151151
binary-orphans >=0.1.8.0 && <0.2,
152-
byteable >=0.1.1 && <0.2,
153-
cryptohash >=0.11.9 && <0.12,
152+
cryptohash-sha1 >=0.11.100.1 && <0.12,
154153
deepseq-generics >=0.2.0.0 && <0.3,
155154
exceptions >=0.10.0 && <0.11,
156155
hashable >=1.2.7.0 && <1.3,
157-
http-client >=0.5.12 && <0.6,
156+
http-client >=0.5.12 && <0.7,
158157
http-client-tls >=0.3.5.3 && <0.4,
159158
http-link-header >=1.0.3.1 && <1.1,
160159
http-types >=0.12.1 && <0.13,
@@ -189,7 +188,7 @@ test-suite github-test
189188
GitHub.UsersSpec
190189
main-is: Spec.hs
191190
ghc-options: -Wall
192-
build-tool-depends: hspec-discover:hspec-discover >=2.5.6 && <2.6
191+
build-tool-depends: hspec-discover:hspec-discover >=2.6.1 && <2.7
193192
build-depends: base,
194193
base-compat,
195194
aeson,
@@ -198,4 +197,4 @@ test-suite github-test
198197
vector,
199198
unordered-containers,
200199
file-embed,
201-
hspec >= 2.5.6 && <2.6
200+
hspec >= 2.6.1 && <2.7

src/GitHub/Data/Webhooks/Validate.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ module GitHub.Data.Webhooks.Validate (
1212
import GitHub.Internal.Prelude
1313
import Prelude ()
1414

15-
import Crypto.Hash (HMAC, SHA1, hmac, hmacGetDigest)
16-
import Data.Byteable (constEqBytes, toBytes)
17-
import Data.ByteString (ByteString)
15+
import Crypto.Hash.SHA1 (hmac)
16+
import Data.ByteString (ByteString)
1817

1918
import qualified Data.ByteString.Base16 as Hex
2019
import qualified Data.Text.Encoding as TE
@@ -30,10 +29,9 @@ isValidPayload
3029
-- including the 'sha1=...' prefix
3130
-> ByteString -- ^ the body
3231
-> Bool
33-
isValidPayload secret shaOpt payload = maybe False (constEqBytes sign) shaOptBS
32+
isValidPayload secret shaOpt payload = maybe False (sign ==) shaOptBS
3433
where
3534
shaOptBS = TE.encodeUtf8 <$> shaOpt
36-
hexDigest = Hex.encode . toBytes . hmacGetDigest
37-
38-
hm = hmac (TE.encodeUtf8 secret) payload :: HMAC SHA1
35+
hexDigest = Hex.encode
36+
hm = hmac (TE.encodeUtf8 secret) payload
3937
sign = "sha1=" <> hexDigest hm

0 commit comments

Comments
 (0)