Merge branch 'token_model' into 'main'

Added token model

See merge request kdeng00/icarus-models!13
This commit is contained in:
KD
2025-03-09 21:43:23 +00:00
3 changed files with 42 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
name = "icarus-models"
description = "models used for the icarus project"
license = "MIT"
version = "0.1.0"
version = "0.1.1"
edition = "2024"
[dependencies]

View File

@@ -1,5 +1,6 @@
pub mod access_level;
pub mod login_result;
pub mod token;
pub mod user;
pub fn add(left: u64, right: u64) -> u64 {

40
src/token.rs Normal file
View File

@@ -0,0 +1,40 @@
use std::default::Default;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Token {
pub scope: String,
pub expiration: i32,
pub audience: String,
pub issuer: String,
pub issued: i32,
}
impl Default for Token {
fn default() -> Self {
Token {
scope: String::new(),
expiration: -1,
audience: String::new(),
issuer: String::new(),
issued: -1,
}
}
}
impl Token {
pub fn _to_json(&self) -> Result<String, serde_json::Error> {
return serde_json::to_string_pretty(&self);
}
// TODO: Implement
pub fn token_expired(&self) -> bool {
return false;
}
// TODO: Implement
pub fn contains_scope(&self, des_scope: String) -> bool {
return false;
}
}