angular / angular/angularfire

Firebase storage 403 on delete

Đang mở
#3,279 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
7.8k
Fork
2.2k
Merge trung bình
22 giờ 28 phút
Pull request đã merge (30 ngày)
6

Mô tả

### 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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với các ví dụ deleteImage() và refFromURL(url).delete(), sau đó kiểm tra các quy tắc bảo mật của Firebase Storage được nêu trong báo cáo. Tái hiện lỗi 403 bằng các phiên bản Angular, Firebase và AngularFire được liệt kê, đồng thời xác định hành vi nào sẽ cho phép xóa; công việc được xem là hoàn tất khi việc xóa thành công theo các quy tắc đã được ghi nhận hoặc chứng minh được rằng vấn đề nằm ở cấu hình.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
firebase, typescript
Lĩnh vực
cloud
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.