Struct actix_jwt_session::RefreshToken
source · pub struct RefreshToken {
pub issues_at: OffsetDateTime,
pub access_ttl: JwtTtl,
pub refresh_jti: Uuid,
pub refresh_ttl: RefreshTtl,
pub expiration_time: u64,
pub not_before: u64,
pub audience: String,
pub issuer: String,
/* private fields */
}
Expand description
Internal claims which allows to extend tokens pair livetime
After encoding it can be used as HTTP token send to endpoint, decoded and extend pair livetime. It’s always created while calling SessionStorage::store. If there’s any extractor for refresh you can use this structure as guard for an endpoint.
Example:
use actix_web::{get, HttpResponse};
use actix_web::web::Data;
use actix_jwt_session::*;
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
pub struct AppClaims { id: uuid::Uuid, sub: String }
impl actix_jwt_session::Claims for AppClaims {
fn jti(&self) -> uuid::Uuid { self.id }
fn subject(&self) -> &str { &self.sub }
}
#[get("/session/refresh")]
async fn refresh_session(
auth: Authenticated<RefreshToken>,
storage: Data<SessionStorage>,
) -> HttpResponse {
let storage = storage.into_inner();
storage.refresh::<AppClaims>(auth.refresh_jti).await.unwrap();
HttpResponse::Ok().json(&*auth)
}
Fields§
§issues_at: OffsetDateTime
date and time when token was created
access_ttl: JwtTtl
JWT lifetime
refresh_jti: Uuid
this token unique identifier
refresh_ttl: RefreshTtl
this token lifetime
expiration_time: u64
this token lifetime as integer (this field is required by standard)
not_before: u64
time before which token is not validate
(this field is required by standard and always set 0
)
audience: String
target audience (this field is required by standard) who created this token (this field is required by standard)
issuer: String
Implementations§
source§impl RefreshToken
impl RefreshToken
pub fn is_access_valid(&self) -> bool
pub fn is_refresh_valid(&self) -> bool
pub fn access_jti(&self) -> Uuid
Trait Implementations§
source§impl Claims for RefreshToken
impl Claims for RefreshToken
source§impl Clone for RefreshToken
impl Clone for RefreshToken
source§fn clone(&self) -> RefreshToken
fn clone(&self) -> RefreshToken
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RefreshToken
impl Debug for RefreshToken
source§impl<'de> Deserialize<'de> for RefreshToken
impl<'de> Deserialize<'de> for RefreshToken
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl PartialEq for RefreshToken
impl PartialEq for RefreshToken
Auto Trait Implementations§
impl RefUnwindSafe for RefreshToken
impl Send for RefreshToken
impl Sync for RefreshToken
impl Unpin for RefreshToken
impl UnwindSafe for RefreshToken
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more