Compare commits
4 Commits
v0.7.3-nex
...
194cd9e622
| Author | SHA1 | Date | |
|---|---|---|---|
|
194cd9e622
|
|||
|
25d2e38133
|
|||
|
6851fdfdde
|
|||
|
79758b2631
|
@@ -2,11 +2,9 @@ name: Release Tagging
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
|
||||||
- next-v0.8
|
|
||||||
pull_request:
|
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
- next-v0.8
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
|
|||||||
30
src/token.rs
30
src/token.rs
@@ -2,7 +2,7 @@ use std::default::Default;
|
|||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||||
pub struct Token {
|
pub struct Token {
|
||||||
pub scope: String,
|
pub scope: String,
|
||||||
pub expiration: i64,
|
pub expiration: i64,
|
||||||
@@ -27,23 +27,16 @@ pub struct AccessToken {
|
|||||||
pub message: String,
|
pub message: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Token {
|
impl AccessToken {
|
||||||
fn default() -> Self {
|
/// Get the token fit for Bearer authentication
|
||||||
Token {
|
pub fn bearer_token(&self) -> String {
|
||||||
scope: String::new(),
|
format!("Bearer {}", self.token)
|
||||||
expiration: -1,
|
|
||||||
audience: String::new(),
|
|
||||||
issuer: String::new(),
|
|
||||||
issued: -1,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AccessToken {
|
pub fn token_expired(&self) -> bool {
|
||||||
pub fn bearer_token(&self) -> String {
|
let current_time = time::OffsetDateTime::now_utc();
|
||||||
let mut token: String = String::from("Bearer ");
|
let expired = time::OffsetDateTime::from_unix_timestamp(self.expiration).unwrap();
|
||||||
token += &self.token.clone();
|
current_time > expired
|
||||||
token
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,9 +45,10 @@ impl Token {
|
|||||||
serde_json::to_string_pretty(&self)
|
serde_json::to_string_pretty(&self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement
|
|
||||||
pub fn token_expired(&self) -> bool {
|
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 {
|
pub fn contains_scope(&self, des_scope: &String) -> bool {
|
||||||
|
|||||||
Reference in New Issue
Block a user