Skip to content

Commit

Permalink
Distinguish between Oidc and OidcClient configuration exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
sberyozkin committed Mar 11, 2021
1 parent bdaa7f3 commit 93d6818
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected static Uni<OidcClient> createOidcClientUni(OidcClientConfig oidcConfig
oidcConfig.setId(oidcClientId);
}

OidcCommonUtils.verifyCommonConfiguration(oidcConfig);
OidcCommonUtils.verifyCommonConfiguration(oidcConfig, false);

String authServerUriString = OidcCommonUtils.getAuthServerUrl(oidcConfig);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,24 @@ private OidcCommonUtils() {

}

public static void verifyCommonConfiguration(OidcCommonConfig oidcConfig) {
public static void verifyCommonConfiguration(OidcCommonConfig oidcConfig, boolean isServerConfig) {
final String configPrefix = isServerConfig ? "quarkus.oidc." : "quarkus.oidc-client.";
if (!oidcConfig.getAuthServerUrl().isPresent() || !oidcConfig.getClientId().isPresent()) {
throw new ConfigurationException("Both 'auth-server-url' and 'client-id' properties must be configured");
throw new ConfigurationException(
String.format("Both '%sauth-server-url' and '%sclient-id' properties must be configured", configPrefix));
}

Credentials creds = oidcConfig.getCredentials();
if (creds.secret.isPresent() && creds.clientSecret.value.isPresent()) {
throw new ConfigurationException(
"'credentials.secret' and 'credentials.client-secret' properties are mutually exclusive");
String.format("'%scredentials.secret' and '%scredentials.client-secret' properties are mutually exclusive",
configPrefix));
}
if ((creds.secret.isPresent() || creds.clientSecret.value.isPresent()) && creds.jwt.secret.isPresent()) {
throw new ConfigurationException(
"Use only 'credentials.secret' or 'credentials.client-secret' or 'credentials.jwt.secret' property");
String.format(
"Use only '%scredentials.secret' or '%scredentials.client-secret' or '%scredentials.jwt.secret' property",
configPrefix));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private Uni<TenantConfigContext> createTenantContext(Vertx vertx, OidcTenantConf
return Uni.createFrom().item(createTenantContextFromPublicKey(oidcConfig));
}

OidcCommonUtils.verifyCommonConfiguration(oidcConfig);
OidcCommonUtils.verifyCommonConfiguration(oidcConfig, true);

if (!oidcConfig.discoveryEnabled) {
if (oidcConfig.applicationType != ApplicationType.SERVICE) {
Expand Down Expand Up @@ -213,8 +213,6 @@ public OidcProvider apply(JsonWebKeyCache jwks) {
protected static Uni<OidcProviderClient> createOidcClientUni(OidcTenantConfig oidcConfig,
TlsConfig tlsConfig, Vertx vertx) {

OidcCommonUtils.verifyCommonConfiguration(oidcConfig);

String authServerUriString = OidcCommonUtils.getAuthServerUrl(oidcConfig);

WebClientOptions options = new WebClientOptions();
Expand Down

0 comments on commit 93d6818

Please sign in to comment.