web/satellite: create access grant: get restricted api key from web worker
WHAT: get new api key with restrictions from web worker WHY: apply restrictions Change-Id: I5747c9ede0c508b29f635a07895738715bd54621
This commit is contained in:
parent
c22ae05bbe
commit
005b089c01
@ -37,6 +37,8 @@ export default class SortAccessGrantsHeader extends Vue {
|
||||
@Prop({default: () => new Promise(() => false)})
|
||||
private readonly onHeaderClickCallback: OnHeaderClickCallback;
|
||||
|
||||
public AccessGrantsOrderBy = AccessGrantsOrderBy;
|
||||
|
||||
public sortBy: AccessGrantsOrderBy = AccessGrantsOrderBy.NAME;
|
||||
public sortDirection: SortDirection = SortDirection.ASCENDING;
|
||||
|
||||
|
@ -64,26 +64,12 @@ export default class BucketsSelection extends Vue {
|
||||
return this.storedBucketNames.length.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns selected bucket names from store or all bucket names.
|
||||
*/
|
||||
public get selectedBucketNames(): string[] {
|
||||
return this.storedBucketNames.length ? this.storedBucketNames : this.allBucketNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns stored selected bucket names.
|
||||
*/
|
||||
public get storedBucketNames(): string[] {
|
||||
private get storedBucketNames(): string[] {
|
||||
return this.$store.state.accessGrantsModule.selectedBucketNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all bucket names.
|
||||
*/
|
||||
public get allBucketNames(): string[] {
|
||||
return this.$store.state.bucketUsageModule.allBucketNames;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -11,12 +11,12 @@
|
||||
<div class="permissions__content">
|
||||
<div class="permissions__content__left">
|
||||
<div class="permissions__content__left__item">
|
||||
<input type="checkbox" id="read" name="read" v-model="isRead" :checked="isRead">
|
||||
<label class="permissions__content__left__item__label" for="read">Read</label>
|
||||
<input type="checkbox" id="download" name="download" v-model="isDownload" :checked="isDownload">
|
||||
<label class="permissions__content__left__item__label" for="download">Download</label>
|
||||
</div>
|
||||
<div class="permissions__content__left__item">
|
||||
<input type="checkbox" id="write" name="write" v-model="isWrite" :checked="isWrite">
|
||||
<label class="permissions__content__left__item__label" for="write">Write</label>
|
||||
<input type="checkbox" id="upload" name="upload" v-model="isUpload" :checked="isUpload">
|
||||
<label class="permissions__content__left__item__label" for="upload">Upload</label>
|
||||
</div>
|
||||
<div class="permissions__content__left__item">
|
||||
<input type="checkbox" id="list" name="list" v-model="isList" :checked="isList">
|
||||
@ -40,7 +40,7 @@
|
||||
<div class="permissions__content__right__bucket-bullets">
|
||||
<div
|
||||
class="permissions__content__right__bucket-bullets__container"
|
||||
v-for="(name, index) in selectedBucketNames"
|
||||
v-for="(name, index) in storedBucketNames"
|
||||
:key="index"
|
||||
>
|
||||
<BucketNameBullet :name="name"/>
|
||||
@ -90,8 +90,8 @@ export default class PermissionsStep extends Vue {
|
||||
private restrictedKey: string = '';
|
||||
private worker: Worker;
|
||||
|
||||
public isRead: boolean = true;
|
||||
public isWrite: boolean = true;
|
||||
public isDownload: boolean = true;
|
||||
public isUpload: boolean = true;
|
||||
public isList: boolean = true;
|
||||
public isDelete: boolean = true;
|
||||
|
||||
@ -156,16 +156,44 @@ export default class PermissionsStep extends Vue {
|
||||
* Holds on continue in browser button click logic.
|
||||
*/
|
||||
public onContinueInBrowserClick(): void {
|
||||
// mock
|
||||
return;
|
||||
this.worker.postMessage({
|
||||
'type': 'SetPermission',
|
||||
'isDownload': this.isDownload,
|
||||
'isUpload': this.isUpload,
|
||||
'isList': this.isList,
|
||||
'isDelete': this.isDelete,
|
||||
'buckets': this.selectedBucketNames,
|
||||
'apiKey': this.key,
|
||||
});
|
||||
|
||||
this.$router.push({
|
||||
name: RouteConfig.AccessGrants.with(RouteConfig.CreateAccessGrant.with(RouteConfig.PassphraseStep)).name,
|
||||
params: {
|
||||
key: this.restrictedKey,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns stored selected bucket names.
|
||||
*/
|
||||
public get selectedBucketNames(): string[] {
|
||||
public get storedBucketNames(): string[] {
|
||||
return this.$store.state.accessGrantsModule.selectedBucketNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns selected bucket names from store or all bucket names.
|
||||
*/
|
||||
private get selectedBucketNames(): string[] {
|
||||
return this.storedBucketNames.length ? this.storedBucketNames : this.allBucketNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all bucket names.
|
||||
*/
|
||||
private get allBucketNames(): string[] {
|
||||
return this.$store.state.bucketUsageModule.allBucketNames;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -18,21 +18,30 @@ const response = fetch('/static/static/wasm/access.wasm');
|
||||
instantiateStreaming(response, go.importObject).then(result => go.run(result.instance)).catch(err => self.postMessage(new Error(err.message)));
|
||||
|
||||
self.onmessage = function (event) {
|
||||
const type = event.data.type;
|
||||
const data = event.data;
|
||||
let result;
|
||||
switch (type) {
|
||||
switch (data.type) {
|
||||
case 'GenerateAccess':
|
||||
result = self.generateAccessGrant();
|
||||
|
||||
self.postMessage(result);
|
||||
break;
|
||||
case 'NewPermission':
|
||||
result = self.newPermission();
|
||||
|
||||
self.postMessage(result);
|
||||
break;
|
||||
case 'SetPermission':
|
||||
result = self.setAPIKeyPermission();
|
||||
const isDownload = data.isDownload;
|
||||
const isUpload = data.isUpload;
|
||||
const isList = data.isList;
|
||||
const isDelete = data.isDelete;
|
||||
const buckets = data.buckets;
|
||||
const apiKey = data.apiKey;
|
||||
|
||||
let permission = self.newPermission().value;
|
||||
|
||||
permission.AllowDownload = isDownload;
|
||||
permission.AllowUpload = isUpload;
|
||||
permission.AllowDelete = isDelete;
|
||||
permission.AllowList = isList;
|
||||
|
||||
result = self.setAPIKeyPermission(apiKey, buckets, permission);
|
||||
|
||||
self.postMessage(result);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user