Skip to content

Commit d2487ff

Browse files
committed
Add RBAC
1 parent d3874a2 commit d2487ff

File tree

8 files changed

+579
-22
lines changed

8 files changed

+579
-22
lines changed

src/adabas/admin.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ const AdminCommands = [
4949
{ command: "cluster", path: [] },
5050
{ command: "tcp", path: [] },
5151
{ command: "plog", path: ["PLOG"] },
52+
{ command: "permission", path: ["RBAC"] },
53+
{ command: "permission?list=userrole", path: ["RBAC"] },
54+
{ command: "permission/", path: ["RBAC"] },
5255
]
5356

5457

@@ -199,6 +202,58 @@ export class AdabasAdmin {
199202
fileList(): Promise<any> {
200203
return triggerCallCommandArray(this.status.Dbid, 9);
201204
}
205+
// Create resource
206+
createRBACResource(resource:string,name:string): Promise<any> {
207+
const getConfig = {
208+
headers: authHeader("application/json"),
209+
useCredentails: true,
210+
};
211+
try {
212+
return axios
213+
.put(config.Url() + "/adabas/database/" + this.status.Dbid + "/permission/" + resource+"/"+name,{}, getConfig);
214+
}
215+
catch (error: any) {
216+
if (error.response) {
217+
if (error.response.status == 401 || error.response.status == 403) {
218+
userService.logout();
219+
location.reload();
220+
}
221+
}
222+
throw error;
223+
}
224+
}
225+
// Get the Adabas RBAC permission list of the Adabas database
226+
grantRBAC(def: any): Promise<any> {
227+
const getConfig = {
228+
headers: authHeader("application/json"),
229+
useCredentails: true,
230+
};
231+
try {
232+
return axios
233+
.put(config.Url() + "/adabas/database/" + this.status.Dbid + "/permission/" ,def, getConfig);
234+
}
235+
catch (error: any) {
236+
if (error.response) {
237+
if (error.response.status == 401 || error.response.status == 403) {
238+
userService.logout();
239+
location.reload();
240+
}
241+
}
242+
throw error;
243+
}
244+
}
245+
// Get the Adabas RBAC permission list of the Adabas database
246+
permissionList(): Promise<any> {
247+
return triggerCallCommandArray(this.status.Dbid, 17);
248+
}
249+
// Get the Adabas RBAC permission list of the Adabas database
250+
resourceList(resource:string): Promise<any> {
251+
return triggerCallOnArray("/adabas/database/" + this.status.Dbid + "/permission/"+resource , ["RBAC"]);
252+
}
253+
// Get the Adabas RBAC user role list of the Adabas database
254+
userRoleList(): Promise<any> {
255+
return triggerCallCommandArray(this.status.Dbid, 18);
256+
}
202257
// Get detailed file information of a file in the Adabas database
203258
fileInfo(file: number): Promise<any> {
204259
return triggerCallOnParameter("/adabas/database/" + this.status.Dbid + "/file/" + file, "File");

src/admin_views/Permission.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!--
2+
* Copyright (c) 2022 Software AG (http://www.softwareag.com/)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.-->
15+
16+
<template>
17+
<div class="permission">
18+
<MyHeader></MyHeader>
19+
<PermissionList :url="url" />
20+
</div>
21+
</template>
22+
23+
<script lang="ts">
24+
import { Component, Prop, Vue } from 'vue-property-decorator';
25+
import MyHeader from '@/components/Header.vue';
26+
import PermissionList from '@/components/PermissionList.vue';
27+
28+
@Component({
29+
components: {
30+
MyHeader,
31+
PermissionList,
32+
},
33+
})
34+
export default class Permission extends Vue {
35+
@Prop(String) readonly url: string | undefined;
36+
}
37+
</script>

src/components/Configuration.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@
451451
<b-form-input v-model="row.item.readPermission" />
452452
</template>
453453
<template v-slot:cell(writePermission)="row">
454-
<b-form-input v-model="row.item.writePermission" />
454+
<b-form-select v-model="selected" :options="options" size="sm" class="mt-3"></b-form-select>
455455
</template>
456456
<template v-slot:cell(delete)="row">
457457
<div class="mx-auto text-center">

src/components/DatabaseInfos.vue

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@
4444
small
4545
:items="infos"
4646
:fields="fields"
47-
></b-table>
47+
>
48+
<template v-slot:cell(Name)="data">
49+
<div class="toCapitalFirst">{{ data.value }}</div>
50+
</template>
51+
</b-table>
4852
</b-card-body>
4953
</b-card>
5054
<StatusBar />
@@ -129,17 +133,27 @@ export default class DatabaseInfos extends Vue {
129133
'Architecture',
130134
'Date',
131135
'Flags',
132-
'Last changed',
133-
'PLOG count',
136+
'PLOGCount',
137+
'PLOGExtent',
134138
'CurrentPLOGNumber',
135-
'Files loaded',
139+
'CurrentCLOGNumber',
140+
'MaxFileNumberLoaded',
141+
'TimeStampReplication',
136142
'TimeStampLog',
137143
'MaxFileNumber',
138144
'SecurityFile',
139145
'CheckpointFile',
140146
'ETDataFile',
147+
'Encrypted',
148+
'EncryptAlgorithm',
149+
'EncryptKMSTarget',
150+
'RBACSecurity',
151+
'RBACSystemFile',
141152
].forEach((element: string) => {
142-
this.$data.infos.push({ Name: element, Value: response.Gcb[element] });
153+
this.$data.infos.push({
154+
Name: element,
155+
Value: response.Gcb[element],
156+
});
143157
});
144158
this.$data.information = response;
145159
});
@@ -180,6 +194,9 @@ export default class DatabaseInfos extends Vue {
180194
h3 {
181195
margin: 40px 0 0;
182196
}
197+
.toCapitalFirst {
198+
text-transform: capitalize;
199+
}
183200
.card-header {
184201
font-weight: bold;
185202
font-size: 18px;

src/components/DatabaseList.vue

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,14 @@
4343
aria-controls="my-table"
4444
></b-pagination>
4545
</b-col>
46-
<b-col sm="2">
47-
<b-form-select v-model="perPage" :options="perPageOptions" size="sm" class="mt-3"></b-form-select>
48-
</b-col></b-row>
46+
<b-col sm="2">
47+
<b-form-select
48+
v-model="perPage"
49+
:options="perPageOptions"
50+
size="sm"
51+
class="mt-3"
52+
></b-form-select> </b-col
53+
></b-row>
4954
<b-row>
5055
<b-col>
5156
<b-form-group
@@ -99,12 +104,8 @@
99104
}}</router-link>
100105
</template>
101106
<template v-slot:[`cell(status.Active)`]="row">
102-
<div v-if="row.item.online()">
103-
Online
104-
</div>
105-
<div v-else>
106-
Offline
107-
</div>
107+
<div v-if="row.item.online()">Online</div>
108+
<div v-else>Offline</div>
108109
</template>
109110
<template v-slot:cell(action)="row">
110111
<div v-if="row.item.status.Active">
@@ -183,6 +184,14 @@
183184
>
184185
Files
185186
</b-button>
187+
<b-button v-if="row.item.status.Active"
188+
size="sm"
189+
variant="outline-primary"
190+
:to="'/permission/' + row.item.status.Dbid"
191+
class="mr-2"
192+
>
193+
Permissions
194+
</b-button>
186195
<div v-if="row.item.status.Active">
187196
<b-dropdown
188197
size="sm"
@@ -205,7 +214,8 @@
205214
>
206215
Command statistics
207216
</b-dropdown-item>
208-
<b-dropdown-item :disabled="!isMonitor(row.item)"
217+
<b-dropdown-item
218+
:disabled="!isMonitor(row.item)"
209219
size="sm"
210220
:to="'/monitor/' + row.item.status.Dbid"
211221
class="mr-2"
@@ -219,7 +229,8 @@
219229
>
220230
Buffer Pool
221231
</b-dropdown-item>
222-
<b-dropdown-item :disabled="!isMonitor(row.item)"
232+
<b-dropdown-item
233+
:disabled="!isMonitor(row.item)"
223234
size="sm"
224235
:to="'/bufferflush/' + row.item.status.Dbid"
225236
class="mr-2"
@@ -352,7 +363,7 @@ export default class DatabaseList extends Vue {
352363
return {
353364
perPage: 10,
354365
currentPage: 1,
355-
perPageOptions: [10,20,50,100],
366+
perPageOptions: [10, 20, 50, 100],
356367
filter: '',
357368
filterOn: [],
358369
fields: [
@@ -427,15 +438,15 @@ export default class DatabaseList extends Vue {
427438
.then((response: any) => {
428439
store.commit(
429440
'SET_STATUS',
430-
"Calling operation '" + operation + "' initiated...",
441+
"Calling operation '" + operation + "' initiated..."
431442
);
432443
console.log('Route to ' + dbid.dbid());
433444
router.push('/nuclog/' + dbid.dbid());
434445
})
435446
.catch((error: any) => {
436447
store.commit(
437448
'SET_STATUS',
438-
'Error calling' + operation + ':' + JSON.stringify(error),
449+
'Error calling' + operation + ':' + JSON.stringify(error)
439450
);
440451
router.push('/nuclog/' + dbid.dbid());
441452
});
@@ -463,7 +474,7 @@ export default class DatabaseList extends Vue {
463474
footerClass: 'p-2',
464475
hideHeaderClose: false,
465476
centered: true,
466-
},
477+
}
467478
)
468479
.then((value) => {
469480
if (value) {
@@ -493,7 +504,7 @@ export default class DatabaseList extends Vue {
493504
return;
494505
}
495506
isMonitor(item: any): boolean {
496-
if (item.status.StructureLevel>21) {
507+
if (item.status.StructureLevel > 21) {
497508
return true;
498509
}
499510
return false;

0 commit comments

Comments
 (0)