googleapis / googleapis/google-cloud-ruby

Authenticating with owner privileges in firebase emulator

Open
#18,087 2 comments 0 reactions 0 assignees View on GitHub
api: firestore priority: p3 type: docs
Dominant language
Ruby
Stars
1.4k
Forks
578
Avg merge
1d 11h
Merged PRs (30d)
166

Description

Hello 👋🏼,

we are currently looking into writing specs against the firestore rules and ruby based gcloud functions (that will work together with firestore).
For that we are using the https://firebase.google.com/docs/functions/local-emulator, so we do not actually interfere with production data.

We are currently instantiating the firestore client likes this:
```ruby
@client ||= Google::Cloud::Firestore.new(
project_id: ENV['FIREBASE_PROJECT'],
emulator_host: ENV['FIRESTORE_EMULATOR_HOST']
)
```

When we now use this client to create data before running a test, we correctly receive a `Google::Cloud::PermissionDeniedError`, as the firestore.rules explicitly prohibit anyone without `admin` or `owner` role to write data.

We now would like the firestore client to act as a admin or owner, but besides actually using a real service account (that also has access to the production data), we couldn't find any other solution using `Google::Cloud::Firestore`.

The node library appears to accept custom headers:
```js
const firestore = new Firestore({
projectId: 'firestore-emulator-sample',
servicePath: 'localhost',
port: 8080,
sslCreds: grpc.credentials.createInsecure(),
customHeaders: {
"Authorization": "Bearer owner"
}
});
```
See: https://github.com/firebase/firebase-tools/issues/1363#issuecomment-498364771

But unfortunately not the ruby library.

Now we could use the HTTP API directly, where we can supply the bearer token, to write data, but it would be nicer to use the library.

Is there any officially supported way that to access firestore running in an emulator with admin/ owner privileges, without using a real service account?

Thanks for you time and have a nice day.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.