Skip to content

Commit

Permalink
WPB-8702 Retrieve in database users that can only login with Phone Nu…
Browse files Browse the repository at this point in the history
…mbers & SMS to login (#4024)
  • Loading branch information
battermann authored May 3, 2024
1 parent ee762a0 commit 69411da
Show file tree
Hide file tree
Showing 10 changed files with 579 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ packages:
, tools/db/inconsistencies/
, tools/db/migrate-sso-feature-flag/
, tools/db/move-team/
, tools/db/phone-users/
, tools/db/repair-handles/
, tools/db/repair-brig-clients-table/
, tools/db/service-backfill/
Expand Down Expand Up @@ -127,6 +128,8 @@ package proxy
ghc-options: -Werror
package mlsstats
ghc-options: -Werror
package phone-users
ghc-options: -Werror
package rabbitmq-consumer
ghc-options: -Werror
package repair-handles
Expand Down Expand Up @@ -179,6 +182,6 @@ package fedcalls
-- - these packages have bounds that are justified with their current
-- dependency set, however, we have updated their dependencies, such
-- that they work with newer base and ghc (api) versions
allow-newer:
allow-newer:
, proto-lens-protoc:base
, proto-lens-protoc:ghc
1 change: 1 addition & 0 deletions changelog.d/5-internal/WPB-8702
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add tool to determine number of phone-only users
1 change: 1 addition & 0 deletions nix/local-haskell-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
inconsistencies = hself.callPackage ../tools/db/inconsistencies/default.nix { inherit gitignoreSource; };
migrate-sso-feature-flag = hself.callPackage ../tools/db/migrate-sso-feature-flag/default.nix { inherit gitignoreSource; };
move-team = hself.callPackage ../tools/db/move-team/default.nix { inherit gitignoreSource; };
phone-users = hself.callPackage ../tools/db/phone-users/default.nix { inherit gitignoreSource; };
repair-brig-clients-table = hself.callPackage ../tools/db/repair-brig-clients-table/default.nix { inherit gitignoreSource; };
repair-handles = hself.callPackage ../tools/db/repair-handles/default.nix { inherit gitignoreSource; };
service-backfill = hself.callPackage ../tools/db/service-backfill/default.nix { inherit gitignoreSource; };
Expand Down
1 change: 1 addition & 0 deletions tools/db/phone-users/.ormolu
44 changes: 44 additions & 0 deletions tools/db/phone-users/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Phone users

This program scans brig's users table and determines the number of users that can only login by phone/sms.

Example usage:

```shell
phone-users --brig-cassandra-keyspace brig --galley-cassandra-keyspace galley -l 100000
```

Display usage:

```shell
phone-users -h
```

```text
phone-users
Usage: phone-users [--brig-cassandra-host HOST] [--brig-cassandra-port PORT]
[--brig-cassandra-keyspace STRING]
[--galley-cassandra-host HOST] [--galley-cassandra-port PORT]
[--galley-cassandra-keyspace STRING] [-l|--limit INT]
This program scans brig's users table and determines the number of users that
can only login by phone/sms
Available options:
-h,--help Show this help text
--brig-cassandra-host HOST
Cassandra Host for brig (default: "localhost")
--brig-cassandra-port PORT
Cassandra Port for brig (default: 9042)
--brig-cassandra-keyspace STRING
Cassandra Keyspace for brig (default: "brig_test")
--galley-cassandra-host HOST
Cassandra Host for galley (default: "localhost")
--galley-cassandra-port PORT
Cassandra Port for galley (default: 9043)
--galley-cassandra-keyspace STRING
Cassandra Keyspace for galley
(default: "galley_test")
-l,--limit INT Limit the number of users to process
```
23 changes: 23 additions & 0 deletions tools/db/phone-users/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2024 Wire Swiss GmbH <[email protected]>
--
-- This program is free software: you can redistribute it and/or modify it under
-- the terms of the GNU Affero General Public License as published by the Free
-- Software Foundation, either version 3 of the License, or (at your option) any
-- later version.
--
-- This program is distributed in the hope that it will be useful, but WITHOUT
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-- FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
-- details.
--
-- You should have received a copy of the GNU Affero General Public License along
-- with this program. If not, see <https://www.gnu.org/licenses/>.

module Main where

import qualified PhoneUsers.Lib as Lib

main :: IO ()
main = Lib.main
48 changes: 48 additions & 0 deletions tools/db/phone-users/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# WARNING: GENERATED FILE, DO NOT EDIT.
# This file is generated by running hack/bin/generate-local-nix-packages.sh and
# must be regenerated whenever local packages are added or removed, or
# dependencies are added or removed.
{ mkDerivation
, aeson
, aeson-pretty
, base
, bytestring
, cassandra-util
, conduit
, cql
, gitignoreSource
, imports
, lens
, lib
, optparse-applicative
, time
, tinylog
, types-common
, wire-api
}:
mkDerivation {
pname = "phone-users";
version = "1.0.0";
src = gitignoreSource ./.;
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [
aeson
aeson-pretty
bytestring
cassandra-util
conduit
cql
imports
lens
optparse-applicative
time
tinylog
types-common
wire-api
];
executableHaskellDepends = [ base ];
description = "Check users that are only able to login via phone";
license = lib.licenses.agpl3Only;
mainProgram = "phone-users";
}
96 changes: 96 additions & 0 deletions tools/db/phone-users/phone-users.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
cabal-version: 3.0
name: phone-users
version: 1.0.0
synopsis: Check users that are only able to login via phone
category: Network
author: Wire Swiss GmbH
maintainer: Wire Swiss GmbH <[email protected]>
copyright: (c) 2024 Wire Swiss GmbH
license: AGPL-3.0-only
build-type: Simple

library
hs-source-dirs: src
exposed-modules:
PhoneUsers.Lib
PhoneUsers.Types

ghc-options:
-O2 -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates
-Wpartial-fields -fwarn-tabs -optP-Wno-nonportable-include-path
-funbox-strict-fields -threaded -with-rtsopts=-N
-Wredundant-constraints -Wunused-packages

build-depends:
, aeson
, aeson-pretty
, bytestring
, cassandra-util
, conduit
, cql
, imports
, lens
, optparse-applicative
, time
, tinylog
, types-common
, wire-api

default-extensions:
AllowAmbiguousTypes
BangPatterns
ConstraintKinds
DataKinds
DefaultSignatures
DeriveFunctor
DeriveGeneric
DeriveLift
DeriveTraversable
DerivingStrategies
DerivingVia
DuplicateRecordFields
EmptyCase
FlexibleContexts
FlexibleInstances
FunctionalDependencies
GADTs
GeneralizedNewtypeDeriving
InstanceSigs
KindSignatures
LambdaCase
MultiParamTypeClasses
MultiWayIf
NamedFieldPuns
NoImplicitPrelude
OverloadedLabels
OverloadedRecordDot
OverloadedStrings
PackageImports
PatternSynonyms
PolyKinds
QuasiQuotes
RankNTypes
RecordWildCards
ScopedTypeVariables
StandaloneDeriving
TupleSections
TypeApplications
TypeFamilies
TypeFamilyDependencies
TypeOperators
UndecidableInstances
ViewPatterns

executable phone-users
main-is: Main.hs
build-depends:
, base
, phone-users

hs-source-dirs: app
default-language: Haskell2010
ghc-options:
-O2 -Wall -Wincomplete-uni-patterns -Wincomplete-record-updates
-Wpartial-fields -fwarn-tabs -optP-Wno-nonportable-include-path
-funbox-strict-fields -threaded -with-rtsopts=-N
-Wredundant-constraints -Wunused-packages
Loading

0 comments on commit 69411da

Please sign in to comment.