Skip to content

Commit

Permalink
feat: bevy 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Jul 5, 2024
1 parent 84bab91 commit 5b7ba85
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 42 deletions.
20 changes: 0 additions & 20 deletions .github/workflows/release.yml

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe

## Unreleased

## 0.2.0

### Changed

- Updated to bevy 0.14

## 0.1.0

- Initial release. Crate was renamed to `bevy_key_rotation` from `bevy-key-rotation` and republished.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[package]
name = "bevy_key_rotation"
description = "Access and refresh token rotation for Bevy applications"
license = "MIT/Apache-2.0"
license = "Apache-2.0 OR MIT"
repository = "https://github.com/loopystudios/bevy_key_rotation"
authors = ["Spencer C. Imbleau"]
keywords = ["gamedev"]
version = "0.1.0"
version = "0.2.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
web-time = "1.1.0"
thiserror = "1.0.58"
bevy_async_task = "0.1.0"
thiserror = "1.0.61"
bevy_async_task = "0.2.0"
async-trait = "0.1.79"
bevy = { version = "0.13", default-features = false }
bevy = { version = "0.14", default-features = false, features = ["bevy_state"] }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
getrandom = { version = "0.2.12" }
getrandom = { version = "0.2.15" }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = "0.3.42"
getrandom = { version = "0.2.12", features = ["js"] }
getrandom = { version = "0.2.15", features = ["js"] }
13 changes: 5 additions & 8 deletions examples/error_handling.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use bevy::{
log::{self, LogPlugin},
prelude::*,
};
use bevy::{log::LogPlugin, prelude::*};
use bevy_key_rotation::{
AuthProvider, KeyRotationPlugin, KeyRotationSettings, Keystore, KeystoreState,
StartKeyRotationExt, TokenRotationError,
Expand Down Expand Up @@ -50,14 +47,14 @@ fn status_check(time: Res<Time>, mut update_every: Local<Option<Timer>>, keystor
}

if keystore.access_token_valid_for() < bevy_key_rotation::Duration::from_secs(5) {
log::warn!("The keystore is about to be non-conformant!");
warn!("The keystore is about to be non-conformant!");
// You could attempt to re-authenticate from scratch:
// commands.start_key_rotation(username, password);
// Or panic, or safe your system and prepare to exit, etc.
}

// Log current access token
log::info!(
info!(
token = keystore.access_token,
refresh_token = keystore.refresh_token,
"token valid for: {:.0?}, refresh token valid for: {:.0?}",
Expand Down Expand Up @@ -86,8 +83,8 @@ pub fn main() {
)
.add_systems(
OnTransition {
from: KeystoreState::Conformant,
to: KeystoreState::NonConformant,
exited: KeystoreState::Conformant,
entered: KeystoreState::NonConformant,
},
|| {
error!("Keystore is now non-conformant! Keys cannot be rotated.");
Expand Down
7 changes: 2 additions & 5 deletions examples/simple.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use bevy::{
log::{self, LogPlugin},
prelude::*,
};
use bevy::{log::LogPlugin, prelude::*};
use bevy_key_rotation::{
AuthProvider, KeyRotationPlugin, KeyRotationSettings, Keystore, StartKeyRotationExt,
TokenRotationError,
Expand Down Expand Up @@ -54,7 +51,7 @@ fn status_check(time: Res<Time>, mut update_every: Local<Option<Timer>>, keystor
}

// Log current access token
log::info!(
info!(
token = keystore.access_token,
refresh_token = keystore.refresh_token,
"token valid for: {:.0?}, refresh token valid for: {:.0?}",
Expand Down
2 changes: 1 addition & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{data_types::Keygen, KeyRotationEvent, Keystore, KeystoreState};
use bevy::{ecs::system::Command, prelude::*};
use bevy::{ecs::world::Command, prelude::*};
use bevy_async_task::AsyncTask;

struct StartKeyRotation {
Expand Down
5 changes: 4 additions & 1 deletion src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
data_types::{AuthProvider, KeyRotationSettings, Keygen, KeystoreState},
systems, KeyRotationEvent,
};
use bevy::prelude::*;
use bevy::{prelude::*, state::app::StatesPlugin};
use std::sync::Arc;

pub struct KeyRotationPlugin {
Expand All @@ -17,6 +17,9 @@ impl Plugin for KeyRotationPlugin {
"Invalid key rotation settings: rotation interval must be smaller than than time to rotate before expiration"
);

if !app.is_plugin_added::<StatesPlugin>() {
app.add_plugins(StatesPlugin);
}
app.insert_resource(self.rotation_settings.clone())
.insert_resource(Keygen(self.auth_provider.clone()))
.init_state::<KeystoreState>()
Expand Down

0 comments on commit 5b7ba85

Please sign in to comment.