I have a simple cryptocurrency app that uses an API to fetch prices. I am using Firestore to store my API key and my app retrieves my API key from Firestore when launched. My API key is the only data I have in my Firestore. Since my app doesn't allow users to create profiles/accounts, I don't include user authentication in my rules. My security rules for Firestore are:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /Data/{Data} {
allow read: if true;
}
}
}
Are there better security rules to improve security or are these rules good enough?
EDIT
The file 'url-builder.dart' below is how I am retrieving my API key from Firestore. I then slot my API key into my URL at the end.
import 'package:cloud_firestore/cloud_firestore.dart';
class URLBuilder {
URLBuilder(this.cryptoCurrency, this.currency, this.periodValue);
String cryptoCurrency;
String currency;
String periodValue;
String _pricesAndTimesURL;
String get pricesAndTimesURL => _pricesAndTimesURL;
Future<String> getApiKey() async {
return FirebaseFirestore.instance
.collection("Data")
.doc("APIKeyDocument")
.get()
.then((value) {
return value.data()["Key"];
});
}
Future<void> buildURL() async {
String apiKey = await getApiKey();
_pricesAndTimesURL =
'https:$urlStart/markets/kraken/$cryptoCurrency$currency/ohlc?periods=$periodValue&apikey=$apiKey';
}
}