Skip to content
Merged
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
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# [2022-03-07]

## Release notes


* For wire.com operators: make sure that nginz is deployed (#2166)


## API changes


* Add qualified broadcast endpoint (#2166)


## Bug fixes and other updates


* Always create spar credentials during SCIM provisioning when applicable (#2174)


## Internal changes


* Add tests for additional information returned by `GET /api-version` (#2159)

* Clean up `Base64ByteString` implementation (#2170)

* The `Event` record type does not contain a `type` field anymore (#2160)

* Add MLS message types and corresponding deserialisers (#2145)

* Servantify `POST /register` and `POST /i/users` endpoints (#2121)


# [2022-03-01]

## Release notes
Expand Down
2 changes: 2 additions & 0 deletions charts/brig/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ data:
suspendTimeout: {{ .setSuspendInactiveUsers.suspendTimeout }}
{{- end }}
setRichInfoLimit: {{ .setRichInfoLimit }}
{{- if .setDefaultUserLocale }}
setDefaultUserLocale: {{ .setDefaultUserLocale }}
{{- end }}
setMaxTeamSize: {{ .setMaxTeamSize }}
setMaxConvSize: {{ .setMaxConvSize }}
setEmailVisibility: {{ .setEmailVisibility }}
Expand Down
2 changes: 1 addition & 1 deletion charts/nginz/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ nginx_conf:
- all
max_body_size: 40m
body_buffer_size: 256k
- path: /broadcast/otr/messages
- path: /broadcast
envs:
- all
max_body_size: 40m
Expand Down
2 changes: 1 addition & 1 deletion deploy/services-demo/conf/nginz/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ http {
proxy_pass http://galley;
}

location /broadcast/otr/messages {
location /broadcast {
include common_response_with_zauth.conf;
proxy_pass http://galley;
}
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ Additionally if `setSftListAllServers` is set to `enabled` (disabled by default)

#### setDefaultLocale (deprecated / ignored)

The brig server config option `setDefaultLocale` has been replaced by `setDefaultUserLocale` and `setDefaultTemplateLocale`. Both settings are optional and `setDefaultTemplateLocale` defaults to `EN` and `setDefaultLocale` defaults to `setDefaultTemplateLocale`. If `setDefaultLocale` was not set or set to `EN` before this change, nothing needs to be done. If `setDefaultLocale` was set to any other language other than `EN` the name of the setting should be changed to `setDefaultTemplateLocale`.
The brig server config option `setDefaultLocale` has been replaced by `setDefaultUserLocale` and `setDefaultTemplateLocale`. Both settings are optional and `setDefaultTemplateLocale` defaults to `EN` and `setDefaultLocale` defaults to `setDefaultTemplateLocale`. If `setDefaultLocale` was not set or set to `EN` before this change, nothing needs to be done. If `setDefaultLocale` was set to any other language other than `EN` the name of the setting should be changed to `setDefaultTemplateLocale`.

#### `setDefaultTemplateLocale`

Expand All @@ -410,7 +410,7 @@ optSettings:

#### `setDefaultUserLocale`

This option is the default user locale to be used if it is not set in the user profile. This can be the case if the users are provisioned by SCIM e.g. This option determines which language to use for email communication. If not set the default is the value that is configured for `setDefaultTemplateLocale`.
This option determines which language to use for email communication. It is the default value if none is given in the user profile, or if no user profile exists (eg., if user is being provisioned via SCIM or manual team invitation via the team management app). If not set, `setDefaultTemplateLocale` is used instead.

```
# [brig.yaml]
Expand All @@ -433,7 +433,7 @@ optSettings:
any key package whose expiry date is set further than 15 days after upload time will be rejected.


### Federated domain specific configuration settings
### Federated domain specific configuration settings
#### Restrict user search

The lookup and search of users on a wire instance can be configured. This can be done per federated domain.
Expand Down
102 changes: 69 additions & 33 deletions libs/types-common/src/Data/Json/Util.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE TypeApplications #-}

Expand Down Expand Up @@ -38,10 +39,12 @@ module Data.Json.Util

-- * Base64
Base64ByteString (..),
base64Schema,
Base64ByteStringL (..),
base64SchemaL,
fromBase64TextLenient,
fromBase64Text,
toBase64Text,
base64Schema,
)
where

Expand All @@ -52,12 +55,12 @@ import qualified Data.Aeson as A
import qualified Data.Aeson.Types as A
import qualified Data.Attoparsec.Text as Atto
import qualified Data.Attoparsec.Time as Atto
import Data.Bifunctor
import qualified Data.ByteString.Base64 as B64
import qualified Data.ByteString.Base64.Lazy as B64L
import qualified Data.ByteString.Base64.URL as B64U
import qualified Data.ByteString.Builder as BB
import qualified Data.ByteString.Conversion as BS
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.Lazy.Char8 as L8
import Data.Fixed
import Data.Schema
import Data.String.Conversions (cs)
Expand All @@ -70,6 +73,7 @@ import Data.Time.Format (formatTime, parseTimeM)
import qualified Data.Time.Lens as TL
import Data.Time.Locale.Compat (defaultTimeLocale)
import Imports
import Servant
import Test.QuickCheck (Arbitrary (arbitrary))
-- for UTCTime
import Test.QuickCheck.Instances ()
Expand Down Expand Up @@ -174,39 +178,71 @@ toJSONFieldName = A.defaultOptions {A.fieldLabelModifier = A.camelTo2 '_' . drop
dropPrefix = dropWhile (not . isUpper)

--------------------------------------------------------------------------------
-- base64-encoded lazy bytestrings

-- | Lazy 'ByteString' with base64 json encoding. Relevant discussion:
-- <https://github.com/bos/aeson/issues/126>. See test suite for more details.
newtype Base64ByteString = Base64ByteString {fromBase64ByteString :: L.ByteString}
-- | Base64-encoded strict 'ByteString'.
--
-- For proper Swagger generation, avoid using this type directly in APIs. Instead,
-- use a plain 'ByteString' (or a more specific newtype wrapper), and construct
-- instances using @deriving via@.
--
-- For URLs or HTTP headers, the base64url encoding is used.
--
-- Some related discussion: <https://github.com/bos/aeson/issues/126>.
newtype Base64ByteString = Base64ByteString {fromBase64ByteString :: ByteString}
deriving stock (Eq, Ord, Show)
deriving (FromJSON, ToJSON) via Schema Base64ByteString
deriving newtype (Arbitrary, IsString)

instance ToSchema Base64ByteString where
schema = fromBase64ByteString .= fmap Base64ByteString base64SchemaN

instance FromHttpApiData Base64ByteString where
parseUrlPiece = bimap Text.pack Base64ByteString . B64U.decode . Text.encodeUtf8

instance ToHttpApiData Base64ByteString where
toUrlPiece = Text.decodeUtf8With Text.lenientDecode . B64U.encode . fromBase64ByteString

instance S.ToParamSchema Base64ByteString where
toParamSchema _ = mempty & S.type_ ?~ S.SwaggerString

base64SchemaN :: ValueSchema NamedSwaggerDoc ByteString
base64SchemaN = toBase64Text .= parsedText "Base64ByteString" fromBase64Text

base64Schema :: ValueSchema SwaggerDoc ByteString
base64Schema = unnamed base64SchemaN

--------------------------------------------------------------------------------

-- | Base64-encoded lazy 'ByteString'.
-- Similar to 'Base64ByteString', but based on 'LByteString'.
newtype Base64ByteStringL = Base64ByteStringL {fromBase64ByteStringL :: LByteString}
deriving (Eq, Show, Generic)
deriving (FromJSON, ToJSON) via Schema Base64ByteStringL
deriving newtype (Arbitrary, IsString)

base64FromStrict :: Base64ByteString -> Base64ByteStringL
base64FromStrict = Base64ByteStringL . L.fromStrict . fromBase64ByteString

base64ToStrict :: Base64ByteStringL -> Base64ByteString
base64ToStrict = Base64ByteString . L.toStrict . fromBase64ByteStringL

instance ToSchema Base64ByteStringL where
schema = fromBase64ByteStringL .= fmap Base64ByteStringL base64SchemaLN

instance FromHttpApiData Base64ByteStringL where
parseUrlPiece = fmap base64FromStrict . parseUrlPiece

instance ToHttpApiData Base64ByteStringL where
toUrlPiece = toUrlPiece . base64ToStrict

instance S.ToParamSchema Base64ByteStringL where
toParamSchema _ = mempty & S.type_ ?~ S.SwaggerString

base64SchemaLN :: ValueSchema NamedSwaggerDoc LByteString
base64SchemaLN = L.toStrict .= fmap L.fromStrict base64SchemaN

instance FromJSON Base64ByteString where
parseJSON (A.String st) = handleError . B64L.decode . stToLbs $ st
where
stToLbs = L.fromChunks . pure . Text.encodeUtf8
handleError =
either
(const $ fail "parse Base64ByteString: invalid base64 encoding")
(pure . Base64ByteString)
parseJSON _ = fail "parse Base64ByteString: not a string"

instance ToJSON Base64ByteString where
toJSON (Base64ByteString lbs) = A.String . lbsToSt . B64L.encode $ lbs
where
lbsToSt =
Text.decodeUtf8With Text.lenientDecode
. mconcat
. L.toChunks

instance IsString Base64ByteString where
fromString = Base64ByteString . L8.pack

instance Arbitrary Base64ByteString where
arbitrary = Base64ByteString <$> arbitrary

base64Schema :: ValueSchema SwaggerDoc Base64ByteString
base64Schema = mkSchema mempty A.parseJSON (pure . A.toJSON)
base64SchemaL :: ValueSchema SwaggerDoc LByteString
base64SchemaL = unnamed base64SchemaLN

--------------------------------------------------------------------------------
-- Utilities
Expand Down
6 changes: 3 additions & 3 deletions libs/types-common/test/Test/Properties.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ tests =
\(c :: Char) -> Ascii.contains Ascii.Base64Url c ==> Ascii.contains Ascii.Standard c
],
testGroup
"Base64ByteString"
"Base64ByteStringL"
[ testProperty "validate (Aeson.decode . Aeson.encode) == pure . id" $
\(Util.Base64ByteString . L.pack -> s) ->
\(Util.Base64ByteStringL . L.pack -> s) ->
(Aeson.eitherDecode . Aeson.encode) s == Right s,
-- the property only considers valid 'String's, and it does not document the encoding very
-- well, so here are some unit tests (see
-- http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt for more).
testCase "examples" $ do
let go :: Util.Base64ByteString -> L.ByteString -> Assertion
let go :: Util.Base64ByteStringL -> L.ByteString -> Assertion
go b uu = do
Aeson.encode b @=? uu
(Aeson.eitherDecode . Aeson.encode) b @=? Right b
Expand Down
100 changes: 0 additions & 100 deletions libs/wire-api-federation/src/Wire/API/Federation/Event.hs

This file was deleted.

1 change: 0 additions & 1 deletion libs/wire-api-federation/wire-api-federation.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ library
Wire.API.Federation.Domain
Wire.API.Federation.Endpoint
Wire.API.Federation.Error
Wire.API.Federation.Event
other-modules:
Paths_wire_api_federation
hs-source-dirs:
Expand Down
2 changes: 2 additions & 0 deletions libs/wire-api/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ tests:
- cassava
- currency-codes
- directory
- either
- hex
- iso3166-country-codes
- iso639
Expand All @@ -123,6 +124,7 @@ tests:
- pretty
- proto-lens
- QuickCheck
- schema-profunctor
- string-conversions
- swagger2
- tasty
Expand Down
Loading