Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
86 changes: 53 additions & 33 deletions cassandra-schema.cql
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,24 @@ CREATE TABLE brig_test.team_invitation_info (
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

CREATE TABLE brig_test.provider_keys (
key text PRIMARY KEY,
provider uuid
) WITH bloom_filter_fp_chance = 0.1
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

CREATE TABLE brig_test.rich_info (
user uuid PRIMARY KEY,
json blob
Expand Down Expand Up @@ -801,12 +819,14 @@ CREATE TABLE brig_test.service_tag (
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

CREATE TABLE brig_test.login_codes (
user uuid PRIMARY KEY,
code text,
retries int,
timeout timestamp
) WITH bloom_filter_fp_chance = 0.01
CREATE TABLE brig_test.meta (
id int,
version int,
date timestamp,
descr text,
PRIMARY KEY (id, version)
) WITH CLUSTERING ORDER BY (version ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
Expand Down Expand Up @@ -1160,13 +1180,35 @@ CREATE TABLE brig_test.nonce (
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

CREATE TABLE brig_test.provider_keys (
key text PRIMARY KEY,
provider uuid
) WITH bloom_filter_fp_chance = 0.1
CREATE TABLE brig_test.login_codes (
user uuid PRIMARY KEY,
code text,
retries int,
timeout timestamp
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.LeveledCompactionStrategy'}
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

CREATE TABLE brig_test.oauth_client (
id uuid PRIMARY KEY,
name text,
redirect_uri blob,
secret blob
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
Expand Down Expand Up @@ -1529,28 +1571,6 @@ CREATE TABLE brig_test.connection (
AND speculative_retry = '99PERCENTILE';
CREATE INDEX conn_status ON brig_test.connection (status);

CREATE TABLE brig_test.meta (
id int,
version int,
date timestamp,
descr text,
PRIMARY KEY (id, version)
) WITH CLUSTERING ORDER BY (version ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';

CREATE TABLE brig_test.invitation (
inviter uuid,
id uuid,
Expand Down
1 change: 1 addition & 0 deletions changelog.d/5-internal/pr-2882
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
New internal endpoint to register OAuth clients
8 changes: 8 additions & 0 deletions charts/nginz/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ nginx_conf:
envs:
- all
disable_zauth: true
- path: /oauth/clients/([^/]*)$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should add that part to the changelog entry as well.

envs:
- all
- path: i/oauth/clients$
envs:
- staging
disable_zauth: true
basic_auth: true
galley:
- path: /conversations/code-check
disable_zauth: true
Expand Down
8 changes: 7 additions & 1 deletion libs/types-common/src/Data/Id.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module Data.Id
RequestId (..),
BotId (..),
NoId,
OAuthClientId,
)
where

Expand Down Expand Up @@ -87,7 +88,7 @@ import Servant (FromHttpApiData (..), ToHttpApiData (..))
import Test.QuickCheck
import Test.QuickCheck.Instances ()

data IdTag = A | C | I | U | P | S | T | STo
data IdTag = A | C | I | U | P | S | T | STo | OAuthClient
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like how the names get exponentially longer over time. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason you're not just using a new type OAuthClientId. it's fine to reuse Id, just wondering.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Id provides us with a lot of helpful utility functions, that's all.


idTagName :: IdTag -> Text
idTagName A = "Asset"
Expand All @@ -98,6 +99,7 @@ idTagName P = "Provider"
idTagName S = "Service"
idTagName T = "Team"
idTagName STo = "ScimToken"
idTagName OAuthClient = "OAuthClient"

class KnownIdTag (t :: IdTag) where
idTagValue :: IdTag
Expand All @@ -118,6 +120,8 @@ instance KnownIdTag 'T where idTagValue = T

instance KnownIdTag 'STo where idTagValue = STo

instance KnownIdTag 'OAuthClient where idTagValue = OAuthClient

type AssetId = Id 'A

type InvitationId = Id 'I
Expand All @@ -136,6 +140,8 @@ type TeamId = Id 'T

type ScimTokenId = Id 'STo

type OAuthClientId = Id 'OAuthClient

-- Id -------------------------------------------------------------------------

data NoId = NoId deriving (Eq, Show, Generic)
Expand Down
3 changes: 3 additions & 0 deletions services/brig/brig.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ library
Brig.API.MLS.KeyPackages
Brig.API.MLS.KeyPackages.Validation
Brig.API.MLS.Util
Brig.API.OAuth
Brig.API.Properties
Brig.API.Public
Brig.API.Public.Swagger
Expand Down Expand Up @@ -442,6 +443,7 @@ executable brig-integration
API.Metrics
API.MLS
API.MLS.Util
API.OAuth
API.Provider
API.RichInfo.Util
API.Search
Expand Down Expand Up @@ -680,6 +682,7 @@ executable brig-schema
V71_AddTableVCodesThrottle
V72_AddNonceTable
V73_ReplaceNonceTable
V74_AddOAuthClientTable
V9
V_FUTUREWORK

Expand Down
4 changes: 3 additions & 1 deletion services/brig/schema/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import qualified V70_UserEmailUnvalidated
import qualified V71_AddTableVCodesThrottle
import qualified V72_AddNonceTable
import qualified V73_ReplaceNonceTable
import qualified V74_AddOAuthClientTable
import qualified V9

main :: IO ()
Expand Down Expand Up @@ -155,7 +156,8 @@ main = do
V70_UserEmailUnvalidated.migration,
V71_AddTableVCodesThrottle.migration,
V72_AddNonceTable.migration,
V73_ReplaceNonceTable.migration
V73_ReplaceNonceTable.migration,
V74_AddOAuthClientTable.migration
-- When adding migrations here, don't forget to update
-- 'schemaVersion' in Brig.App

Expand Down
40 changes: 40 additions & 0 deletions services/brig/schema/src/V74_AddOAuthClientTable.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{-# LANGUAGE QuasiQuotes #-}

-- This file is part of the Wire Server implementation.
--
-- Copyright (C) 2022 Wire Swiss GmbH <opensource@wire.com>
--
-- 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 V74_AddOAuthClientTable
( migration,
)
where

import Cassandra.Schema
import Imports
import Text.RawString.QQ

migration :: Migration
migration =
Migration 74 "Add table for OAuth clients" $ do
schema'
[r|
CREATE TABLE IF NOT EXISTS oauth_client
( id uuid PRIMARY KEY
, name text
, redirect_uri blob
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text? (same for secrect)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, I did this according to other table columns with the same Haskell types.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we should probably keep it as is for consistency.

, secret blob
)
|]
13 changes: 12 additions & 1 deletion services/brig/src/Brig/API/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import qualified Brig.API.Connection as API
import Brig.API.Error
import Brig.API.Handler
import Brig.API.MLS.KeyPackages.Validation
import Brig.API.OAuth (IOAuthAPI, internalOauthAPI)
import Brig.API.Types
import qualified Brig.API.User as API
import qualified Brig.API.User as Api
Expand Down Expand Up @@ -105,14 +106,24 @@ import Wire.API.User.RichInfo
-- Sitemap (servant)

servantSitemap ::
Members
'[ BlacklistStore,
GalleyProvider,
UserPendingActivationStore p
]
r =>
ServerT (BrigIRoutes.API :<|> IOAuthAPI) (Handler r)
servantSitemap = brigInternalAPI :<|> internalOauthAPI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not add internalOAuthAPI to the list in brigInternalAPI? i would argue it's just one more thing next to mls, teams, user, auth, ...

same for public api.


brigInternalAPI ::
Members
'[ BlacklistStore,
GalleyProvider,
UserPendingActivationStore p
]
r =>
ServerT BrigIRoutes.API (Handler r)
servantSitemap =
brigInternalAPI =
ejpdAPI
:<|> accountAPI
:<|> mlsAPI
Expand Down
Loading