From 79758b2631f7fd49bcc9fc62e14c24645f59f870 Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 21:49:18 -0400 Subject: [PATCH 1/9] tsk-71: Simplify bearer_token() method --- src/token.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/token.rs b/src/token.rs index 5ade1d0..af23655 100644 --- a/src/token.rs +++ b/src/token.rs @@ -40,10 +40,9 @@ impl Default for Token { } impl AccessToken { + /// Get the token fit for Bearer authentication pub fn bearer_token(&self) -> String { - let mut token: String = String::from("Bearer "); - token += &self.token.clone(); - token + format!("Bearer {}", self.token) } } -- 2.43.0 From 6851fdfddea15d8252601ca1f6d84e29f1d68ea5 Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 21:49:38 -0400 Subject: [PATCH 2/9] tsk-71: Updated tag release triggering --- .gitea/workflows/tag_release.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitea/workflows/tag_release.yaml b/.gitea/workflows/tag_release.yaml index 717f9ac..d424e07 100644 --- a/.gitea/workflows/tag_release.yaml +++ b/.gitea/workflows/tag_release.yaml @@ -2,11 +2,9 @@ name: Release Tagging on: push: - branches: - - next-v0.8 - pull_request: branches: - main + - next-v0.8 jobs: release: -- 2.43.0 From 25d2e38133f70756aa21ab2116de45243b7b347c Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 21:56:24 -0400 Subject: [PATCH 3/9] tsk-71: Added methods for token expiration --- src/token.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/token.rs b/src/token.rs index af23655..c727eff 100644 --- a/src/token.rs +++ b/src/token.rs @@ -44,6 +44,12 @@ impl AccessToken { pub fn bearer_token(&self) -> String { format!("Bearer {}", self.token) } + + pub fn token_expired(&self) -> bool { + let current_time = time::OffsetDateTime::now_utc(); + let expired = time::OffsetDateTime::from_unix_timestamp(self.expiration).unwrap(); + current_time > expired + } } impl Token { @@ -51,9 +57,10 @@ impl Token { serde_json::to_string_pretty(&self) } - // TODO: Implement pub fn token_expired(&self) -> bool { - false + let current_time = time::OffsetDateTime::now_utc(); + let expired = time::OffsetDateTime::from_unix_timestamp(self.expiration).unwrap(); + current_time > expired } pub fn contains_scope(&self, des_scope: &String) -> bool { -- 2.43.0 From 194cd9e6227044b97527f6ddb99dfc18a0ba051b Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 22:02:32 -0400 Subject: [PATCH 4/9] tsk-71: Removed function --- src/token.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/token.rs b/src/token.rs index c727eff..5831a75 100644 --- a/src/token.rs +++ b/src/token.rs @@ -2,7 +2,7 @@ use std::default::Default; use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, Deserialize, Serialize)] +#[derive(Clone, Debug, Default, Deserialize, Serialize)] pub struct Token { pub scope: String, pub expiration: i64, @@ -27,18 +27,6 @@ pub struct AccessToken { pub message: String, } -impl Default for Token { - fn default() -> Self { - Token { - scope: String::new(), - expiration: -1, - audience: String::new(), - issuer: String::new(), - issued: -1, - } - } -} - impl AccessToken { /// Get the token fit for Bearer authentication pub fn bearer_token(&self) -> String { -- 2.43.0 From 7f4adbdb9d90486326c05c096abb6b8531cd19b9 Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 22:05:54 -0400 Subject: [PATCH 5/9] tsk-71: Added expiration check in LoginResult --- src/login_result.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/login_result.rs b/src/login_result.rs index 670be51..563fd9e 100644 --- a/src/login_result.rs +++ b/src/login_result.rs @@ -28,4 +28,10 @@ impl LoginResult { pub fn _to_json(&self) -> Result { serde_json::to_string_pretty(&self) } + + pub fn token_expired(&self) -> bool { + let current_time = time::OffsetDateTime::now_utc(); + let expired = time::OffsetDateTime::from_unix_timestamp(self.expiration).unwrap(); + current_time > expired + } } -- 2.43.0 From 380d28a86e7b21d0cac9e6e482a902eead0069ed Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 22:06:38 -0400 Subject: [PATCH 6/9] tsk-71: Removed default function --- src/login_result.rs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/login_result.rs b/src/login_result.rs index 563fd9e..e65be09 100644 --- a/src/login_result.rs +++ b/src/login_result.rs @@ -2,7 +2,7 @@ use std::default::Default; use serde::{Deserialize, Serialize}; -#[derive(Clone, Debug, Deserialize, Serialize, utoipa::ToSchema)] +#[derive(Clone, Debug, Default, Deserialize, Serialize, utoipa::ToSchema)] pub struct LoginResult { pub id: uuid::Uuid, pub username: String, @@ -12,17 +12,6 @@ pub struct LoginResult { pub expiration: i64, } -impl Default for LoginResult { - fn default() -> Self { - LoginResult { - id: uuid::Uuid::nil(), - username: String::new(), - token: String::new(), - token_type: String::new(), - expiration: -1, - } - } -} impl LoginResult { pub fn _to_json(&self) -> Result { -- 2.43.0 From 56205fc0d5aac571e013718c63d1632113c8576a Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 22:07:52 -0400 Subject: [PATCH 7/9] tsk-71: Removed underscore from method --- src/login_result.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/login_result.rs b/src/login_result.rs index e65be09..e329337 100644 --- a/src/login_result.rs +++ b/src/login_result.rs @@ -14,7 +14,7 @@ pub struct LoginResult { impl LoginResult { - pub fn _to_json(&self) -> Result { + pub fn to_json(&self) -> Result { serde_json::to_string_pretty(&self) } -- 2.43.0 From 2f36ba30f51e8915f48b19a36b91a5d8913d9029 Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 22:08:07 -0400 Subject: [PATCH 8/9] tsk-71: Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8cf848a..9a6f1c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,7 +149,7 @@ checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" [[package]] name = "icarus_models" -version = "0.7.2" +version = "0.7.3" dependencies = [ "josekit", "rand", diff --git a/Cargo.toml b/Cargo.toml index 54a405f..9a7974c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus_models" -version = "0.7.2" +version = "0.7.3" edition = "2024" rust-version = "1.90" description = "models used for the icarus project" -- 2.43.0 From 65017599a4b03e79dae5c709a6848c343143b73b Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 18 Oct 2025 22:12:08 -0400 Subject: [PATCH 9/9] tsk-71: Code formatting --- src/login_result.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/login_result.rs b/src/login_result.rs index e329337..ff03083 100644 --- a/src/login_result.rs +++ b/src/login_result.rs @@ -12,7 +12,6 @@ pub struct LoginResult { pub expiration: i64, } - impl LoginResult { pub fn to_json(&self) -> Result { serde_json::to_string_pretty(&self) -- 2.43.0