Crates.io | bevy-firebase-auth |
lib.rs | bevy-firebase-auth |
version | 0.1.0 |
source | src |
created_at | 2023-09-06 07:53:35.109144 |
updated_at | 2023-09-06 07:53:35.109144 |
description | firebase auth for the bevy game engine |
homepage | https://bytemunch.dev/projects/bevy-firebase |
repository | https://github.com/bytemunch/bevy-firebase |
max_upload_size | |
id | 965069 |
size | 41,638 |
Google Firebase Auth integration for Bevy.
Currently only implements Google + GitHub OAuth2. Will support all Firebase auth methods in future.
This is very very not battle-tested, and you will be trusting the plugin with API keys that can be used to rack up some bills and access your data if you're not careful.
Your keys will either be embedded in the distributed binary, or provided as separate files, but no matter which they will need to be essentially public. Ensure your GCP is prepared for this.
cargo add bevy-firebase-auth
Requires bevy-tokio-tasks
for the tonic crate to work. Removing dependencies is a TODO, I just don't know Rust well enough yet.
Targets Bevy 0.11.0
Create a Firebase project and note your ProjectID and client ID and Secret.
Place the client keys in a keys.ron
in the root of your project, and add keys.ron
to your .gitignore
.
The keys.ron
should be formatted as so:
{
Github: Some(("YOUR-GITHUB-CLIENT-ID","YOUR-GITHUB-CLIENT-SECRET")),
Google: Some(("YOUR-GOOGLE-CLIENT-ID-STRING.apps.googleusercontent.com","YOUR-GOOGLE-CLIENT-SECRET"))
}
This structure will change, likely in the next release, so I'd advise against writing any tooling around it.
App::new()
// PLUGINS
.add_plugins(DefaultPlugins)
// Dependency for firestore RPC to work
.add_plugins(bevy_tokio_tasks::TokioTasksPlugin::default())
.add_plugins(bevy_firebase_auth::AuthPlugin::default());
Google likes to put the required keys all over the place, with a couple of steps to set a project up. Here's a little walkthrough to get a hold of everything needed to use the plugins.
Go to this link and create a project.
Once you have created a project, go to Project Settings (In the Settings cog on the Firebase project console) and take note of the Project ID and Web API Key.
We need to create an identifier to authenticate the app with Google's backend. Go here, select your project in the top left dropdown and create a new OAuth2 credential. Name it something recognisable, and make note of the Client ID and Client Secret once it is generated.
NOTE: I have only tested with Desktop clients.
If demand exists I'll add instruction for GitHub and other login methods as they become available, create an issue on github :)
Apache 2.0 or MIT at user's discretion.