aws-general 0.1.1 → 0.2.0
raw patch · 7 files changed
+61/−37 lines, 7 filesdep ~timePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: time
API changes (from Hackage documentation)
+ Aws.SignatureV4: sigV4SecurityToken :: SignatureV4Credentials -> Maybe ByteString
- Aws.SignatureV4: SignatureV4Credentials :: ByteString -> ByteString -> IORef [SigV4Key] -> SignatureV4Credentials
+ Aws.SignatureV4: SignatureV4Credentials :: ByteString -> ByteString -> IORef [SigV4Key] -> Maybe ByteString -> SignatureV4Credentials
- Aws.SignatureV4: newCredentials :: (Functor m, MonadIO m) => ByteString -> ByteString -> m SignatureV4Credentials
+ Aws.SignatureV4: newCredentials :: (Functor m, MonadIO m) => ByteString -> ByteString -> Maybe ByteString -> m SignatureV4Credentials
Files
- CHANGELOG.md +6/−0
- README.md +1/−5
- aws-general.cabal +17/−6
- constraints +20/−21
- src/Aws/General.hs +2/−0
- src/Aws/SignatureV4.hs +14/−4
- tests/SignatureV4.hs +1/−1
CHANGELOG.md view
@@ -1,3 +1,9 @@+0.2.0+=====++* Support X-Amz-Security-Token header for signing with credentials derived+ from IAM role.+ 0.1.1 =====
README.md view
@@ -1,12 +1,8 @@ [](https://travis-ci.org/alephcloud/hs-aws-general) --Haskell Bindings for Amazon AWS General API-===========================================+Haskell Bindings for [Amazon Web Services (AWS) General Reference](http://docs.aws.amazon.com/general/latest/gr/) *API Version 0.1*--[Amazon AWS General API Reference](http://docs.aws.amazon.com/general/latest/gr/) Installation ============
aws-general.cabal view
@@ -3,10 +3,10 @@ -- ------------------------------------------------------ -- Name: aws-general-Version: 0.1.1-Synopsis: Bindings for AWS General API Version 0.1+Version: 0.2.0+Synopsis: Bindings for Amazon Web Services (AWS) General Reference description:- Bindings for AWS General API including AWS Signature V4.+ Bindings for Amazon Web Services (AWS) General Reference including AWS Signature V4. . /API Version: 1.0/ .@@ -38,7 +38,7 @@ source-repository this type: git location: https://github.com/alephcloud/hs-aws-general.git- tag: 0.1.1+ tag: 0.2.0 flag normalize-signature-v4-date Description:@@ -48,6 +48,11 @@ since the tests in that test suite use an invalid date. default: True +flag old-locale+ Description: use time < 1.4 with old-local package+ default: False+ manual: False+ Library default-language: Haskell2010 hs-source-dirs: src@@ -69,12 +74,18 @@ cryptohash >= 0.11, hashable >= 1.2, http-types >= 0.8,- old-locale >= 1.0, parsers >= 0.11, quickcheck-instances >= 0.3, text >= 1.1,- time >= 1.4, transformers >= 0.3++ if flag(old-locale)+ build-depends:+ old-locale >= 1.0,+ time < 1.5+ else+ build-depends:+ time >= 1.5 ghc-options: -Wall
constraints view
@@ -1,41 +1,40 @@-constraints: QuickCheck ==2.7.5,- aeson ==0.7.0.6,+constraints: QuickCheck ==2.7.6,+ aeson ==0.8.0.2, array ==0.5.0.0,- attoparsec ==0.12.1.0,- aws-general ==0.1,+ attoparsec ==0.12.1.2, base ==4.7.0.1, base16-bytestring ==0.1.1.6,- blaze-builder ==0.3.3.2,+ blaze-builder ==0.3.3.4, byteable ==0.1.1, bytestring ==0.10.4.0,- case-insensitive ==1.2.0.0,+ case-insensitive ==1.2.0.3, charset ==0.3.7, containers ==0.5.5.1, cryptohash ==0.11.6, deepseq ==1.3.0.2, dlist ==0.7.1, ghc-prim ==0.3.1.0,- hashable ==1.2.2.0,+ hashable ==1.2.3.1, http-types ==0.8.5, integer-gmp ==0.5.1.0,- mtl ==2.1.3.1,- nats ==0.2,+ mtl ==2.2.1,+ nats ==1, old-locale ==1.0.0.6, old-time ==1.1.0.2,- parsec ==3.1.5,- parsers ==0.12,+ parsec ==3.1.7,+ parsers ==0.12.1.1, pretty ==1.1.1.1,- primitive ==0.5.3.0,- quickcheck-instances ==0.3.8,- random ==1.0.1.1,+ primitive ==0.5.4.0,+ quickcheck-instances ==0.3.10,+ random ==1.1, rts ==1.0,- scientific ==0.3.3.0,- semigroups ==0.15.1,- syb ==0.4.2,+ scientific ==0.3.3.7,+ semigroups ==0.16.0.1,+ syb ==0.4.4, template-haskell ==2.9.0.0,- text ==1.1.1.3,+ text ==1.2.0.3, tf-random ==0.5, time ==1.4.2,- transformers ==0.3.0.0,- unordered-containers ==0.2.5.0,- vector ==0.10.11.0+ transformers ==0.4.2.0,+ unordered-containers ==0.2.5.1,+ vector ==0.10.12.2
src/Aws/General.hs view
@@ -89,6 +89,8 @@ fromText :: T.Text -> Either String a fromText = AP.parseOnly $ parse <* P.eof + {-# MINIMAL toText, parse #-}+ -- -------------------------------------------------------------------------- -- -- General API Version
src/Aws/SignatureV4.hs view
@@ -1,6 +1,7 @@-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE CPP #-}+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TupleSections #-} -- | -- Module: Aws.SignatureV4@@ -127,7 +128,11 @@ import qualified Text.Parser.Char as P import qualified Text.Parser.Combinators as P +#if MIN_VERSION_time(1,5,0)+import Data.Time.Format+#else import System.Locale+#endif import qualified Network.HTTP.Types as HTTP @@ -178,6 +183,7 @@ , sigV4SecretAccessKey :: B.ByteString , sigV4SigningKeys :: IORef [SigV4Key] -- ^ used internally for caching the singing key+ , sigV4SecurityToken :: Maybe B.ByteString } deriving (Typeable) @@ -185,9 +191,11 @@ :: (Functor m, MonadIO m) => B.ByteString -- ^ Access Key ID -> B.ByteString -- ^ Secret Access Key+ -> Maybe B.ByteString -- ^ Security Token -> m SignatureV4Credentials-newCredentials accessKeyId secretAccessKey =- SignatureV4Credentials accessKeyId secretAccessKey <$> liftIO (newIORef [])+newCredentials accessKeyId secretAccessKey securityToken = do+ signingKeysRef <- liftIO $ newIORef []+ return $ SignatureV4Credentials accessKeyId secretAccessKey signingKeysRef securityToken -- -------------------------------------------------------------------------- -- -- Canonical URI@@ -715,6 +723,7 @@ , ("X-Amz-Credential", Just $ authorizationCredential credentials credentialScope) , ("X-Amz-Date", Just $ fTime signingStringDateFormat date) , ("X-Amz-SignedHeaders", let SignedHeaders h = shdrs in Just (T.decodeUtf8 h))+ , ("X-Amz-Security-Token", T.decodeUtf8 <$> sigV4SecurityToken credentials) ] authz = authorizationInfo credentials credentialScope shdrs date sig sig = requestSignature key str@@ -792,6 +801,7 @@ } headersWithDate = ("x-amz-date", fTime signingStringDateFormat date) : filter (\x -> fst x /= "date" && fst x /= "x-amz-date") headers+ ++ maybe [] ((:[]) . ("X-Amz-Security-Token",)) (sigV4SecurityToken credentials) -- -------------------------------------------------------------------------- -- -- Sign Request in IO
tests/SignatureV4.hs view
@@ -119,7 +119,7 @@ $ fromText "20110909/us-east-1/host/aws4_request" amz_credentialsIO :: IO SignatureV4Credentials-amz_credentialsIO = newCredentials "AKIDEXAMPLE" "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY"+amz_credentialsIO = newCredentials "AKIDEXAMPLE" "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY" Nothing amz_credentials :: SignatureV4Credentials amz_credentials = unsafePerformIO $ amz_credentialsIO