feat: discord oauth provider, setup provider list route, add 'active' method, common type alias

This commit is contained in:
Ryan Walters
2025-09-17 09:23:31 -05:00
parent 8e23fb66a4
commit ac1417aabc
6 changed files with 244 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
use axum::{response::IntoResponse, response::Redirect};
use dashmap::DashMap;
use oauth2::{basic::BasicClient, AuthorizationCode, CsrfToken, PkceCodeChallenge, PkceCodeVerifier, Scope, TokenResponse};
use oauth2::{AuthorizationCode, CsrfToken, PkceCodeChallenge, PkceCodeVerifier, Scope, TokenResponse};
use serde::{Deserialize, Serialize};
use std::sync::atomic::{AtomicU32, Ordering};
@@ -13,10 +13,6 @@ use crate::{
errors::ErrorResponse,
};
// Private type alias for the OAuth2 BasicClient specialized type
type OAuthClient =
BasicClient<oauth2::EndpointSet, oauth2::EndpointNotSet, oauth2::EndpointNotSet, oauth2::EndpointNotSet, oauth2::EndpointSet>;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GitHubUser {
pub id: u64,
@@ -58,7 +54,7 @@ pub async fn fetch_github_user(
}
pub struct GitHubProvider {
pub client: OAuthClient,
pub client: super::OAuthClient,
pub http: reqwest::Client,
pkce: DashMap<String, PkceRecord>,
last_purge_at_secs: AtomicU32,
@@ -72,7 +68,7 @@ struct PkceRecord {
}
impl GitHubProvider {
pub fn new(client: OAuthClient, http: reqwest::Client) -> Arc<Self> {
pub fn new(client: super::OAuthClient, http: reqwest::Client) -> Arc<Self> {
Arc::new(Self {
client,
http,