web/satellite: remove time caveats for object browser AGs

WHAT:
removed notBefore and notAfter caveats from object browser AGs

WHY:
caused a bug when user's clock is not synced correctly

Change-Id: I1af10418f1668003a09cba313eaed3b0764eabdc
This commit is contained in:
Vitalii Shpital 2021-05-24 17:28:29 +03:00
parent f2842a27e2
commit 2896a2736c
2 changed files with 3 additions and 13 deletions

View File

@ -130,9 +130,6 @@ export default class BucketsView extends Vue {
const cleanAPIKey: AccessGrant = await this.$store.dispatch(ACCESS_GRANTS_ACTIONS.CREATE, this.FILE_BROWSER_AG_NAME); const cleanAPIKey: AccessGrant = await this.$store.dispatch(ACCESS_GRANTS_ACTIONS.CREATE, this.FILE_BROWSER_AG_NAME);
await this.$store.dispatch(OBJECTS_ACTIONS.SET_API_KEY, cleanAPIKey.secret); await this.$store.dispatch(OBJECTS_ACTIONS.SET_API_KEY, cleanAPIKey.secret);
const now = new Date();
const inADay = new Date(now.setDate(now.getDate() + 1));
await this.worker.postMessage({ await this.worker.postMessage({
'type': 'SetPermission', 'type': 'SetPermission',
'isDownload': true, 'isDownload': true,
@ -141,8 +138,6 @@ export default class BucketsView extends Vue {
'isDelete': true, 'isDelete': true,
'buckets': [], 'buckets': [],
'apiKey': cleanAPIKey.secret, 'apiKey': cleanAPIKey.secret,
'notBefore': new Date().toISOString(),
'notAfter': inADay.toISOString(),
}); });
const grantEvent: MessageEvent = await new Promise(resolve => this.worker.onmessage = resolve); const grantEvent: MessageEvent = await new Promise(resolve => this.worker.onmessage = resolve);

View File

@ -73,11 +73,9 @@ export default class UploadFile extends Vue {
*/ */
public async generateObjectMapUrl(path: string): Promise<string> { public async generateObjectMapUrl(path: string): Promise<string> {
path = `${this.bucket}/${path}`; path = `${this.bucket}/${path}`;
const now = new Date();
const inADay = new Date(now.setDate(now.getDate() + 1));
try { try {
const key: string = await this.accessKey(this.apiKey, inADay, path); const key: string = await this.accessKey(this.apiKey, path);
path = encodeURIComponent(path.trim()); path = encodeURIComponent(path.trim());
@ -95,12 +93,11 @@ export default class UploadFile extends Vue {
public async generateShareLinkUrl(path: string): Promise<string> { public async generateShareLinkUrl(path: string): Promise<string> {
path = `${this.bucket}/${path}`; path = `${this.bucket}/${path}`;
const now = new Date(); const now = new Date();
const notAfter = new Date(now.setFullYear(now.getFullYear() + 100));
const LINK_SHARING_AG_NAME = `${path}_shared-object_${now.toISOString()}`; const LINK_SHARING_AG_NAME = `${path}_shared-object_${now.toISOString()}`;
const cleanAPIKey: AccessGrant = await this.$store.dispatch(ACCESS_GRANTS_ACTIONS.CREATE, LINK_SHARING_AG_NAME); const cleanAPIKey: AccessGrant = await this.$store.dispatch(ACCESS_GRANTS_ACTIONS.CREATE, LINK_SHARING_AG_NAME);
try { try {
const key: string = await this.accessKey(cleanAPIKey.secret, notAfter, path); const key: string = await this.accessKey(cleanAPIKey.secret, path);
path = encodeURIComponent(path.trim()); path = encodeURIComponent(path.trim());
@ -125,7 +122,7 @@ export default class UploadFile extends Vue {
/** /**
* Generates public access key. * Generates public access key.
*/ */
private async accessKey(cleanApiKey: string, notAfter: Date, path: string): Promise<string> { private async accessKey(cleanApiKey: string, path: string): Promise<string> {
const satelliteNodeURL = MetaUtils.getMetaContent('satellite-nodeurl'); const satelliteNodeURL = MetaUtils.getMetaContent('satellite-nodeurl');
this.worker.postMessage({ this.worker.postMessage({
@ -152,8 +149,6 @@ export default class UploadFile extends Vue {
'isDelete': true, 'isDelete': true,
'paths': [path], 'paths': [path],
'grant': grantData.value, 'grant': grantData.value,
'notBefore': new Date().toISOString(),
'notAfter': notAfter.toISOString(),
}); });
const event: MessageEvent = await new Promise(resolve => this.worker.onmessage = resolve); const event: MessageEvent = await new Promise(resolve => this.worker.onmessage = resolve);