Implement federated login; #123

This commit is contained in:
NG (Graham) authored and NGnius committed 2026-07-05 20:38:17 +00:00
1 parent 6601c188d0
commit 2adf8249bb
35 files changed
+1466 -121

No files matched your search

+15 -2
View File
@@ -22,7 +22,7 @@ pub enum UserAuthInfo {
Email {
email: String,
password: String,
}
},
}
impl UserAuthInfo {
@@ -35,6 +35,12 @@ impl UserAuthInfo {
}
}
pub struct FederatedAuthInfo {
pub display_name: String,
pub password: String,
pub domain: String,
}
pub enum UserId {
SteamId(u64),
Email(String),
@@ -68,13 +74,20 @@ pub trait UserProvider<C> {
}
#[async_trait::async_trait]
pub trait UserAuthenticator {
pub trait UserAuthenticator: FederatedAuthenticator {
async fn login(&self, info: UserAuthInfo) -> Result<UserLoginInfo, AuthError>;
async fn user_exists(&self, user: UserId) -> Result<bool, String>;
async fn register(&self, info: RegistrationInfo) -> Result<i32, String>;
async fn verify(&self, token: String) -> Result<crate::auth::Token, AuthError>;
}
#[async_trait::async_trait]
pub trait FederatedAuthenticator {
async fn local_login(&self, info: FederatedAuthInfo) -> Result<UserLoginInfo, AuthError>;
async fn remote_auth(&self, info: &super::federation::FederatedAuthenticationPayload, challenge: &str) -> Result<String, AuthError>;
async fn remote_token(&self, access_token: &str, verifier: &str) -> Result<UserLoginInfo, AuthError>;
}
#[async_trait::async_trait]
pub trait User<C>: ChatUser + SocialUser + SocialUserC<C> + LobbyUser + MultiplayerUser + SingleplayerUser + IntercomUser + CommonUser + FactoryUser {
async fn unlocked_parts(&self) -> Vec<u32>;