Skip to content

Commit 73a4e1d

Browse files
Configures CSRFilter to allow POST request and changed the Interface Instance back.
1 parent c738bf5 commit 73a4e1d

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

client/src/app/api/api/api.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import { SysInfo } from '../model/sysInfo';
4343
})
4444
export class ApiService {
4545

46-
public basePath = '';
46+
protected basePath = '';
4747
public defaultHeaders = new HttpHeaders();
4848
public configuration = new Configuration();
4949

@@ -238,7 +238,7 @@ export class ApiService {
238238

239239

240240
// This method is a common configuration to set the headers and query params
241-
commonConf(endpoint: string, queryParameters: HttpParams, observe: any = 'body', reportProgress: boolean = false): Observable<number> {
241+
private commonConf(endpoint: string, queryParameters: HttpParams, observe: any = 'body', reportProgress: boolean = false): Observable<number> {
242242
let headers = this.defaultHeaders;
243243

244244
// to determine the Accept header

client/src/app/api/model/instance.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ export const ComponentTypeEnum = {
2828

2929
export interface Instance {
3030
id?: number;
31-
host?: string;
32-
portNumber?: number;
33-
name?: string;
31+
host: string;
32+
portNumber: number;
33+
name: string;
3434
/**
3535
* Component Type
3636
*/
37-
componentType?: ComponentType;
37+
componentType: ComponentType;
3838
dockerId?: string;
3939
/**
4040
* State of the instance

client/src/app/dashboard/table-all/table-all.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,20 @@ export class TableAllComponent implements OnInit {
104104
* @param componentName
105105
*/
106106
openAddDialog() {
107-
const instance: Instance = {};
108-
instance.componentType = this.type;
109107
const dialogRef = this.dialog.open(AddDialogComponent, {
110108
width: '300px',
111109

112110
});
113111

114112
dialogRef.afterClosed().subscribe(dialogResult => {
115-
this.apiService.postInstance(instance.componentType, dialogResult.name).subscribe((result: Instance) => {
113+
this.apiService.postInstance(this.type, dialogResult.name).subscribe((result: Instance) => {
116114
this.dataSource.data.push({
117115
id: result.id,
118116
host: '',
119117
portNumber: result.portNumber,
120118
name: dialogResult.name,
121119
instanceState: result.instanceState,
122-
componentType: instance.componentType
120+
componentType: this.type
123121
});
124122
this.table.renderRows();
125123
}, err => {

conf/application.conf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ play.filters {
219219

220220
# Disabled filters remove elements from the enabled list.
221221
#disabled += filters.ExampleFilters
222-
disabled += play.filters.csrf.CSRFFilter
223-
222+
224223
## CORS filter configuration
225224
# https://www.playframework.com/documentation/latest/CorsFilter
226225
# ~~~~~
@@ -253,6 +252,12 @@ play.filters {
253252

254253
# Defaults to CSRFErrorHandler in the root package.
255254
#errorHandler = MyCSRFErrorHandler
255+
contentType {
256+
whiteList = ["application/json"]
257+
}
258+
routeModifiers {
259+
whiteList = ["nocsrf"]
260+
}
256261
}
257262

258263
## Security headers filter configuration

conf/routes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# Application
33
GET / controllers.FrontendController.index
44

5+
+nocsrf
56
-> /api controllers.ApiRouter
67
GET /ws controllers.InstanceRegistryController.socket
78

89
# Public assets
910
# Serve static assets under public directory
1011
GET /*file controllers.FrontendController.assetOrDefault(file)
1112
#GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
12-

0 commit comments

Comments
 (0)