rustbasic-passport 0.1.1

OAuth2 server and personal access tokens for Rust applications, a port of laravel/passport for the RustBasic ecosystem.
Documentation
use serde::{Deserialize, Serialize};

pub type UserId = String;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Client {
    pub id: String,
    pub owner_type: Option<String>,
    pub owner_id: Option<String>,
    pub name: String,
    pub secret: Option<String>,
    pub provider: Option<String>,
    pub redirect_uris: Vec<String>,
    pub grant_types: Vec<String>,
    pub revoked: bool,
}

impl Client {
    pub fn has_grant_type(&self, grant_type: &str) -> bool {
        self.grant_types.iter().any(|g| g == grant_type)
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AccessToken {
    pub id: String,
    pub user_id: Option<UserId>,
    pub client_id: String,
    pub name: Option<String>,
    pub scopes: Vec<String>,
    pub revoked: bool,
    pub expires_at: i64,
    pub created_at: i64,
    pub updated_at: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuthCode {
    pub id: String,
    pub user_id: Option<UserId>,
    pub client_id: String,
    pub scopes: Vec<String>,
    pub revoked: bool,
    pub expires_at: i64,
    pub redirect_uri: String,
    pub code_challenge: Option<String>,
    pub code_challenge_method: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RefreshToken {
    pub id: String,
    pub client_id: String,
    pub access_token_id: String,
    pub revoked: bool,
    pub expires_at: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeviceCode {
    pub id: String,
    pub user_id: Option<UserId>,
    pub client_id: String,
    pub user_code: String,
    pub scopes: Vec<String>,
    pub revoked: bool,
    pub user_approved_at: Option<i64>,
    pub last_polled_at: Option<i64>,
    pub expires_at: i64,
}

#[derive(Debug, Clone)]
pub struct PersonalAccessTokenResult {
    pub access_token: String,
    pub token: AccessToken,
}