SQL-85 Convert OIDC config into system params#34845
SQL-85 Convert OIDC config into system params#34845SangJunBak merged 4 commits intoMaterializeInc:mainfrom
Conversation
4f46b9b to
6013469
Compare
6013469 to
4effde6
Compare
72e4912 to
c06caf6
Compare
c06caf6 to
a477778
Compare
eef5a9e to
c589475
Compare
…nfig - Remove OIDC CLI args - Initialize oidc authenticator with adapter client to get access to system variables - Refactor tests to use system parameter default
- Tests the runtime nature of OIDC configuration
c589475 to
ed01884
Compare
teskje
left a comment
There was a problem hiding this comment.
Looks good, I just have one question/concern about the issuer default and how we behave when no issuer was set.
| use mz_frontegg_auth::Authenticator as FronteggAuthenticator; | ||
|
|
||
| pub use oidc::{GenericOidcAuthenticator, OidcClaims, OidcConfig, OidcError}; | ||
| pub use mz_adapter::Client as AdapterClient; |
There was a problem hiding this comment.
Does this need to be pub? I don't see it used anywhere.
| /// issued by a dummy application, but from the same identity provider. | ||
| pub const OIDC_AUDIENCE: Config<&'static str> = Config::new( | ||
| "oidc_audience", | ||
| "", |
There was a problem hiding this comment.
Is it possible to make this an Option, so we remember to handle the case where this wasn't set? Also for OIDC_ISSUER above.
There was a problem hiding this comment.
I think I chose to make it a &'static str because an Option didn't exist for Config, but I can create one!
| ) -> Result<OidcClaims, OidcError> { | ||
| // Fetch current OIDC configuration from system variables | ||
| let system_vars = self.adapter_client.get_system_vars().await; | ||
| let issuer = OIDC_ISSUER.get(system_vars.dyncfgs()); |
There was a problem hiding this comment.
Here we might get the empty string if this wasn't set before. Probably want to handle that specially to return a proper error?
There was a problem hiding this comment.
Can you also add a test for the behavior when trying to authenticate with OIDC without an issuer set?
There was a problem hiding this comment.
Added a test! Right now it just asserts on "Invalid Password" but I have a future PR that surfaces a more informative error
- Remove pub from AdapterClient - Add Option<String> as a possible dyncfg type
3c2a49c to
fac6923
Compare
| use mz_frontegg_auth::Authenticator as FronteggAuthenticator; | ||
|
|
||
| pub use mz_adapter::Client as AdapterClient; | ||
| use mz_adapter::Client as AdapterClient; |
There was a problem hiding this comment.
Nit: Mind putting this up to the non-pub block again?
| let issuer = if let Some(issuer) = OIDC_ISSUER.get(system_vars.dyncfgs()) { | ||
| issuer | ||
| } else { | ||
| return Err(OidcError::MissingIssuer); | ||
| }; |
There was a problem hiding this comment.
| let issuer = if let Some(issuer) = OIDC_ISSUER.get(system_vars.dyncfgs()) { | |
| issuer | |
| } else { | |
| return Err(OidcError::MissingIssuer); | |
| }; | |
| let Some(issuer) = OIDC_ISSUER.get(system_vars.dyncfgs()) else { | |
| return Err(OidcError::MissingIssuer); | |
| }; |
- Set constants as Option<String> and initializes as None - Adds test to validate that issuer exists
fac6923 to
54c8ab5
Compare
See commit messages
Start reviewing from Update OIDC tests to use system parameter defaults as config
Motivation
Tips for reviewer
Checklist
$T ⇔ Proto$Tmapping (possibly in a backwards-incompatible way), then it is tagged with aT-protolabel.