If I understand the question correctly, the criteria are as follows:
- You offer a purchasable app that provides access to premium data
- Only paid customers should be able to read that data
- It is possible for users to log in with FirebaseSimpleLogin without downloading your app
- You would like to prevent this
Assuming all of this is correct, I see two quick answers:
Create your own auth tokens
Since FirebaseSimpleLogin is available from in the cloud, you won't be able to prevent users from authenticating based on device. But FirebaseSimpleLogin is just a wrapper on the token generator, so nothing stops you from generating your own.
#!/usr/bin/env node
var FirebaseTokenGenerator = require("firebase-token-generator");
var tokenGenerator = new FirebaseTokenGenerator(YOUR_FIREBASE_SECRET);
if( validateUserIsFromiOSApp() ) {
var token = tokenGenerator.createToken({id: userId});
}
function validateUserIsFromiOSApp() { /* ??? */ }
Now one can simply turn off simple login and users will have no way to authenticate without first obtaining a valid token from your service. Security rules here are proprietary, but would contain something like this:
".read": "auth.uid !== null"
With some creativity, depending on the use case for requiring twitter/facebook auth, you might be able to bypass the entire auth process by simply having the app request a token when it registers and never forcing the user to authenticate at all.
Using some meta data in conjunction with simple login
Of course, simple login is by definition simple, and does not require a server process. You could utilize this by storing information about which users have purchased your app:
- user purchases app from store
- during receipt of transaction, you store user id and purchase record in Firebase
- use simple login auth as normal
- add a security rule to ensure user has purchased the app
The security rule would look something like this:
".read": "root.child('purchase_receipts/'+auth.uid).exists()"
Additional reading: