Firebase storage 403 on delete
- 主要语言
- TypeScript
- 星标
- 7.8k
- 派生
- 2.2k
- 平均合并
- 22 小时 28 分钟
- 30 天内合并 PR
- 6
描述
### Version info
**Angular:** 14.1.0
**Firebase:** 9.6.10
**AngularFire:** 7.4.0
**Other (e.g. Ionic/Cordova, Node, browser, operating system):**
Mac
node 16.16.0
Chrome latest
### How to reproduce these conditions
**Failing test unit, Stackblitz demonstrating the problem**
**Steps to set up and reproduce**
**Sample data and security rules**
private _getImagePath(): Observable {
return of('debug/users/%USERID%/images/exportimage'); //For demo purpose
}
// Succeeds
setImage(data: Blob): Observable {
return this._getImagePath().pipe(
switchMap(path => new Observable(obs => {
this.storage.ref(path).put(data).then(x => {
obs.next(x);
obs.complete();
});
}))
);
}
// Succeeds
getMetadata(): Observable{
return this._getImagePath().pipe(
switchMap(path => this.storage.ref(path).getMetadata())
);
}
// Succeeds
getUrl(): Observable{
return this._getImagePath().pipe(
switchMap(path => this.storage.ref(path).getDownloadURL())
);
}
// fails
deleteImage(){
return this._getImagePath().pipe(
switchMap(path => this.storage.ref(path).delete())
);
}
I get the same result from `this._storage.storage.refFromURL(url).delete()`
rules:
service firebase.storage {
match /b/admob-app-id-5092275243.appspot.com/o {
match /debug/users/{userId}/images/exportimage {
allow read: if request.auth.uid == userId;
allow write: if request.auth.uid == userId &&
request.resource.size < 1 * 1024 * 1024 &&
request.resource.contentType.matches('image/.*');
}
match /release/users/{userId}/images/exportimage {
allow read: if request.auth.uid == userId;
allow write: if request.auth.uid == userId &&
request.resource.size < 1 * 1024 * 1024 &&
request.resource.contentType.matches('image/.*');
}
}
}
### Debug output
** Errors in the JavaScript console **
FirebaseError: Firebase Storage: User does not have permission to access 'debug/users/L7vT58BkdXQTHa6nF3hNgHVeHcq1/images/exportimage'. (storage/unauthorized)
** Output from `firebase.database().enableLogging(true);` **
** Screenshots **
### Expected behavior
The image should be deleted
### Actual behavior
403 unauthorised
贡献指南
调研方向
先从 deleteImage() 和 refFromURL(url).delete() 示例开始,然后检查报告中显示的 Firebase Storage 安全规则。使用列出的 Angular、Firebase 和 AngularFire 版本重现 403,并确定什么行为应当允许删除;当在文档所述规则下删除成功,或证明该问题是配置问题时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- firebase, typescript
- 领域
- cloud
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100