Skip to content

Commit 1165360

Browse files
Merge pull request #886 from rocket-admin/fix-master-password
Fix master password: add master password to request header when it is turned on
2 parents 80ab1ba + 6ae9f0f commit 1165360

4 files changed

Lines changed: 28 additions & 5 deletions

File tree

frontend/src/app/components/connect-db/connect-db.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class ConnectDBComponent implements OnInit, OnDestroy {
6868

6969
ngOnInit() {
7070
this.connectionID = this._connections.currentConnectionID;
71+
this.isMasterKeyTurnedOn = this._connections.currentConnection.masterEncryption;
7172

7273
if (this.connectionID) this.getTitleSubscription = this._connections.getCurrentConnectionTitle().subscribe(connectionTitle => {
7374
this.title.setTitle(`Edit connection ${connectionTitle} | Rocketadmin`);
@@ -94,7 +95,6 @@ export class ConnectDBComponent implements OnInit, OnDestroy {
9495
}
9596

9697
get db():Connection {
97-
this.isMasterKeyTurnedOn = this._connections.currentConnection.masterEncryption;
9898
return this._connections.currentConnection;
9999
}
100100

frontend/src/app/components/db-table-row-edit/db-table-row-edit.component.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
padding: 36px 0 16px;
77
}
88

9+
@media (width <= 600px) {
10+
.wrapper {
11+
padding: 36px 9vw 16px;
12+
width: 100vw;
13+
}
14+
}
15+
916
.row-edit-header {
1017
display: flex;
1118
align-items: center;
@@ -17,9 +24,15 @@
1724
margin: 24px auto 40px;
1825
max-width: 520px;
1926
min-width: 300px;
20-
width: 96%;
27+
/* width: 96%; */
2128
}
2229

30+
/* @media (width <= 600px) {
31+
.form {
32+
padding: 0 9vw;
33+
}
34+
} */
35+
2336
.related-views {
2437
position: fixed;
2538
top: calc(52px + 96px);

frontend/src/app/services/connections.service.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,13 @@ export class ConnectionsService {
259259
dbCredentials.type = `agent_${dbCredentials.type}`
260260
}
261261

262-
return this._http.post('/connection', dbCredentials)
262+
263+
264+
return this._http.post('/connection', dbCredentials, {
265+
headers: {
266+
masterpwd: masterKey
267+
}
268+
})
263269
.pipe(
264270
map(res => {
265271
this._masterPassword.checkMasterPassword(connection.masterEncryption, connection.id, masterKey);
@@ -287,7 +293,11 @@ export class ConnectionsService {
287293
dbCredentials.type = `agent_${dbCredentials.type}`
288294
}
289295

290-
return this._http.put(`/connection/${connection.id}`, dbCredentials)
296+
return this._http.put(`/connection/${connection.id}`, dbCredentials, {
297+
headers: {
298+
masterpwd: masterKey
299+
}
300+
})
291301
.pipe(
292302
map(res => {
293303
this._masterPassword.checkMasterPassword(connection.masterEncryption, connection.id, masterKey);

frontend/src/app/services/token.interceptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class TokenInterceptor implements HttpInterceptor {
4747
withCredentials: true
4848
});
4949

50-
if (connectionID) {
50+
if (connectionID && !request.headers.get('masterpwd')) {
5151
const masterKey = localStorage.getItem(`${connectionID}__masterKey`) || '';
5252
request = request.clone({
5353
setHeaders: {

0 commit comments

Comments
 (0)