Skip to content

Deleted App's Database Being Returned #160

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

Closed
dylancopeland opened this issue Jul 29, 2017 · 5 comments
Closed

Deleted App's Database Being Returned #160

dylancopeland opened this issue Jul 29, 2017 · 5 comments
Assignees

Comments

@dylancopeland
Copy link

dylancopeland commented Jul 29, 2017

After getting a database reference and deleting the associated app, Firebase will always return the same instance to the initial database for an app's lifecycle.

The issue lies within FIRDatabase: https://github.com/firebase/firebase-ios-sdk/blob/master/Firebase/Database/Api/FIRDatabase.m#L122.

The instances array will hold an outdated reference of the database. The outdated database can point to a then deleted FIRApp. Perhaps when a FIRApp is deleted, any databases it owns should be removed from the instances array.

  • Xcode version: Version 8.3.3 (8E3004b)
  • Firebase SDK version: 4.0.4
  • Library version: 4.0.0
  • Firebase Product: database

Steps to reproduce:

1.) Create a Firebase app with a specific name.
2.) Authenticate against the app.
3.) Get a Firebase database reference.
4.) Sign out.
5.) Delete the Firebase app.
6.) Create a Firebase app using the same name used in step 1.
7.) Authenticate against the Firebase app created in step 6.
8.) Get a Firebase database reference with databaseForApp: using the app created in step 6.

The final Firebase database reference's app will actually point to the app created in step 1. This causes the database's authentication chain to break. Since the user is authenticated with the app created in step 6, the user will not be able to use the database.

@ryanwilson ryanwilson self-assigned this Aug 3, 2017
ryanwilson added a commit that referenced this issue Aug 5, 2017
When a FIRApp is deleted in Core, it should also be deleted from
the instances array in Database.

See #160 for more details.
@ryanwilson
Copy link
Member

Sorry, was on vacation the past week. Getting back to this now!

@ryanwilson
Copy link
Member

ryanwilson commented Aug 15, 2017

@dylancopeland the PR (#194) should fix the issue but I wanted to check - what's the use case / reason for deleting FIRApp and recreating it?

@dylancopeland
Copy link
Author

dylancopeland commented Aug 16, 2017

@ryanwilson Awesome, thank you!

Our data is sharded across a few Firebase projects. When a user authenticates against a new FIRApp, we were hoping to delete the old FIRApp that a user may have used from a previous session. The whole point of that was just to free up local & Firebase resources.

@ryanwilson
Copy link
Member

Okay great, thanks for the reply. I created a new issue (#202) to investigate some of the other SDKs as well to make sure we're cleaning up properly.

For your use case, I'd just suggest making sure that when you delete the FIRApp ensure that all existing instances are cleared out (any properties, local variables, etc).

Thanks for reporting this! I'll close it when #194 is closed.

ryanwilson added a commit that referenced this issue Aug 17, 2017
* Delete an app from Database when deleted in Core.

When a FIRApp is deleted in Core, it should also be deleted from
the instances array in Database.

See #160 for more details.

* Add tests for deleting databases.

* Add call to clean up deleted FIRDatabase instance.
@ryanwilson
Copy link
Member

Thanks again for reporting, @dylancopeland.

minafarid pushed a commit to minafarid/firebase-ios-sdk that referenced this issue Jun 6, 2018
* Delete an app from Database when deleted in Core.

When a FIRApp is deleted in Core, it should also be deleted from
the instances array in Database.

See firebase#160 for more details.

* Add tests for deleting databases.

* Add call to clean up deleted FIRDatabase instance.
@firebase firebase locked and limited conversation to collaborators Nov 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants