packages feed

servant-auth-client 0.4.0.0 → 0.4.1.0

raw patch · 4 files changed

+42/−20 lines, 4 filesdep ~QuickCheckdep ~aesondep ~basePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: QuickCheck, aeson, base, bytestring, hspec, http-client, jose, servant, servant-auth, servant-client-core, servant-server, time, transformers, warp

API changes (from Hackage documentation)

- Servant.Auth.Client.Internal: class JWTAuthNotEnabled
- Servant.Auth.Client.Internal: instance (Servant.Auth.Client.Internal.HasJWT auths, Servant.Client.Core.HasClient.HasClient m api) => Servant.Client.Core.HasClient.HasClient m (Servant.Auth.Auth auths a Servant.API.Sub.:> api)
+ Servant.Auth.Client: data Bearer
+ Servant.Auth.Client.Internal: class BearerAuthNotEnabled
+ Servant.Auth.Client.Internal: data Bearer
+ Servant.Auth.Client.Internal: instance (Servant.Auth.Client.Internal.HasBearer auths, Servant.Client.Core.HasClient.HasClient m api) => Servant.Client.Core.HasClient.HasClient m (Servant.Auth.Auth auths a Servant.API.Sub.:> api)
- Servant.Auth.Client.Internal: type family HasJWT xs :: Constraint
+ Servant.Auth.Client.Internal: type family HasBearer xs :: Constraint

Files

CHANGELOG.md view
@@ -7,6 +7,10 @@  ## [Unreleased] +## [0.4.1.0] - 2020-10-06++- Support generic Bearer token auth + ## [0.4.0.0] - 2019-03-08  ## Changed
servant-auth-client.cabal view
@@ -1,5 +1,5 @@ name:           servant-auth-client-version:        0.4.0.0+version:        0.4.1.0 synopsis:       servant-client/servant-auth compatibility description:    This package provides instances that allow generating clients from                 <https://hackage.haskell.org/package/servant servant>@@ -15,7 +15,7 @@ copyright:      (c) Julian K. Arni license:        BSD3 license-file:   LICENSE-tested-with:    GHC == 8.0.2, GHC == 8.2.2, GHC==8.4.4, GHC==8.6.2+tested-with:    GHC == 8.2.2, GHC==8.4.4, GHC==8.6.5, GHC==8.8.1, GHC==8.10.2 build-type:     Simple cabal-version:  >= 1.10 extra-source-files:@@ -31,12 +31,12 @@   default-extensions: AutoDeriveTypeable ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes ScopedTypeVariables TypeFamilies TypeOperators   ghc-options: -Wall   build-depends:-      base                >= 4.9      && < 4.13+      base                >= 4.10     && < 4.15     , bytestring          >= 0.10.6.0 && < 0.11     , containers          >= 0.5.6.2  && < 0.7     , servant-auth        == 0.3.*-    , servant             >= 0.13     && < 0.17-    , servant-client-core >= 0.13     && < 0.17+    , servant             >= 0.13     && < 0.19+    , servant-client-core >= 0.13     && < 0.19    exposed-modules:       Servant.Auth.Client@@ -63,17 +63,17 @@   -- test dependencies   build-depends:       hspec                >= 2.5.5    && < 2.8-    , QuickCheck           >= 2.11.3   && < 2.13-    , aeson                >= 1.3.1.1  && < 1.5+    , QuickCheck           >= 2.11.3   && < 2.15+    , aeson                >= 1.3.1.1  && < 1.6     , bytestring           >= 0.10.6.0 && < 0.11     , http-client          >= 0.5.13.1 && < 0.7     , http-types           >= 0.12.2   && < 0.13     , servant-auth-server  >= 0.4.2.0  && < 0.5-    , servant-server       >= 0.13     && < 0.17-    , time                 >= 1.5.0.1  && < 1.9+    , servant-server       >= 0.13     && < 0.19+    , time                 >= 1.5.0.1  && < 1.10     , transformers         >= 0.4.2.0  && < 0.6     , wai                  >= 3.2.1.2  && < 3.3-    , warp                 >= 3.2.25   && < 3.3+    , warp                 >= 3.2.25   && < 3.4     , jose                 >= 0.7.0.0  && < 0.9   other-modules:       Servant.Auth.ClientSpec
src/Servant/Auth/Client.hs view
@@ -1,3 +1,3 @@-module Servant.Auth.Client (Token(..)) where+module Servant.Auth.Client (Token(..), Bearer) where -import Servant.Auth.Client.Internal (Token(..))+import Servant.Auth.Client.Internal (Bearer, Token(..))
src/Servant/Auth/Client/Internal.hs view
@@ -19,20 +19,21 @@ import           Servant.Client.Core import           Data.Sequence ((<|)) --- | A compact JWT Token.+-- | A simple bearer token. newtype Token = Token { getToken :: BS.ByteString }   deriving (Eq, Show, Read, Generic, IsString) -type family HasJWT xs :: Constraint where-  HasJWT (JWT ': xs) = ()-  HasJWT (x ': xs)   = HasJWT xs-  HasJWT '[]         = JWTAuthNotEnabled+type family HasBearer xs :: Constraint where+  HasBearer (Bearer ': xs) = ()+  HasBearer (JWT ': xs) = ()+  HasBearer (x ': xs)   = HasBearer xs+  HasBearer '[]         = BearerAuthNotEnabled -class JWTAuthNotEnabled+class BearerAuthNotEnabled --- | @'HasJWT' auths@ is nominally a redundant constraint, but ensures we're not+-- | @'HasBearer' auths@ is nominally a redundant constraint, but ensures we're not -- trying to send a token to an API that doesn't accept them.-instance (HasJWT auths, HasClient m api) => HasClient m (Auth auths a :> api) where+instance (HasBearer auths, HasClient m api) => HasClient m (Auth auths a :> api) where   type Client m (Auth auths a :> api) = Token -> Client m api    clientWithRoute m _ req (Token token)@@ -44,3 +45,20 @@ #if MIN_VERSION_servant_client_core(0,14,0)   hoistClientMonad pm _ nt cl = hoistClientMonad pm (Proxy :: Proxy api) nt . cl #endif+++-- * Authentication combinators++-- | A Bearer token in the Authorization header:+--+--    @Authorization: Bearer <token>@+--+-- This can be any token recognized by the server, for example,+-- a JSON Web Token (JWT).+--+-- Note that, since the exact way the token is validated is not specified,+-- this combinator can only be used in the client. The server would not know+-- how to validate it, while the client does not care.+-- If you want to implement Bearer authentication in your server, you have to+-- choose a specific combinator, such as 'JWT'.+data Bearer