chore(pwhash): reintroduce digest computation

This commit is contained in:
Sarah Vaupel 2024-02-21 02:32:15 +01:00
parent 71e2d6827e
commit 012c75db21
3 changed files with 10 additions and 10 deletions

View File

@ -6,9 +6,9 @@
-- NOTE: Also see Handler.Utils.Profile for similar utilities
module Handler.Utils.Users
( -- computeUserAuthenticationDigest
-- , Digest, SHA3_256
constEq
( computeUserAuthenticationDigest
, Digest, SHA3_256
, constEq
, NameMatchQuality(..)
, matchesName
, GuessUserInfo(..)
@ -27,13 +27,13 @@ import Import
import Auth.LDAP (ldapUserMatr')
import Foundation.Yesod.Auth (upsertUser)
-- import Crypto.Hash (hashlazy)
import Crypto.Hash (hashlazy)
import Data.ByteArray (constEq)
import Data.Maybe (fromJust)
import qualified Data.List.NonEmpty as NonEmpty (fromList)
-- import qualified Data.Aeson as JSON
import qualified Data.Aeson as JSON
import qualified Data.Aeson.Types as JSON
import qualified Data.Set as Set
@ -130,8 +130,8 @@ getSupervisees = do
return $ Set.insert uid $ Set.fromAscList svs
-- computeUserAuthenticationDigest :: AuthenticationMode -> Digest SHA3_256
-- computeUserAuthenticationDigest = hashlazy . JSON.encode
computeUserAuthenticationDigest :: Maybe Text -> Digest SHA3_256
computeUserAuthenticationDigest = hashlazy . JSON.encode
data GuessUserInfo

View File

@ -1,4 +1,4 @@
-- SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Winnie Ros <winnie.ros@campus.lmu.de>
-- SPDX-FileCopyrightText: 2022-2024 Sarah Vaupel <sarah.vaupel@uniworx.de>, Gregor Kleen <gregor.kleen@ifi.lmu.de>, Winnie Ros <winnie.ros@campus.lmu.de>
--
-- SPDX-License-Identifier: AGPL-3.0-or-later
@ -36,7 +36,7 @@ dispatchJobSendPasswordReset jRecipient = JobHandlerException . userMailT jRecip
resetBearer' <- bearerToken (HashSet.singleton $ Right jRecipient) Nothing (HashMap.singleton BearerTokenRouteEval . HashSet.singleton $ UserPasswordR cID) Nothing (Just $ Just tomorrowEndOfDay) Nothing
let resetBearer = resetBearer'
& bearerRestrict (UserPasswordR cID) (decodeUtf8 . Base64.encode . BA.convert $ computeUserAuthenticationDigest userAuthentication)
& bearerRestrict (UserPasswordR cID) (decodeUtf8 . Base64.encode . BA.convert $ computeUserAuthenticationDigest userPasswordHash)
encodedBearer <- encodeBearer resetBearer
resetUrl <- toTextUrl (UserPasswordR cID, [(toPathPiece GetBearer, toPathPiece encodedBearer)])

View File

@ -41,5 +41,5 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later
<p>
_{SomeMessage MsgAuthExternalLoginTip}
$if is _Just userLastLogin
$if is _Just userLastAuthentication
^{editNotifications}