This commit is contained in:
Mats Rauhala 2018-08-29 23:34:19 +03:00
parent 786927ccbd
commit a580138e0d
3 changed files with 16 additions and 17 deletions

View File

@ -18,9 +18,6 @@ newtype PlainPassword = PlainPassword Text deriving (Show, ToJSON, FromJSON, ToH
newtype HashedPassword = HashedPassword {unHashed :: ByteString}
data NoPassword = NoPassword
newtype Email = Email { unEmail :: Text } deriving (Show, ToJSON, FromJSON, ToHttpApiData, FromHttpApiData)
newtype Username = Username { unUsername :: Text } deriving (Show, ToJSON, FromJSON, ToHttpApiData, FromHttpApiData)
instance SqlType HashedPassword where
mkLit = LCustom . LBlob . unHashed

View File

@ -24,21 +24,8 @@ import Control.Lens (view)
import Data.Generics.Product
import Servant (err401)
import Control.Monad.Logger
import Auth (SafeUser(..))
-- generic-lens can convert similar types to this
-- I'm trying out servant-auth-server which uses a jwt style login. IIRC anyone
-- can open the jwt token and view what's inside, you just can't modify it.
--
-- Is it a problem that a human readable username and email are visible?
data SafeUser = SafeUser { email :: Email
, username :: Username
, role :: Role }
deriving (Show, Generic)
instance ToJSON SafeUser where
instance FromJSON SafeUser where
instance ToJWT SafeUser where
instance FromJWT SafeUser where
type instance BasicAuthCfg = BasicAuthData -> IO (AuthResult SafeUser)

View File

@ -15,14 +15,27 @@ cabal-version: >=1.10
library
exposed-modules: Configuration
, Data.Versioned
, API
, API.Books
, API.Catalogue
, API.Channels
, API.Users
, Auth
-- other-extensions:
build-depends: base >=4.10 && <4.11
, aeson
, classy-prelude
, dhall
, foreign-store
, generic-lens
, lens
, mtl
, servant
, servant-auth
, servant-auth-server
, servant-docs
, servant-lucid
, servant-multipart
, text
, transformers
hs-source-dirs: src
@ -30,4 +43,6 @@ library
, NoImplicitPrelude
, OverloadedStrings
, RecordWildCards
, TypeOperators
, DataKinds
default-language: Haskell2010