bloodhound-amazonka-auth 0.1.1.0 → 0.1.2.0
raw patch · 4 files changed
+20/−11 lines, 4 filesdep ~amazonkaPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: amazonka
API changes (from Hackage documentation)
- Database.Bloodhound.Auth.Amazonka.Internal: instance Eq EsAmazonkaAuthError
- Database.Bloodhound.Auth.Amazonka.Internal: instance Exception EsAmazonkaAuthError
- Database.Bloodhound.Auth.Amazonka.Internal: instance Show EsAmazonkaAuthError
- Database.Bloodhound.Auth.Amazonka.Internal: instance Typeable EsAmazonkaAuthError
+ Database.Bloodhound.Auth.Amazonka.Internal: instance GHC.Classes.Eq Database.Bloodhound.Auth.Amazonka.Internal.EsAmazonkaAuthError
+ Database.Bloodhound.Auth.Amazonka.Internal: instance GHC.Exception.Exception Database.Bloodhound.Auth.Amazonka.Internal.EsAmazonkaAuthError
+ Database.Bloodhound.Auth.Amazonka.Internal: instance GHC.Show.Show Database.Bloodhound.Auth.Amazonka.Internal.EsAmazonkaAuthError
Files
- bloodhound-amazonka-auth.cabal +2/−2
- changelog.md +4/−0
- src/Database/Bloodhound/Auth/Amazonka/Internal.hs +6/−6
- test/Main.hs +8/−3
bloodhound-amazonka-auth.cabal view
@@ -1,5 +1,5 @@ name: bloodhound-amazonka-auth-version: 0.1.1.0+version: 0.1.2.0 synopsis: Adds convenient Amazon ElasticSearch Service authentication to Bloodhound. description: Please see README.md homepage: http://github.com/MichaelXavier/bloodhound-amazonka-auth#readme@@ -54,7 +54,7 @@ , time , bloodhound , text- , amazonka+ , amazonka >= 1.4.0 , amazonka-core , http-client-tls , lens
changelog.md view
@@ -1,3 +1,7 @@+0.1.2.0+* Fix bug where amazonka would override user-specified timeouts.+* Support newer versions of bloodhound.+ 0.1.1.0 * Worked around seemingly a bug in V4 signatures with AWS ES service with paths that needed encoding. This comes up if you make authenticated requests with index patterns, e.g. /foo*/. They would previously fail to authenticate.
src/Database/Bloodhound/Auth/Amazonka/Internal.hs view
@@ -7,7 +7,6 @@ import Control.Exception import Data.Time.Clock import Data.Typeable-import Database.Bloodhound.Types import Network.AWS.Data.Body import Network.AWS.Data.ByteString import Network.AWS.Data.Path@@ -18,7 +17,7 @@ sgSign) import qualified Network.AWS.Types as A import Network.HTTP.Client-import Network.HTTP.Types.Method (parseMethod)+import Network.HTTP.Types.Method (Method, parseMethod) import URI.ByteString ------------------------------------------------------------------------------- @@ -44,12 +43,13 @@ amazonkaAuthHook' :: AuthEnv -> Region -> Request -> UTCTime -> Either EsAmazonkaAuthError Request amazonkaAuthHook' ae reg req now = toReq <$> toAwsRequest req reg where algo = sgSign (A._svcSigner elasticSearch)- toReq req' = decodePath (sgRequest (algo req' ae reg now))+ toReq req' = restoreTimeout (decodePath (sgRequest (algo req' ae reg now))) -- We decode the path because for some reason AWS ES actually -- doesn't want the path url encoded. If you do, it will -- expect double-encoding for the canonical uri. If you -- double, it will expect triple and so-on. decodePath x = x { path = urlDecode True (path x)}+ restoreTimeout x = x { responseTimeout = responseTimeout req } -------------------------------------------------------------------------------@@ -74,7 +74,7 @@ toQS :: ByteString -> Either EsAmazonkaAuthError A.QueryString toQS bs = case parseRelativeRef laxURIParserOptions bs of Right rr -> Right (go (rrQuery rr))- Left _ -> Left MalformedQueryString+ Left _ -> Left MalformedQueryString where go q = QList [ QPair k (QValue (Just v)) | (k, v) <- queryPairs q] -------------------------------------------------------------------------------@@ -97,5 +97,5 @@ ------------------------------------------------------------------------------- toRQBody :: RequestBody -> Either EsAmazonkaAuthError RqBody toRQBody (RequestBodyLBS b) = Right (toBody b)-toRQBody (RequestBodyBS b) = Right (toBody b)-toRQBody _ = Left StreamingBodyNotSupported+toRQBody (RequestBodyBS b) = Right (toBody b)+toRQBody _ = Left StreamingBodyNotSupported
test/Main.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} module Main@@ -14,7 +15,11 @@ import qualified Data.Proxy as P import qualified Data.Text as T import Data.Time.Clock.POSIX+#if MIN_VERSION_bloodhound(0, 13, 0)+import Database.V1.Bloodhound+#else import Database.Bloodhound+#endif import Network.AWS import Network.AWS.Env import Network.HTTP.Client@@ -72,7 +77,7 @@ res <- parseEsResponse =<< runBH env (searchByIndex testIndexSplat search) case (res :: Either EsError (SearchResult Value)) of Right _ -> return ()- Left e -> assertFailure (show e)+ Left e -> assertFailure (show e) ] where testIndex = IndexName "bloodhound-amazonka-auth-test"@@ -81,7 +86,7 @@ setup = do mgr <- newManager tlsManagerSettings lgr <- newLogger Debug stdout- env <- set envLogger lgr<$> newEnvWith region Discover Nothing mgr+ env <- set envRegion region . set envLogger lgr<$> newEnvWith Discover Nothing mgr let auth = view envAuth env let hook req = withAuth auth $ \authEnv -> either throwIO return =<< amazonkaAuthHook authEnv region req let bhe = (mkBHEnv server mgr) { bhRequestHook = hook }@@ -118,6 +123,6 @@ instance IsOption IntegrationServer where defaultValue = IntegrationServer Nothing parseValue "" = return (IntegrationServer Nothing)- parseValue s = return (IntegrationServer (Just (Server (T.pack s))))+ parseValue s = return (IntegrationServer (Just (Server (T.pack s)))) optionName = return "integration-server" optionHelp = return "If supplied, tests against a real AWS ES cluster (fees may apply). Uses the standard amazonka methods for discovering credentials."