summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts')
-rw-r--r--src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts
index f9a351367..451a7dd38 100644
--- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts
+++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-details/rgw-bucket-details.component.ts
@@ -2,6 +2,8 @@ import { Component, Input, OnChanges } from '@angular/core';
import { RgwBucketService } from '~/app/shared/api/rgw-bucket.service';
+import * as xml2js from 'xml2js';
+
@Component({
selector: 'cd-rgw-bucket-details',
templateUrl: './rgw-bucket-details.component.html',
@@ -11,6 +13,8 @@ export class RgwBucketDetailsComponent implements OnChanges {
@Input()
selection: any;
+ aclPermissions: Record<string, string[]> = {};
+
constructor(private rgwBucketService: RgwBucketService) {}
ngOnChanges() {
@@ -18,7 +22,43 @@ export class RgwBucketDetailsComponent implements OnChanges {
this.rgwBucketService.get(this.selection.bid).subscribe((bucket: object) => {
bucket['lock_retention_period_days'] = this.rgwBucketService.getLockDays(bucket);
this.selection = bucket;
+ this.aclPermissions = this.parseXmlAcl(this.selection.acl, this.selection.owner);
});
}
}
+
+ parseXmlAcl(xml: any, bucketOwner: string): Record<string, string[]> {
+ const parser = new xml2js.Parser({ explicitArray: false, trim: true });
+ let data: Record<string, string[]> = {
+ Owner: ['-'],
+ AllUsers: ['-'],
+ AuthenticatedUsers: ['-']
+ };
+ parser.parseString(xml, (err, result) => {
+ if (err) return null;
+
+ const xmlGrantees: any = result['AccessControlPolicy']['AccessControlList']['Grant'];
+ if (Array.isArray(xmlGrantees)) {
+ for (let i = 0; i < xmlGrantees.length; i++) {
+ const grantee = xmlGrantees[i];
+ if (grantee?.Grantee?.URI) {
+ const granteeGroup = grantee.Grantee.URI.split('/').pop();
+ if (data[granteeGroup].includes('-')) {
+ data[granteeGroup] = [grantee?.Permission];
+ } else {
+ data[granteeGroup].push(grantee?.Permission);
+ }
+ }
+ if (grantee?.Grantee?.ID && bucketOwner === grantee?.Grantee?.ID) {
+ data['Owner'] = grantee?.Permission;
+ }
+ }
+ } else {
+ if (xmlGrantees?.Grantee?.ID && bucketOwner === xmlGrantees?.Grantee?.ID) {
+ data['Owner'] = xmlGrantees?.Permission;
+ }
+ }
+ });
+ return data;
+ }
}