firebase / firebase/firebase-admin-node

Discrepancy in Admin SDK's updateUser and client JS SDK's updateProfile functions

Đang mở
#1,955 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
api: auth type: bug
Ngôn ngữ chính
TypeScript
Star
1.7k
Fork
419
Merge trung bình
3 ngày 10 giờ
Pull request đã merge (30 ngày)
16

Mô tả

### [REQUIRED] Step 2: Describe your environment

* Operating System version: MacOS 12.4
* Firebase SDK version: firebase-admin@10.3.0
* Firebase Product: Auth
* Node.js version: 16.17.1
* NPM version: 8.15.0

### [REQUIRED] Step 3: Describe the problem

#### Steps to reproduce:

There seem to be a discrepancy between how Admin SDK's `updateUser` works versus client JS SDK's `updateProfile` - more specifically how the `photoURL` field is being validated.

For example, using the client-side Firebase JS SDK we can update the `photoURL` to be a relative path which we later on assemble in order to render the actual profile photo.

This works just fine:

```
import firebase from 'firebase/app';

await firebase.auth().currentUser?.updateProfile({
photoURL: 'users/abc_123.jpg'
});
```

However, when updating the photo URL using Admin SDK (from the Firebase function), there seem to be additional validation step which requires the `photoURL` to be a valid URL starting with `http` or `https`.

So, this doesn't work because error `FirebaseAuthError: The photoURL field must be a valid URL.` is being thrown:

```
const admin = require('firebase-admin');

admin.auth().updateUser('...', {
photoURL: 'users/abc_123.jpg'
});
```

In my opinion there shouldn't be URL validation because Firebase Auth itself doesn't impose validation and plus it breaks our efforts to reuse the logic in both backend and frontend because if we try to update the profile photo from the backend, it breaks the way how we handle image rendering as we can't hard-code the whole URL since it changes based on some internal logic.

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

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

Hướng nghiên cứu

Start by reproducing the discrepancy with Admin SDK auth().updateUser and the client JS SDK currentUser.updateProfile using the relative photoURL shown in the issue. Compare the two validation paths and their existing tests, if present; done means the supported behavior is aligned or the limitation is explicitly documented.

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

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
authentication, backend
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
Khá rõ ràng
Mức phù hợp với người mới
38/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.