Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove strict connection #20861

Merged
merged 1 commit into from
May 24, 2024
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
201 changes: 0 additions & 201 deletions src/panels/config/cloud/account/cloud-remote-pref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import "../../../../components/ha-settings-row";
import "../../../../components/ha-switch";
// eslint-disable-next-line
import { formatDate } from "../../../../common/datetime/format_date";
import type { HaRadio } from "../../../../components/ha-radio";
import type { HaSwitch } from "../../../../components/ha-switch";
import {
CloudStatusLoggedIn,
Expand All @@ -23,7 +22,6 @@ import {
} from "../../../../data/cloud";
import type { HomeAssistant } from "../../../../types";
import { showToast } from "../../../../util/toast";
import { showAlertDialog } from "../../../lovelace/custom-card-helpers";
import { showCloudCertificateDialog } from "../dialog-cloud-certificate/show-dialog-cloud-certificate";

@customElement("cloud-remote-pref")
Expand Down Expand Up @@ -179,125 +177,6 @@ export class CloudRemotePref extends LitElement {
"ui.panel.config.cloud.account.remote.security_options"
)}
>
<ha-settings-row>
<span slot="heading">
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection"
)}
</span>
<span slot="description">
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_secondary"
)}
</span>
</ha-settings-row>

<div class="strict-connection-container">
<ha-formfield>
<ha-radio
name="strict-connection-mode"
value="disabled"
.checked=${strict_connection === "disabled"}
@change=${this._strictConnectionModeChanged}
></ha-radio>
<div slot="label">
<div class="primary">
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_option_disabled"
)}
</div>
<div class="secondary">
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_option_disabled_secondary"
)}
</div>
</div>
</ha-formfield>

<ha-formfield>
<ha-radio
name="strict-connection-mode"
value="guard_page"
.checked=${strict_connection === "guard_page"}
@change=${this._strictConnectionModeChanged}
></ha-radio>
<div slot="label">
<div class="primary">
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_option_guard_page"
)}
</div>
<div class="secondary">
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_option_guard_page_secondary"
)}
${strict_connection === "guard_page"
? html`
<br /><br />
⚠️
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_option_guard_page_warning"
)}
`
: nothing}
</div>
</div>
</ha-formfield>

<ha-formfield>
<ha-radio
name="strict-connection-mode"
value="drop_connection"
.checked=${strict_connection === "drop_connection"}
@change=${this._strictConnectionModeChanged}
></ha-radio>
<div slot="label">
<div class="primary">
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_option_drop_connection"
)}
</div>
<div class="secondary">
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_option_drop_connection_secondary"
)}
${strict_connection === "drop_connection"
? html`
<br /><br />
⚠️
${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_option_drop_connection_warning"
)}
`
: nothing}
</div>
</div>
</ha-formfield>
</div>

${strict_connection !== "disabled"
? html`
<ha-settings-row .narrow=${this.narrow}>
<span slot="heading"
>${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_link"
)}</span
>
<span slot="description"
>${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_link_secondary"
)}</span
>
<ha-button @click=${this._createLoginUrl}
>${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_create_link"
)}</ha-button
>
</ha-settings-row>
`
: nothing}

<hr />
<ha-settings-row wrap-heading>
<span slot="heading"
>${this.hass.localize(
Expand Down Expand Up @@ -389,24 +268,6 @@ export class CloudRemotePref extends LitElement {
}
}

private async _strictConnectionModeChanged(ev) {
const toggle = ev.target as HaRadio;

if (ev.target.value === this.cloudStatus?.prefs.strict_connection) {
return;
}

try {
await updateCloudPref(this.hass, {
strict_connection: ev.target.value,
});
fireEvent(this, "ha-refresh-cloud-status");
} catch (err: any) {
alert(err.message);
toggle.checked = !toggle.checked;
}
}

private async _copyURL(ev): Promise<void> {
const url = ev.currentTarget.url;
await copyToClipboard(url);
Expand All @@ -415,45 +276,6 @@ export class CloudRemotePref extends LitElement {
});
}

private async _createLoginUrl() {
try {
const result = await this.hass.callService(
"cloud",
"create_temporary_strict_connection_url",
undefined,
undefined,
false,
true
);
showAlertDialog(this, {
title: this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_link"
),
text: html`${this.hass.localize(
"ui.panel.config.cloud.account.remote.strict_connection_link_created_message"
)}
<div
style="display: flex; align-items: center; gap: 8px; margin-top: 8px;"
>
<ha-textfield .value=${result.response.url} readonly></ha-textfield>
<ha-button
style="flex-basis: 180px;"
.url=${result.response.url}
@click=${this._copyURL}
unelevated
>
<ha-svg-icon slot="icon" .path=${mdiContentCopy}></ha-svg-icon>
${this.hass.localize(
"ui.panel.config.cloud.account.remote.copy_link"
)}
</ha-button>
</div>`,
});
} catch (err: any) {
showAlertDialog(this, { text: err.message });
}
}

static get styles(): CSSResultGroup {
return css`
.preparing {
Expand Down Expand Up @@ -538,29 +360,6 @@ export class CloudRemotePref extends LitElement {
color: var(--secondary-text-color);
direction: var(--direction);
}
ha-formfield {
margin-left: -12px;
margin-inline-start: -12px;
margin-inline-end: initial;
--ha-formfield-align-items: start;
}
.strict-connection-container {
gap: 16px;
display: flex;
flex-direction: column;
}
.strict-connection-container ha-formfield {
--ha-formfield-align-items: start;
}
.strict-connection-container .primary {
font-size: 14px;
margin-top: 12px;
margin-bottom: 4px;
}
.strict-connection-container .secondary {
color: var(--secondary-text-color);
font-size: 12px;
}
hr {
border: none;
height: 1px;
Expand Down
14 changes: 0 additions & 14 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3844,24 +3844,10 @@
"hide_url": "Hide URL",
"copy_link": "Copy link",
"security_options": "Security options",
"strict_connection": "Remote login access",
"strict_connection_secondary": "Choose what happens when new devices visit your remote access link.",
"strict_connection_option_disabled": "Show login page",
"strict_connection_option_disabled_secondary": "Any new device visiting your remote access link are presented with a login page.",
"strict_connection_option_guard_page": "Block remote logins",
"strict_connection_option_guard_page_secondary": "New devices must log in with a temporary access link. Devices accessing the link that are not logged in will be presented with a page explaining the restrictions.",
"strict_connection_option_guard_page_warning": "This prevents outsiders from trying to log in to your system but also your own devices if they have not logged in previously.",
"strict_connection_option_drop_connection": "Block remote logins and show nothing",
"strict_connection_option_drop_connection_secondary": "This is the same as the above setting but instead provides a blank page for additional security.",
"strict_connection_option_drop_connection_warning": "This prevents outsiders from snooping the remote web address and trying to log in, but it may appear as if there is no system running when users try to access it.",
"external_activation": "Allow external activation of remote access",
"external_activation_secondary": "If you disable remote access on this page, having this setting enabled allows you to reactivate it remotely via your Nabu Casa account.",
"drop_connection_warning_title": "Remote log in has been deactivated",
"drop_connection_warning": "The below security options may make it appear the system is not running.",
"strict_connection_link": "Provide temporary login access",
"strict_connection_link_secondary": "This provides a link for new devices to login for the next hour.",
"strict_connection_create_link": "Create link",
"strict_connection_link_created_message": "Give this link to the person you want to give remote access to the login page of your Home Assistant instance.",
"certificate_info": "Certificate information",
"certificate_expire": "Certificate renewal at {date}",
"more_info": "More details"
Expand Down
Loading