From ea8beb985247aac4345ecefc8ec551f52f5f1a24 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Tue, 26 Nov 2019 04:20:43 -0500 Subject: allow multiple oauth configurations using the same auth type this should allow us to configure a separate oauth application for tt web than normal (since the redirect_url needs to be different) --- teleterm/src/server.rs | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'teleterm/src/server.rs') diff --git a/teleterm/src/server.rs b/teleterm/src/server.rs index 1f565a2..e36f3fc 100644 --- a/teleterm/src/server.rs +++ b/teleterm/src/server.rs @@ -309,7 +309,10 @@ pub struct Server< allowed_auth_types: std::collections::HashSet, oauth_configs: std::collections::HashMap< crate::protocol::AuthType, - crate::oauth::Config, + std::collections::HashMap< + crate::protocol::AuthClient, + crate::oauth::Config, + >, >, } @@ -324,7 +327,10 @@ impl >, oauth_configs: std::collections::HashMap< crate::protocol::AuthType, - crate::oauth::Config, + std::collections::HashMap< + crate::protocol::AuthClient, + crate::oauth::Config, + >, >, ) -> Self { Self { @@ -379,19 +385,28 @@ impl )); } oauth if oauth.is_oauth() => { - let config = self.oauth_configs.get(&ty).context( + let configs = self.oauth_configs.get(&ty).context( crate::error::AuthTypeMissingOauthConfig { ty }, )?; let (refresh, client) = match oauth { - crate::protocol::Auth::RecurseCenter { id } => ( - id.is_some(), - Box::new(crate::oauth::RecurseCenter::new( - config.clone(), - &id.clone().unwrap_or_else(|| { - format!("{}", uuid::Uuid::new_v4()) - }), - )), - ), + crate::protocol::Auth::RecurseCenter { + auth_client, + id, + .. + } => { + let config = configs.get(auth_client).context( + crate::error::AuthTypeMissingOauthConfig { ty }, + )?; + ( + id.is_some(), + Box::new(crate::oauth::RecurseCenter::new( + config.clone(), + &id.clone().unwrap_or_else(|| { + format!("{}", uuid::Uuid::new_v4()) + }), + )), + ) + } _ => unreachable!(), }; -- cgit v1.2.3-54-g00ecf