Files
Pac-Man/pacman-server/src/auth/provider.rs

29 lines
661 B
Rust

use async_trait::async_trait;
use mockall::automock;
use serde::Serialize;
use crate::errors::ErrorResponse;
#[derive(Debug, Clone, Serialize)]
pub struct AuthUser {
pub id: String,
pub username: String,
pub name: Option<String>,
pub email: Option<String>,
pub avatar_url: Option<String>,
}
#[automock]
#[async_trait]
pub trait OAuthProvider: Send + Sync {
fn id(&self) -> &'static str;
fn label(&self) -> &'static str;
fn active(&self) -> bool {
true
}
async fn authorize(&self) -> axum::response::Response;
async fn handle_callback(&self, code: &str, state: &str) -> Result<AuthUser, ErrorResponse>;
}