Merge branch 'token_model' into 'main'
Added token model See merge request kdeng00/icarus-models!13
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
name = "icarus-models"
|
name = "icarus-models"
|
||||||
description = "models used for the icarus project"
|
description = "models used for the icarus project"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
pub mod access_level;
|
pub mod access_level;
|
||||||
pub mod login_result;
|
pub mod login_result;
|
||||||
|
pub mod token;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
|
|
||||||
pub fn add(left: u64, right: u64) -> u64 {
|
pub fn add(left: u64, right: u64) -> u64 {
|
||||||
|
40
src/token.rs
Normal file
40
src/token.rs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user