angular / angular/angularfire

Firebase storage 403 on delete

オープン
#3,279 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
7.8k
フォーク
2.2k
平均マージ
22時間 28分
マージ済み PR(30日)
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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。