Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iOS auth for resumable uploads in Storage Emulator #4184

Merged
merged 4 commits into from Feb 18, 2022

Conversation

tohhsinpei
Copy link
Member

Description

Issue(s)

This PR fixes #3550, possibly also #3584, #3765, and #3890.

Any upload via the iOS SDK gated by auth rules causes the Storage Emulator to crash. A permissions error occurs on the iOS side.

Cause

A resumable upload consists of two requests: start and upload, finalize. Clients are only expected to include an Authorization header in the first request. The 403 occurs because the emulator is expecting it in the second request as well. This bug does not occur for the other SDKs because they include the auth header in every request (e.g. JS, Android).

Scenarios Tested

Tested against example linked in issue and verified that 403 does not occur after fix.

src/emulator/storage/apis/firebase.ts Outdated Show resolved Hide resolved
src/emulator/storage/apis/firebase.ts Outdated Show resolved Hide resolved
@tonyjhuang
Copy link
Contributor

Were you able to verify the ios sdk now works with these changes?

@tohhsinpei
Copy link
Member Author

Were you able to verify the ios sdk now works with these changes?

Sort of... I ran the example against the changes. But I still need to set up the iOS integration tests as discussed and try it out there.

@tohhsinpei tohhsinpei merged commit aa178b2 into master Feb 18, 2022
@tohhsinpei tohhsinpei deleted the hsinpei/storage-ios-auth branch February 18, 2022 16:36
@hixfield
Copy link

@tohhsinpei I'm currently running into this issue (last couple of days). How can I get this fix early?

@tohhsinpei
Copy link
Member Author

@tohhsinpei I'm currently running into this issue (last couple of days). How can I get this fix early?

@hixfield We're working on a new release but in the meantime you could clone this repo and work off a local build; instructions here.

@yareeh
Copy link

yareeh commented Mar 8, 2022

With firebase-tools 10.2.2. that according to the release notes contains this fix I still get

Error: An unexpected error has occurred.
error Command failed with exit code 2.

and emulator crash with this in rule in storage.rules:

request.auth != null && request.auth.uid != null;

If I have this in rule:

request.auth.uid != null;

The emulator crashes with:

⚠  com.google.firebase.rules.runtime.common.EvaluationException: Error: /Users/jari/git/albertine/firebase/storage.rules line [5], column [14]. Null value error.

Error: An unexpected error has occurred.
error Command failed with exit code 2.

@tohhsinpei
Copy link
Member Author

With firebase-tools 10.2.2. that according to the release notes contains this fix I still get

Error: An unexpected error has occurred.
error Command failed with exit code 2.

and emulator crash with this in rule in storage.rules:

request.auth != null && request.auth.uid != null;

If I have this in rule:

request.auth.uid != null;

The emulator crashes with:

⚠  com.google.firebase.rules.runtime.common.EvaluationException: Error: /Users/jari/git/albertine/firebase/storage.rules line [5], column [14]. Null value error.

Error: An unexpected error has occurred.
error Command failed with exit code 2.

@yareeh I wasn't able to reproduce this. Could you provide the full contents of your storage.rules as well as the firebase-debug.log?

@yareeh
Copy link

yareeh commented Mar 21, 2022

@tohhsinpei – I updated the iOS SDK to 8.13.0 and now it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emulator Suite Crashes with Unexpected Error on Uploading Photo to Storage Emulator
5 participants