mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-15 22:12:25 -06:00
feat: setup github provider with generic trait, proper routes, session & jwt handling, errors & user agent
This commit is contained in:
25
pacman-server/src/auth/provider.rs
Normal file
25
pacman-server/src/auth/provider.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use async_trait::async_trait;
|
||||
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>,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait OAuthProvider: Send + Sync {
|
||||
fn id(&self) -> &'static str;
|
||||
fn label(&self) -> &'static str;
|
||||
|
||||
async fn authorize(&self) -> axum::response::Response;
|
||||
|
||||
async fn handle_callback(&self, query: &HashMap<String, String>) -> Result<AuthUser, ErrorResponse>;
|
||||
}
|
||||
Reference in New Issue
Block a user