mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Implement federated login; #123
This commit is contained in:
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user