Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9bb0151
range
battermann Mar 8, 2023
a0aff3f
using pw with range everywhere
battermann Mar 8, 2023
c31a899
using min length password in relevant places
battermann Mar 9, 2023
7d5468e
changelog
battermann Mar 9, 2023
51c4fa7
Generalize password type instances.
fisx Mar 10, 2023
29f4602
Merge branch 'develop' into SQSERVICES-1931-wire-server-allow-backend…
fisx Mar 10, 2023
1731b48
hi ci
fisx Mar 13, 2023
b2adfe0
fix integration test.
fisx Mar 13, 2023
fca8388
automatic renames (1)
fisx Mar 13, 2023
fe632a7
automatic renames (2)
fisx Mar 13, 2023
369e1ec
automatic renames (3)
fisx Mar 13, 2023
becc36e
test login with 6 char password still works
battermann Mar 13, 2023
8abfe18
hi ci
fisx Mar 15, 2023
3766cbd
Downgrade to our fork of http2 (#3141)
pcapriotti Mar 13, 2023
952b67f
Add release note (#3146)
smatting Mar 13, 2023
25400f5
Add changelog for Release 2023-03-06
zebot Mar 6, 2023
55ccf1c
Fix gundeck leak (#3136)
isovector Mar 13, 2023
c21f8e3
Fix ES reset command in Makefile (#3114)
pcapriotti Mar 13, 2023
82f4d8f
Upgrade cachix to 1.3.1 (#3144)
smatting Mar 13, 2023
5ba26cc
Revert "Use openssl instead of tls in federator http2 client (#3051)"…
smatting Mar 13, 2023
1f3da62
Add `flakyTestCase` command and use it. (#3143)
fisx Mar 13, 2023
91b315e
Add docs for creating diagrams in markdown files
battermann Feb 22, 2023
7231764
FS-1530 Suppress federated errors when removing users from conversati…
lepsa Mar 14, 2023
2127ded
[SQSERVICES-1942] Fix DPoP access token error propagation (2/2) (#3142)
battermann Mar 14, 2023
01838ca
OAuth (#2989)
fisx Mar 14, 2023
974cd63
Set versions in Helm charts for Frida (BUND release)
supersven Mar 15, 2023
4d69dc0
Revert "Set versions in Helm charts for Frida (BUND release)"
supersven Mar 15, 2023
c2c94c5
resolved merge issue
battermann Mar 15, 2023
613919b
Merge branch 'develop' into SQSERVICES-1931-wire-server-allow-backend…
battermann Mar 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2-features/pr-3137
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enforce a minimum length of 8 characters when setting a new password
4 changes: 2 additions & 2 deletions libs/api-bot/src/Network/Wire/Bot/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import System.Random.MWC.Distributions (uniformShuffle)

newtype Cache = Cache {cache :: IORef [CachedUser]}

data CachedUser = CachedUser !PlainTextPassword !User
data CachedUser = CachedUser !PlainTextPassword6 !User

-- | Load users out of a file in the following format:
--
Expand Down Expand Up @@ -77,7 +77,7 @@ put c a = liftIO . atomicModifyIORef (cache c) $ \u -> (a : u, ())

toUser :: HasCallStack => Logger -> Domain -> [CachedUser] -> [LText] -> IO [CachedUser]
toUser _ domain acc [i, e, p] = do
let pw = PlainTextPassword . Text.toStrict $ Text.strip p
let pw = plainTextPassword6Unsafe . Text.toStrict $ Text.strip p
let iu = error "Cache.toUser: invalid user"
let ie = error "Cache.toUser: invalid email"
let ui = fromMaybe iu . fromByteString . encodeUtf8 . Text.toStrict . Text.strip $ i
Expand Down
12 changes: 6 additions & 6 deletions libs/api-bot/src/Network/Wire/Bot/Monad.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ import qualified Data.HashMap.Strict as HashMap
import Data.Id
import Data.Metrics (Metrics)
import qualified Data.Metrics as Metrics
import Data.Misc (PlainTextPassword (..))
import Data.Misc
import Data.Qualified (Local, toLocalUnsafe)
import Data.Text (pack, unpack)
import Data.Time.Clock
Expand Down Expand Up @@ -345,7 +345,7 @@ data Bot = Bot
botMetrics :: BotMetrics,
-- END TODO
botClients :: TVar [BotClient], -- TODO: IORef?
botPassphrase :: PlainTextPassword
botPassphrase :: PlainTextPassword6
}

instance Show Bot where
Expand Down Expand Up @@ -452,7 +452,7 @@ newBot tag = liftBotNet $ do
keys <- liftIO $ awaitActivationMail mbox folders sndr email
log Info $ botLogFields (userId user) tag . msg (val "Activate user")
forM_ keys (uncurry activateKey >=> flip assertTrue "Activation failed.")
bot <- mkBot tag user pw
bot <- mkBot tag user (plainTextPassword8To6 pw)
-- TODO: addBotClient?
incrBotsCreatedNew
pure bot
Expand Down Expand Up @@ -689,7 +689,7 @@ try ma = do
-------------------------------------------------------------------------------
-- Internal Bot Lifecycle

mkBot :: BotTag -> User -> PlainTextPassword -> BotNet Bot
mkBot :: BotTag -> User -> PlainTextPassword6 -> BotNet Bot
mkBot tag user pw = do
log Info $ botLogFields (userId user) tag . msg (val "Login")
let ident = fromMaybe (error "No email") (userEmail user)
Expand Down Expand Up @@ -978,12 +978,12 @@ botLogFields u t = field "Bot" (show u) . field "Tag" (unTag t)
-------------------------------------------------------------------------------
-- Randomness

randUser :: Email -> BotTag -> IO (NewUser, PlainTextPassword)
randUser :: Email -> BotTag -> IO (NewUser, PlainTextPassword8)
randUser (Email loc dom) (BotTag tag) = do
uuid <- nextRandom
pwdUuid <- nextRandom
let email = Email (loc <> "+" <> tag <> "-" <> pack (toString uuid)) dom
let passw = PlainTextPassword (pack (toString pwdUuid))
let passw = plainTextPassword8Unsafe (pack (toString pwdUuid))
pure
( NewUser
{ newUserDisplayName = Name (tag <> "-Wirebot-" <> pack (toString uuid)),
Expand Down
4 changes: 2 additions & 2 deletions libs/brig-types/src/Brig/Types/User/Auth.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ where

import Data.Aeson
import Data.Id (UserId)
import Data.Misc (PlainTextPassword (..))
import Data.Misc (PlainTextPassword6)
import Imports
import Wire.API.User.Auth

Expand All @@ -37,7 +37,7 @@ data SsoLogin
-- This kind of login returns restricted 'LegalHoldUserToken's instead of regular
-- tokens.
data LegalHoldLogin
= LegalHoldLogin !UserId !(Maybe PlainTextPassword) !(Maybe CookieLabel)
= LegalHoldLogin !UserId !(Maybe PlainTextPassword6) !(Maybe CookieLabel)

instance FromJSON SsoLogin where
parseJSON = withObject "SsoLogin" $ \o ->
Expand Down
64 changes: 49 additions & 15 deletions libs/types-common/src/Data/Misc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,16 @@ module Data.Misc
Fingerprint (..),
Rsa,

-- * PlainTextPassword
PlainTextPassword (..),
-- * PlainTextPassword6
PlainTextPassword' (..),
PlainTextPassword6,
PlainTextPassword8,
plainTextPassword6,
plainTextPassword8,
fromPlainTextPassword,
plainTextPassword8Unsafe,
plainTextPassword6Unsafe,
plainTextPassword8To6,

-- * Typesafe FUTUREWORKS
FutureWork (..),
Expand All @@ -75,6 +83,8 @@ import Data.String.Conversions (cs)
import qualified Data.Swagger as S
import qualified Data.Text as Text
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import GHC.TypeLits (Nat)
import GHC.TypeNats (KnownNat)
import Imports
import Servant (FromHttpApiData (..))
import Test.QuickCheck (Arbitrary (arbitrary), chooseInteger)
Expand Down Expand Up @@ -338,23 +348,47 @@ instance Arbitrary (Fingerprint Rsa) where
--------------------------------------------------------------------------------
-- Password

newtype PlainTextPassword = PlainTextPassword
{fromPlainTextPassword :: Text}
type PlainTextPassword6 = PlainTextPassword' (6 :: Nat)

type PlainTextPassword8 = PlainTextPassword' (8 :: Nat)

plainTextPassword6 :: Text -> Maybe PlainTextPassword6
plainTextPassword6 = fmap PlainTextPassword' . checked

plainTextPassword6Unsafe :: Text -> PlainTextPassword6
plainTextPassword6Unsafe = PlainTextPassword' . unsafeRange

plainTextPassword8 :: Text -> Maybe PlainTextPassword8
plainTextPassword8 = fmap PlainTextPassword' . checked

plainTextPassword8Unsafe :: Text -> PlainTextPassword8
plainTextPassword8Unsafe = PlainTextPassword' . unsafeRange

fromPlainTextPassword :: PlainTextPassword' t -> Text
fromPlainTextPassword = fromRange . fromPlainTextPassword'

-- | Convert a 'PlainTextPassword8' to a legacy 'PlainTextPassword'.
plainTextPassword8To6 :: PlainTextPassword8 -> PlainTextPassword6
plainTextPassword8To6 = PlainTextPassword' . unsafeRange . fromPlainTextPassword

newtype PlainTextPassword' (minLen :: Nat) = PlainTextPassword'
{fromPlainTextPassword' :: Range minLen (1024 :: Nat) Text}
deriving stock (Eq, Generic)
deriving (FromJSON, ToJSON, S.ToSchema) via Schema PlainTextPassword

instance Show PlainTextPassword where
show _ = "PlainTextPassword <hidden>"
deriving via (Schema (PlainTextPassword' tag)) instance ToSchema (PlainTextPassword' tag) => FromJSON (PlainTextPassword' tag)

instance ToSchema PlainTextPassword where
schema =
PlainTextPassword
<$> fromPlainTextPassword
.= untypedRangedSchema 6 1024 schema
deriving via (Schema (PlainTextPassword' tag)) instance ToSchema (PlainTextPassword' tag) => ToJSON (PlainTextPassword' tag)

deriving via (Schema (PlainTextPassword' tag)) instance ToSchema (PlainTextPassword' tag) => S.ToSchema (PlainTextPassword' tag)

instance Show (PlainTextPassword' minLen) where
show _ = "PlainTextPassword' <hidden>"

instance (KnownNat (n :: Nat), Within Text n 1024) => ToSchema (PlainTextPassword' n) where
schema = PlainTextPassword' <$> fromPlainTextPassword' .= schema

instance Arbitrary PlainTextPassword where
-- TODO: why 6..1024? For tests we might want invalid passwords as well, e.g. 3 chars
arbitrary = PlainTextPassword . fromRange <$> genRangeText @6 @1024 arbitrary
instance (KnownNat (n :: Nat), Within Text n 1024) => Arbitrary (PlainTextPassword' n) where
arbitrary = PlainTextPassword' <$> arbitrary

-- | Usage:
-- 1. Use this type in patterns to mark FUTUREWORKS.
Expand Down
16 changes: 8 additions & 8 deletions libs/wire-api/src/Wire/API/Provider.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import Data.Aeson
import Data.Aeson.TH
import Data.Id
import Data.Json.Util
import Data.Misc (HttpsUrl (..), PlainTextPassword (..))
import Data.Misc (HttpsUrl (..), PlainTextPassword6, PlainTextPassword8)
import Data.Range
import Imports
import Wire.API.Conversation.Code as Code
Expand Down Expand Up @@ -116,7 +116,7 @@ data NewProvider = NewProvider
newProviderUrl :: HttpsUrl,
newProviderDescr :: Range 1 1024 Text,
-- | If none provided, a password is generated.
newProviderPassword :: Maybe PlainTextPassword
newProviderPassword :: Maybe PlainTextPassword6
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform NewProvider)
Expand Down Expand Up @@ -145,7 +145,7 @@ data NewProviderResponse = NewProviderResponse
{ rsNewProviderId :: ProviderId,
-- | The generated password, if none was provided
-- in the 'NewProvider' request.
rsNewProviderPassword :: Maybe PlainTextPassword
rsNewProviderPassword :: Maybe PlainTextPassword8
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform NewProviderResponse)
Expand Down Expand Up @@ -214,7 +214,7 @@ instance FromJSON ProviderActivationResponse where
-- | Input data for a provider login request.
data ProviderLogin = ProviderLogin
{ providerLoginEmail :: Email,
providerLoginPassword :: PlainTextPassword
providerLoginPassword :: PlainTextPassword6
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform ProviderLogin)
Expand All @@ -237,7 +237,7 @@ instance FromJSON ProviderLogin where

-- | Input data for a provider deletion request.
newtype DeleteProvider = DeleteProvider
{deleteProviderPassword :: PlainTextPassword}
{deleteProviderPassword :: PlainTextPassword6}
deriving stock (Eq, Show)
deriving newtype (Arbitrary)

Expand Down Expand Up @@ -265,7 +265,7 @@ deriveJSON toJSONFieldName ''PasswordReset
data CompletePasswordReset = CompletePasswordReset
{ cpwrKey :: Code.Key,
cpwrCode :: Code.Value,
cpwrPassword :: PlainTextPassword
cpwrPassword :: PlainTextPassword6
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform CompletePasswordReset)
Expand All @@ -274,8 +274,8 @@ deriveJSON toJSONFieldName ''CompletePasswordReset

-- | The payload for changing a password.
data PasswordChange = PasswordChange
{ cpOldPassword :: PlainTextPassword,
cpNewPassword :: PlainTextPassword
{ cpOldPassword :: PlainTextPassword6,
cpNewPassword :: PlainTextPassword6
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform PasswordChange)
Expand Down
8 changes: 4 additions & 4 deletions libs/wire-api/src/Wire/API/Provider/Service.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import Data.ByteString.Conversion
import Data.Id
import Data.Json.Util ((#))
import Data.List1 (List1)
import Data.Misc (HttpsUrl (..), PlainTextPassword (..))
import Data.Misc (HttpsUrl (..), PlainTextPassword6)
import Data.PEM (PEM, pemParseBS, pemWriteLBS)
import Data.Proxy
import Data.Range (Range)
Expand Down Expand Up @@ -419,7 +419,7 @@ instance FromJSON UpdateService where
-- | Update service connection information.
-- This operation requires re-authentication via password.
data UpdateServiceConn = UpdateServiceConn
{ updateServiceConnPassword :: PlainTextPassword,
{ updateServiceConnPassword :: PlainTextPassword6,
updateServiceConnUrl :: Maybe HttpsUrl,
updateServiceConnKeys :: Maybe (Range 1 2 [ServiceKeyPEM]),
updateServiceConnTokens :: Maybe (Range 1 2 [ServiceToken]),
Expand All @@ -428,7 +428,7 @@ data UpdateServiceConn = UpdateServiceConn
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform UpdateServiceConn)

mkUpdateServiceConn :: PlainTextPassword -> UpdateServiceConn
mkUpdateServiceConn :: PlainTextPassword6 -> UpdateServiceConn
mkUpdateServiceConn pw = UpdateServiceConn pw Nothing Nothing Nothing Nothing

instance ToJSON UpdateServiceConn where
Expand All @@ -455,7 +455,7 @@ instance FromJSON UpdateServiceConn where

-- | Input data for a service deletion request.
newtype DeleteService = DeleteService
{deleteServicePassword :: PlainTextPassword}
{deleteServicePassword :: PlainTextPassword6}
deriving stock (Eq, Show)
deriving newtype (Arbitrary)

Expand Down
8 changes: 4 additions & 4 deletions libs/wire-api/src/Wire/API/Team.hs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import Data.Attoparsec.Combinator (choice)
import Data.ByteString.Conversion
import qualified Data.Code as Code
import Data.Id (TeamId, UserId)
import Data.Misc (PlainTextPassword (..))
import Data.Misc (PlainTextPassword6)
import Data.Range
import Data.Schema
import qualified Data.Swagger as S
Expand Down Expand Up @@ -290,7 +290,7 @@ instance ToSchema TeamUpdateData where
-- TeamDeleteData

data TeamDeleteData = TeamDeleteData
{ _tdAuthPassword :: Maybe PlainTextPassword,
{ _tdAuthPassword :: Maybe PlainTextPassword6,
_tdVerificationCode :: Maybe Code.Value
}
deriving stock (Eq, Show)
Expand All @@ -299,10 +299,10 @@ data TeamDeleteData = TeamDeleteData
instance Arbitrary TeamDeleteData where
arbitrary = TeamDeleteData <$> arbitrary <*> arbitrary

newTeamDeleteData :: Maybe PlainTextPassword -> TeamDeleteData
newTeamDeleteData :: Maybe PlainTextPassword6 -> TeamDeleteData
newTeamDeleteData = flip TeamDeleteData Nothing

newTeamDeleteDataWithCode :: Maybe PlainTextPassword -> Maybe Code.Value -> TeamDeleteData
newTeamDeleteDataWithCode :: Maybe PlainTextPassword6 -> Maybe Code.Value -> TeamDeleteData
newTeamDeleteDataWithCode = TeamDeleteData

instance ToSchema TeamDeleteData where
Expand Down
6 changes: 3 additions & 3 deletions libs/wire-api/src/Wire/API/Team/LegalHold.hs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ instance ToSchema UserLegalHoldStatusResponse where
-- RemoveLegalHoldSettingsRequest

data RemoveLegalHoldSettingsRequest = RemoveLegalHoldSettingsRequest
{ rmlhsrPassword :: Maybe PlainTextPassword
{ rmlhsrPassword :: Maybe PlainTextPassword6
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform RemoveLegalHoldSettingsRequest)
Expand All @@ -181,7 +181,7 @@ instance ToSchema RemoveLegalHoldSettingsRequest where
-- DisableLegalHoldForUserRequest

data DisableLegalHoldForUserRequest = DisableLegalHoldForUserRequest
{ dlhfuPassword :: Maybe PlainTextPassword
{ dlhfuPassword :: Maybe PlainTextPassword6
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform DisableLegalHoldForUserRequest)
Expand All @@ -197,7 +197,7 @@ instance ToSchema DisableLegalHoldForUserRequest where
-- ApproveLegalHoldForUserRequest

data ApproveLegalHoldForUserRequest = ApproveLegalHoldForUserRequest
{ alhfuPassword :: Maybe PlainTextPassword
{ alhfuPassword :: Maybe PlainTextPassword6
}
deriving stock (Eq, Show, Generic)
deriving (Arbitrary) via (GenericUniform ApproveLegalHoldForUserRequest)
Expand Down
6 changes: 3 additions & 3 deletions libs/wire-api/src/Wire/API/Team/Member.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import Data.Id (UserId)
import Data.Json.Util
import Data.Kind
import Data.LegalHold (UserLegalHoldStatus (..), defUserLegalHoldStatus)
import Data.Misc (PlainTextPassword (..))
import Data.Misc (PlainTextPassword6)
import Data.Proxy
import Data.Schema
import Data.Swagger (ToParamSchema (..))
Expand Down Expand Up @@ -390,7 +390,7 @@ instance ToSchema NewTeamMember where
-- TeamMemberDeleteData

newtype TeamMemberDeleteData = TeamMemberDeleteData
{ _tmdAuthPassword :: Maybe PlainTextPassword
{ _tmdAuthPassword :: Maybe PlainTextPassword6
}
deriving stock (Eq, Show)
deriving newtype (Arbitrary)
Expand All @@ -401,7 +401,7 @@ instance ToSchema TeamMemberDeleteData where
objectWithDocModifier "TeamMemberDeleteData" (description ?~ "Data for a team member deletion request in case of binding teams.") $
TeamMemberDeleteData <$> _tmdAuthPassword .= optFieldWithDocModifier "password" (description ?~ "The account password to authorise the deletion.") (maybeWithDefault Null schema)

newTeamMemberDeleteData :: Maybe PlainTextPassword -> TeamMemberDeleteData
newTeamMemberDeleteData :: Maybe PlainTextPassword6 -> TeamMemberDeleteData
newTeamMemberDeleteData = TeamMemberDeleteData

makeLenses ''TeamMember'
Expand Down
Loading