remove tor http warnings

This commit is contained in:
Matt Hill
2024-02-16 14:12:10 -07:00
parent c0a55142b5
commit 69d5f521a5
12 changed files with 13 additions and 195 deletions

View File

@@ -11,9 +11,7 @@ import {
filter,
first,
map,
merge,
Observable,
of,
pairwise,
startWith,
switchMap,
@@ -114,10 +112,9 @@ export class MenuComponent {
readonly theme$ = inject(THEME)
readonly warning$ = merge(
of(this.config.isTorHttp()),
this.patch.watch$('server-info', 'ntp-synced').pipe(map(synced => !synced)),
)
readonly warning$ = this.patch
.watch$('server-info', 'ntp-synced')
.pipe(map(synced => !synced))
constructor(
private readonly patch: PatchDB<DataModel>,

View File

@@ -11,7 +11,6 @@ import {
import { TuiInputPasswordModule } from '@taiga-ui/kit'
import { CAWizardComponent } from './ca-wizard/ca-wizard.component'
import { LoginPage } from './login.page'
import { LoginWarningComponent } from './warning.component'
const routes: Routes = [
{
@@ -25,7 +24,6 @@ const routes: Routes = [
CommonModule,
FormsModule,
CAWizardComponent,
LoginWarningComponent,
TuiButtonModule,
TuiCardModule,
TuiSurfaceModule,

View File

@@ -3,8 +3,6 @@
<!-- not Local HTTP -->
<ng-template #notLanHttp>
<login-warning />
<div tuiCardLarge tuiSurface="elevated" class="card">
<img alt="StartOS Icon" class="logo" src="assets/img/icon.png" />
<h1 class="header">Login to StartOS</h1>

View File

@@ -1,60 +0,0 @@
import { NgIf } from '@angular/common'
import { Component, inject } from '@angular/core'
import { WINDOW } from '@ng-web-apis/common'
import { TuiNotificationModule } from '@taiga-ui/core'
import { TuiButtonModule, TuiIconsModule } from '@taiga-ui/experimental'
import { ConfigService } from 'src/app/services/config.service'
@Component({
standalone: true,
selector: 'login-warning',
template: `
<tui-notification *ngIf="config.isTorHttp()" status="warning">
<button
tuiButton
size="s"
appearance="neutral"
iconRight="tuiIconExternalLink"
(click)="launchHttps()"
>
Open Https
</button>
<h2><strong>Http detected</strong></h2>
<p>
Tor is faster over https. Your Root CA must be trusted.
<a
href="https://docs.start9.com/0.3.5.x/user-manual/trust-ca"
target="_blank"
rel="noreferrer"
>
View instructions
</a>
</p>
</tui-notification>
`,
styles: [
`
@import '@taiga-ui/core/styles/taiga-ui-local';
:host {
@include center-left();
top: 1rem;
width: max(50%, 20rem);
}
button {
float: right;
margin: 0.5rem 0 0.5rem 1rem;
}
`,
],
imports: [NgIf, TuiButtonModule, TuiIconsModule, TuiNotificationModule],
})
export class LoginWarningComponent {
private readonly windowRef = inject(WINDOW)
readonly config = inject(ConfigService)
launchHttps() {
this.windowRef.open(`https://${this.config.getHost()}`, '_self')
}
}

View File

@@ -14,7 +14,7 @@ import { InstallProgressPipeModule } from 'src/app/common/install-progress/insta
template: `
<strong *ngIf="!installProgress; else installing">
{{ connected ? rendering.display : 'Unknown' }}
<!-- @TODO should show 'this may take a while' if sigterm-timeout is > 30s -->
<!-- @TODO should show 'this may take a while' if sigtermTimeout is > 30s -->
<span *ngIf="rendering.showDots" class="loading-dots"></span>
</strong>
<ng-template #installing>

View File

@@ -1,43 +0,0 @@
import { ChangeDetectionStrategy, Component } from '@angular/core'
import { TuiNotificationModule } from '@taiga-ui/core'
import {
TuiButtonModule,
TuiCellModule,
TuiTitleModule,
} from '@taiga-ui/experimental'
@Component({
selector: 'settings-http',
template: `
<tui-notification status="warning">
<div tuiCell [style.padding]="0">
<div tuiTitle>
Http detected
<div tuiSubtitle>
<div>
Tor is faster over https.
<a
href="https://docs.start9.com/0.3.5.x/user-manual/trust-ca"
target="_blank"
rel="noreferrer"
>
Download and trust your server's Root CA
</a>
, then switch to https.
</div>
</div>
</div>
<ng-content />
</div>
</tui-notification>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: true,
imports: [
TuiButtonModule,
TuiCellModule,
TuiNotificationModule,
TuiTitleModule,
],
})
export class SettingsHttpsComponent {}

View File

@@ -3,12 +3,10 @@ import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
import { TuiAlertService, TuiLoaderModule } from '@taiga-ui/core'
import { TuiButtonModule } from '@taiga-ui/experimental'
import { PatchDB } from 'patch-db-client'
import { ConfigService } from 'src/app/services/config.service'
import { DataModel } from 'src/app/services/patch-db/data-model'
import { ClientStorageService } from 'src/app/services/client-storage.service'
import { SettingsService } from '../settings.service'
import { SettingsSyncComponent } from './sync.component'
import { SettingsHttpsComponent } from './http.component'
import { SettingsButtonComponent } from './button.component'
import { SettingsUpdateComponent } from './update.component'
@@ -17,19 +15,7 @@ import { SettingsUpdateComponent } from './update.component'
template: `
<ng-container *ngIf="server$ | async as server; else loading">
<settings-sync *ngIf="!server['ntp-synced']" />
<settings-http *ngIf="isTorHttp">
<a
tuiButton
appearance="glass"
iconRight="tuiIconExternalLinkLarge"
target="_self"
size="s"
[href]="'https://' + server.ui.torHostname"
>
Open Https
</a>
</settings-http>
<section *ngFor="let cat of service.settings | keyvalue : asIsOrder">
<section *ngFor="let cat of service.settings | keyvalue: asIsOrder">
<h3 class="g-title" (click)="addClick(cat.key)">{{ cat.key }}</h3>
<ng-container *ngFor="let btn of cat.value">
<settings-button [button]="btn">
@@ -46,8 +32,8 @@ import { SettingsUpdateComponent } from './update.component'
!server.network.outboundProxy
? 'None'
: server.network.outboundProxy === 'primary'
? 'System Primary'
: server.network.outboundProxy.proxyId
? 'System Primary'
: server.network.outboundProxy.proxyId
}}
</div>
</settings-button>
@@ -82,7 +68,6 @@ import { SettingsUpdateComponent } from './update.component'
TuiLoaderModule,
TuiButtonModule,
SettingsSyncComponent,
SettingsHttpsComponent,
SettingsButtonComponent,
SettingsUpdateComponent,
],
@@ -91,7 +76,6 @@ export class SettingsMenuComponent {
private readonly clientStorageService = inject(ClientStorageService)
private readonly alerts = inject(TuiAlertService)
readonly isTorHttp = inject(ConfigService).isTorHttp()
readonly server$ = inject(PatchDB<DataModel>).watch$('server-info')
readonly service = inject(SettingsService)

View File

@@ -1,15 +0,0 @@
<ion-item color="warning" class="ion-margin-bottom">
<ion-icon slot="start" name="warning-outline"></ion-icon>
<ion-label class="warn-label">
<h2>You are using unencrypted http</h2>
<p>
Click the button on the right to switch to https. Your browser may warn
you that the page is insecure. You can safely bypass this warning. It will
go away after you download and trust your Embassy's certificate
</p>
</ion-label>
<ion-button slot="end" color="light" (click)="launchHttps()">
Open Https
<ion-icon slot="end" name="open-outline"></ion-icon>
</ion-button>
</ion-item>

View File

@@ -1,8 +0,0 @@
.warn-label {
h2 {
font-weight: 700;
}
p {
font-weight: 600;
}
}

View File

@@ -1,18 +0,0 @@
import { DOCUMENT } from '@angular/common'
import { ChangeDetectionStrategy, Component, Inject } from '@angular/core'
@Component({
selector: 'insecure-warning',
templateUrl: './insecure-warning.component.html',
styleUrls: ['./insecure-warning.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class InsecureWarningComponent {
constructor(@Inject(DOCUMENT) private readonly document: Document) {}
launchHttps() {
this.document.defaultView?.open(
this.document.location.href.replace('http', 'https'),
)
}
}

View File

@@ -1,11 +0,0 @@
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { IonicModule } from '@ionic/angular'
import { InsecureWarningComponent } from './insecure-warning.component'
@NgModule({
declarations: [InsecureWarningComponent],
imports: [CommonModule, IonicModule],
exports: [InsecureWarningComponent],
})
export class InsecureWarningComponentModule {}

View File

@@ -64,10 +64,6 @@ export class ConfigService {
)
}
isTorHttp(): boolean {
return this.isTor() && !this.isHttps()
}
isLanHttp(): boolean {
return !this.isTor() && !this.isLocalhost() && !this.isHttps()
}
@@ -80,12 +76,12 @@ export class ConfigService {
return this.isTor()
? info.addressInfo.torHostname
: this.isLocalhost()
? `https://${info.addressInfo.lanHostname}`
: this.isLocal() || this.isIpv4() || this.isIpv6()
? `https://${this.hostname}`
: info.addressInfo.domainInfo?.subdomain
? `https://${info.addressInfo.domainInfo.subdomain}${info.addressInfo.domainInfo.domain}`
: `https://${info.addressInfo.domainInfo?.domain}`
? `https://${info.addressInfo.lanHostname}`
: this.isLocal() || this.isIpv4() || this.isIpv6()
? `https://${this.hostname}`
: info.addressInfo.domainInfo?.subdomain
? `https://${info.addressInfo.domainInfo.subdomain}${info.addressInfo.domainInfo.domain}`
: `https://${info.addressInfo.domainInfo?.domain}`
}
getHost(): string {