X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FAuthorization.hs;h=04beabae3cb676cd138d1a0b447c818ba1ee5d0c;hb=23977989ef4be7316b1c2c3f709ca1e8e6bb7f84;hp=8f32ddfc613420e005e898e24ac08be920cbee0e;hpb=4e428cf86da68b72ef8fdff87990e7c953c8f12e;p=Rakka.git diff --git a/Rakka/Authorization.hs b/Rakka/Authorization.hs index 8f32ddf..04beaba 100644 --- a/Rakka/Authorization.hs +++ b/Rakka/Authorization.hs @@ -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