]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Authorization.hs
fix for interface change of Crypto
[Rakka.git] / Rakka / Authorization.hs
index 8f32ddfc613420e005e898e24ac08be920cbee0e..04beabae3cb676cd138d1a0b447c818ba1ee5d0c 100644 (file)
@@ -9,7 +9,7 @@ import qualified Codec.Binary.Base64 as B64
 import qualified Codec.Binary.UTF8.String as UTF8
 import           Control.Concurrent.STM
 import           Control.Monad.Trans
-import qualified Data.Digest.SHA1 as SHA1
+import           Data.Digest.SHA2
 import           Data.Map (Map)
 import qualified Data.Map as M hiding (Map)
 import           Data.Maybe
@@ -45,7 +45,7 @@ mkAuthDB lsdir
 
 isValidPair :: MonadIO m => AuthDB -> String -> String -> m Bool
 isValidPair adb name pass
-    = let hash = SHA1.hash (UTF8.encode pass)
+    = let hash = toOctets $ sha256 $ UTF8.encode pass
       in
         liftIO $ atomically $ do m <- readTVar (adbUserMap adb)
                                  return (M.lookup name m == Just hash)
@@ -64,12 +64,12 @@ loadUserMap path
     where
       decodePair :: (String, String) -> (String, [Word8])
       decodePair (name, b64Hash)
-          = (UTF8.decodeString name, B64.decode b64Hash)
+          = (UTF8.decodeString name, fromJust $ B64.decode b64Hash)
 
       initMap :: UserMap -> UserMap
       initMap m
           | M.null m  = let name = "root"
-                            hash = SHA1.hash []
+                            hash = toOctets $ sha256 ([] :: [Word8])
                         in
                           M.singleton name hash
           | otherwise = m