Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Add a warning on E2EE rooms if you try to make them public #5698

Merged
merged 24 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
131f499
Add Confirm Public Encrypted Room dialog
SimonBrandner Feb 27, 2021
0d9bc00
i18n
SimonBrandner Feb 27, 2021
5d6bc9a
Add second Confirm Public Encrypted Room dialog
SimonBrandner Feb 28, 2021
5a55b0d
i18n
SimonBrandner Feb 28, 2021
2442878
Remove unnecessary async
SimonBrandner Feb 28, 2021
a6deef7
Merge branch 'develop' into public-e2ee-warn
SimonBrandner May 22, 2021
02c1378
Fix
SimonBrandner May 22, 2021
0618460
Merge remote-tracking branch 'upstream/develop' into public-e2ee-warn
SimonBrandner Jul 12, 2021
c478b4e
Improve "Are you sure you want to make this encrypted room public?" d…
SimonBrandner Jul 12, 2021
90ecdac
Types!
SimonBrandner Jul 12, 2021
0e4ea97
Add defaultEncrypted prop
SimonBrandner Jul 13, 2021
d7acaa9
Update onEncryptionChange dialog
SimonBrandner Jul 13, 2021
82e0bce
Remove unnecessary code
SimonBrandner Jul 13, 2021
e445c9c
Merge remote-tracking branch 'upstream/develop' into public-e2ee-warn
SimonBrandner Jul 28, 2021
9ec4507
Update copy
SimonBrandner Jul 28, 2021
168a329
Remove additional word
SimonBrandner Jul 28, 2021
e076282
Fix typo
SimonBrandner Jul 28, 2021
717691e
Remove spaces
SimonBrandner Aug 6, 2021
67062da
Remove spaces
SimonBrandner Aug 6, 2021
94f915a
Remove spaces
SimonBrandner Aug 6, 2021
1e9437d
Use correct character
SimonBrandner Aug 6, 2021
3abc419
Remove spaces and use correct character
SimonBrandner Aug 6, 2021
6e688b3
Merge remote-tracking branch 'upstream/develop' into public-e2ee-warn
SimonBrandner Aug 6, 2021
1b8aae9
i18n
SimonBrandner Aug 6, 2021
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
5 changes: 5 additions & 0 deletions res/css/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ input[type=text]:focus, input[type=password]:focus, textarea:focus {
font-size: $font-14px;
color: $primary-fg-color;
word-wrap: break-word;

a {
color: $accent-color;
cursor: pointer;
}
}

.mx_Dialog_buttons {
Expand Down
5 changes: 4 additions & 1 deletion src/components/views/dialogs/CreateRoomDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ interface IProps {
defaultPublic?: boolean;
defaultName?: string;
parentSpace?: Room;
defaultEncrypted?: boolean;
onFinished(proceed: boolean, opts?: IOpts): void;
}

interface IState {
joinRule: JoinRule;
isPublic: boolean;
isEncrypted: boolean;
name: string;
topic: string;
Expand Down Expand Up @@ -74,8 +76,9 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {

const config = SdkConfig.get();
this.state = {
isPublic: this.props.defaultPublic || false,
isEncrypted: this.props.defaultEncrypted ?? privateShouldBeEncrypted(),
joinRule,
isEncrypted: privateShouldBeEncrypted(),
name: this.props.defaultName || "",
topic: "",
alias: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import RoomUpgradeWarningDialog from '../../../dialogs/RoomUpgradeWarningDialog'
import { upgradeRoom } from "../../../../../utils/RoomUpgrade";
import { arrayHasDiff } from "../../../../../utils/arrays";
import SettingsFlag from '../../../elements/SettingsFlag';
import createRoom, { IOpts } from '../../../../../createRoom';
import CreateRoomDialog from '../../../dialogs/CreateRoomDialog';

interface IProps {
roomId: string;
Expand Down Expand Up @@ -129,7 +131,38 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
if (refreshWhenTypes.includes(e.getType() as EventType)) this.forceUpdate();
};

private onEncryptionChange = () => {
private onEncryptionChange = async () => {
if (this.state.joinRule == "public") {
const dialog = Modal.createTrackedDialog('Confirm Public Encrypted Room', '', QuestionDialog, {
title: _t('Are you sure you want to add encryption to this public room?'),
description: <div>
<p> { _t(
"<b> It’s not recommended to add encryption to public rooms. </b>" +
SimonBrandner marked this conversation as resolved.
Show resolved Hide resolved
"Anyone can find and join public rooms, so anyone can read messages in them. " +
"You’ll get none of the benefits of encryption, and you won’t be able to turn it " +
SimonBrandner marked this conversation as resolved.
Show resolved Hide resolved
"off later. Encrypting messages in a public room will make receiving and sending " +
"messages slower.",
null,
{ "b": (sub) => <b> { sub } </b> },
SimonBrandner marked this conversation as resolved.
Show resolved Hide resolved
) } </p>
<p> { _t(
"To avoid these issues, create a <a> new encrypted room </a> for " +
SimonBrandner marked this conversation as resolved.
Show resolved Hide resolved
"the conversation you plan to have.",
null,
{ "a": (sub) => <a onClick={() => {
dialog.close();
this.createNewRoom(false, true);
}}> { sub } </a> },
) } </p>
</div>,

});

const { finished } = dialog;
const [confirm] = await finished;
if (!confirm) return;
}

Modal.createTrackedDialog('Enable encryption', '', QuestionDialog, {
title: _t('Enable encryption?'),
description: _t(
Expand Down Expand Up @@ -194,6 +227,41 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
}
}

if (
this.state.encrypted &&
this.state.joinRule !== JoinRule.Public &&
joinRule === JoinRule.Public
) {
const dialog = Modal.createTrackedDialog('Confirm Public Encrypted Room', '', QuestionDialog, {
title: _t("Are you sure you want to make this encrypted room public?"),
description: <div>
<p> { _t(
"<b> It’s not recommended to make encrypted rooms public. </b> " +
"It will mean anyone can find and join the room, so anyone can read messages. " +
"You’ll get none of the benefits of encryption. Encrypting messages in a public " +
"room will make receiving and sending messages slower.",
null,
{ "b": (sub) => <b> { sub } </b> },
) } </p>
<p> { _t(
"To avoid these issues, create a <a> new public room </a> for the conversation " +
"you plan to have.",
SimonBrandner marked this conversation as resolved.
Show resolved Hide resolved
null,
{
"a": (sub) => <a onClick={() => {
dialog.close();
this.createNewRoom(true, false);
}}> { sub } </a>,
},
) } </p>
</div>,
});

const { finished } = dialog;
const [confirm] = await finished;
if (!confirm) return;
}

if (beforeJoinRule === joinRule && !restrictedAllowRoomIds) return;

const content: IContent = {
Expand Down Expand Up @@ -254,6 +322,20 @@ export default class SecurityRoomSettingsTab extends React.Component<IProps, ISt
});
};

private createNewRoom = async (defaultPublic: boolean, defaultEncrypted: boolean) => {
const modal = Modal.createTrackedDialog<[boolean, IOpts]>(
"Create Room",
"Create room after trying to make an E2EE room public",
CreateRoomDialog,
{ defaultPublic, defaultEncrypted },
);
const [shouldCreate, opts] = await modal.finished;
if (shouldCreate) {
await createRoom(opts);
}
return shouldCreate;
};

private onHistoryRadioToggle = (history: HistoryVisibility) => {
const beforeHistory = this.state.history;
if (beforeHistory === history) return;
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1426,9 +1426,15 @@
"Send %(eventType)s events": "Send %(eventType)s events",
"Permissions": "Permissions",
"Select the roles required to change various parts of the room": "Select the roles required to change various parts of the room",
"Are you sure you want to add encryption to this public room?": "Are you sure you want to add encryption to this public room?",
"<b> It’s not recommended to add encryption to public rooms. </b>Anyone can find and join public rooms, so anyone can read messages in them. You’ll get none of the benefits of encryption, and you won’t be able to turn it off later. Encrypting messages in a public room will make receiving and sending messages slower.": "<b> It’s not recommended to add encryption to public rooms. </b>Anyone can find and join public rooms, so anyone can read messages in them. You’ll get none of the benefits of encryption, and you won’t be able to turn it off later. Encrypting messages in a public room will make receiving and sending messages slower.",
"To avoid these issues, create a <a> new encrypted room </a> for the conversation you plan to have.": "To avoid these issues, create a <a> new encrypted room </a> for the conversation you plan to have.",
"Enable encryption?": "Enable encryption?",
"Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. <a>Learn more about encryption.</a>": "Once enabled, encryption for a room cannot be disabled. Messages sent in an encrypted room cannot be seen by the server, only by the participants of the room. Enabling encryption may prevent many bots and bridges from working correctly. <a>Learn more about encryption.</a>",
"This upgrade will allow members of selected spaces access to this room without an invite.": "This upgrade will allow members of selected spaces access to this room without an invite.",
"Are you sure you want to make this encrypted room public?": "Are you sure you want to make this encrypted room public?",
"<b> It’s not recommended to make encrypted rooms public. </b> It will mean anyone can find and join the room, so anyone can read messages. You’ll get none of the benefits of encryption. Encrypting messages in a public room will make receiving and sending messages slower.": "<b> It’s not recommended to make encrypted rooms public. </b> It will mean anyone can find and join the room, so anyone can read messages. You’ll get none of the benefits of encryption. Encrypting messages in a public room will make receiving and sending messages slower.",
"To avoid these issues, create a <a> new public room </a> for the conversation you plan to have.": "To avoid these issues, create a <a> new public room </a> for the conversation you plan to have.",
"To link to this room, please add an address.": "To link to this room, please add an address.",
"Private (invite only)": "Private (invite only)",
"Only invited people can join.": "Only invited people can join.",
Expand Down