authnz-common 0.2.1

Authnz common library (types and utils).
Documentation
//! Logout module.

#[cfg(any(feature = "app-server-types", feature = "authnz-server-types"))]
use impulse_server_kit::salvo;
#[cfg(any(feature = "app-server-types", feature = "authnz-server-types"))]
use salvo::oapi::ToSchema;
use serde::{Deserialize, Serialize};

#[cfg_attr(any(feature = "app-server-types", feature = "authnz-server-types"), derive(ToSchema))]
#[derive(Deserialize, Serialize, PartialEq, Eq, Hash, Clone, Debug)]
/// Request to log out.
///
/// Note that logout revokes refresh token, but access token is still valid for at least 15 minutes by default (see `TokenLifetimes`).
/// Revoke can be made without even client token if it is compromised.
pub struct UserLogoutRequest {
  /// Access token (MPAAT).
  pub access_token: String,
  /// Refresh token (random bytes).
  pub refresh_token: String,
}

impl UserLogoutRequest {
  /// Creates new user logout request.
  pub fn new(act: impl ToString, rft: impl ToString) -> Self {
    Self {
      access_token: act.to_string(),
      refresh_token: rft.to_string(),
    }
  }
}