• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Xevion / Pac-Man / 17862749257

19 Sep 2025 03:28PM UTC coverage: 66.315% (+0.4%) from 65.884%
17862749257

push

github

Xevion
ci: adjust timeouts for nextest given docker requirements

2514 of 3791 relevant lines covered (66.31%)

21873.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.06
/pacman-server/src/auth/mod.rs
1
use std::collections::HashMap;
2
use std::sync::Arc;
3

4
use oauth2::{basic::BasicClient, EndpointNotSet, EndpointSet};
5

6
use crate::config::Config;
7

8
pub mod discord;
9
pub mod github;
10
pub mod provider;
11

12
type OAuthClient =
13
    BasicClient<oauth2::EndpointSet, oauth2::EndpointNotSet, oauth2::EndpointNotSet, oauth2::EndpointNotSet, oauth2::EndpointSet>;
14

15
pub struct AuthRegistry {
16
    providers: HashMap<&'static str, Arc<dyn provider::OAuthProvider>>,
17
}
18

19
impl AuthRegistry {
20
    pub fn new(config: &Config) -> Result<Self, oauth2::url::ParseError> {
16✔
21
        let http = reqwest::ClientBuilder::new()
16✔
22
            .redirect(reqwest::redirect::Policy::none())
16✔
23
            .build()
16✔
24
            .expect("HTTP client should build");
16✔
25

26
        let github_client: BasicClient<EndpointSet, EndpointNotSet, EndpointNotSet, EndpointNotSet, EndpointSet> =
16✔
27
            BasicClient::new(oauth2::ClientId::new(config.github_client_id.clone()))
16✔
28
                .set_client_secret(oauth2::ClientSecret::new(config.github_client_secret.clone()))
16✔
29
                .set_auth_uri(oauth2::AuthUrl::new("https://github.com/login/oauth/authorize".to_string())?)
16✔
30
                .set_token_uri(oauth2::TokenUrl::new(
16✔
31
                    "https://github.com/login/oauth/access_token".to_string(),
16✔
32
                )?)
×
33
                .set_redirect_uri(
16✔
34
                    oauth2::RedirectUrl::new(format!("{}/auth/github/callback", config.public_base_url))
16✔
35
                        .expect("Invalid redirect URI"),
16✔
36
                );
37

38
        let mut providers: HashMap<&'static str, Arc<dyn provider::OAuthProvider>> = HashMap::new();
16✔
39
        providers.insert("github", github::GitHubProvider::new(github_client, http.clone()));
16✔
40

41
        // Discord OAuth client
42
        let discord_client: BasicClient<EndpointSet, EndpointNotSet, EndpointNotSet, EndpointNotSet, EndpointSet> =
16✔
43
            BasicClient::new(oauth2::ClientId::new(config.discord_client_id.clone()))
16✔
44
                .set_client_secret(oauth2::ClientSecret::new(config.discord_client_secret.clone()))
16✔
45
                .set_auth_uri(oauth2::AuthUrl::new("https://discord.com/api/oauth2/authorize".to_string())?)
16✔
46
                .set_token_uri(oauth2::TokenUrl::new("https://discord.com/api/oauth2/token".to_string())?)
16✔
47
                .set_redirect_uri(
16✔
48
                    oauth2::RedirectUrl::new(format!("{}/auth/discord/callback", config.public_base_url))
16✔
49
                        .expect("Invalid redirect URI"),
16✔
50
                );
51
        providers.insert("discord", discord::DiscordProvider::new(discord_client, http));
16✔
52

53
        Ok(Self { providers })
16✔
54
    }
16✔
55

56
    pub fn get(&self, id: &str) -> Option<&Arc<dyn provider::OAuthProvider>> {
4✔
57
        self.providers.get(id)
4✔
58
    }
4✔
59

60
    pub fn values(&self) -> impl Iterator<Item = &Arc<dyn provider::OAuthProvider>> {
1✔
61
        self.providers.values()
1✔
62
    }
1✔
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc