start of CSRF

This commit is contained in:
Jesse Lucas 2020-03-13 22:11:05 -04:00
parent af3d380b6a
commit ebf0541385
3 changed files with 33 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { SystemConfigService } from './system-config.service';
@Component({
selector: 'app-root',
@ -7,4 +8,15 @@ import { Component } from '@angular/core';
})
export class AppComponent {
title = 'Tech UI';
constructor(private systemConfigService: SystemConfigService) { }
ngOnInit(): void {
console.log("app component init");
this.systemConfigService.getSystemConfig().subscribe(
x => console.log('Observer got a next value: ' + x),
err => console.error('Observer got an error: ' + err),
() => console.log('Observer got a complete notification')
);
}
}

View File

@ -1,5 +1,6 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule, HttpClientXsrfModule } from '@angular/common/http';
import { MatTableModule } from '@angular/material/table';
import { MatPaginatorModule } from '@angular/material/paginator';
@ -13,7 +14,12 @@ import { StatusListComponent } from './status-list/status-list.component';
import { FolderListComponent } from './folder-list/folder-list.component';
import { DeviceListComponent } from './device-list/device-list.component';
import { StatusToggleComponent } from './status-toggle/status-toggle.component';
import { DeviceListDataSource } from './device-list/device-list-datasource';
const deviceID = (): String => {
const dID: String = globalThis.metadata['deviceID'];
return dID.substring(0, 5)
}
@NgModule({
declarations: [
@ -30,9 +36,17 @@ import { StatusToggleComponent } from './status-toggle/status-toggle.component';
MatTableModule,
MatPaginatorModule,
MatSortModule,
MatButtonToggleModule
MatButtonToggleModule,
HttpClientModule,
HttpClientXsrfModule.withOptions({
headerName: 'X-CSRF-Token-' + deviceID(),
cookieName: 'CSRF-Token-' + deviceID(),
})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

View File

@ -1,5 +1,6 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>TechUi</title>
@ -8,8 +9,11 @@
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script type="text/javascript" src="http://127.0.0.1:8384/meta.js"></script>
</head>
<body>
<app-root></app-root>
</body>
</html>
</html>