firemage is a CLI tool to manage Firebase Auth Claims, written in Golang
The project uses task
to make your life easier. If you're not familiar with Taskfiles you can take a look at this quickstart guide.
Let's assume you have a
- Firebase project where you're managing users in Firebase Auth.
- You need special permissions, eg.
admin
,writer
,editor
,consultant
, etc. - You're using Firestore
- If you're storing user data in Firestore, you can search by user properties.
- A list of all users with special permissions is saved as a cache. Otherwise you'd have to iterate all Firebase Auth users every time.
- Search users by name or email address (if you have those in your Firestore), and change their permissions.
- List all privileged users from the Firestore cache, and change their permissions.
- Save your changes to Firebase Auth and the Firestore cache.
- In case your Firestore cache and Auth Claims get out of sync, you can refresh the cache.
- Install Go if you don't have it already.
- Run:
go get github.com/vendelin8/firemage
- Go to https://console.cloud.google.com/iam-admin/serviceaccounts?project=YOUR_PROJECT_ID to create a service account key, and download it somewhere inside
$GOPATH/src/github.com/vendelin8/firemage
folder. The default path isservice-account.json
, change it inTaskfile
if you want it otherwise. - Fill in
custom/custom.go
with your details. - The default is English (
LANG
=en
). If you want to change it to your language, and you can find it ini18n
folder, call:
task setlang <LANG>
You can overwrite the defaults by editing conf.yaml
. It's localized with task setlang
, see above. You can define more shortcuts to functions as well.
You can print help with
task help
If you have Taskfile, you can call it with:
task debug
To add arguments here, do like task debug -- -v
.
Otherwise with go run .
or similar with your own args. Or from any path with something like go run github.com/vendelin8/firemage
.
To print debug info to log.txt
add -v
.
To use it with a configured FIrebase emulator add -e
.
You can compile with
task build
or cross compile to multiple platforms with task build-win
, task build-osx
or task build-lin
. It will output to build
folder. It compiles custom/custom.go
options and chosen language. You can ship with the compiled version to a teammate. Add service-account.json
in the same folder and optionally conf.yaml
to be able to configure keyboard shortcuts.
The first Refresh
call will create a collection misc
with a document specialUsers
. It will have all privileged users as uid
-> email
pairs as data. When you open the List
page in the app, it will download this list, and get the permissions from Firebase Auth claims. By removing permissions and calling Save
users may be removed from the cache list. By searching for email or name, adding permissions to other users and calling Save
, users may be added to the cache list.
Run linting
task lint
Run tests
task test
Feel free to raise an issue or create a PR, eg. translate the package to your own language.