From 012c75db21a5f186cbba007dea00207406a74746 Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Wed, 21 Feb 2024 02:32:15 +0100 Subject: [PATCH] chore(pwhash): reintroduce digest computation --- src/Handler/Utils/Users.hs | 14 +++++++------- src/Jobs/Handler/SendPasswordReset.hs | 4 ++-- templates/mail/userAuthModeUpdate.hamlet | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Handler/Utils/Users.hs b/src/Handler/Utils/Users.hs index 14d18c3b2..24b395ca1 100644 --- a/src/Handler/Utils/Users.hs +++ b/src/Handler/Utils/Users.hs @@ -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 diff --git a/src/Jobs/Handler/SendPasswordReset.hs b/src/Jobs/Handler/SendPasswordReset.hs index 5a93f3ba3..cf6686d46 100644 --- a/src/Jobs/Handler/SendPasswordReset.hs +++ b/src/Jobs/Handler/SendPasswordReset.hs @@ -1,4 +1,4 @@ --- SPDX-FileCopyrightText: 2022 Gregor Kleen ,Winnie Ros +-- SPDX-FileCopyrightText: 2022-2024 Sarah Vaupel , Gregor Kleen , Winnie Ros -- -- 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)]) diff --git a/templates/mail/userAuthModeUpdate.hamlet b/templates/mail/userAuthModeUpdate.hamlet index 6fb694a6f..fb45ed4db 100644 --- a/templates/mail/userAuthModeUpdate.hamlet +++ b/templates/mail/userAuthModeUpdate.hamlet @@ -41,5 +41,5 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later

_{SomeMessage MsgAuthExternalLoginTip} - $if is _Just userLastLogin + $if is _Just userLastAuthentication ^{editNotifications}