Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply minor polish to OidcAuthenticationMechanism #22763

Merged
merged 1 commit into from
Jan 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import java.util.Set;
import java.util.function.Function;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;

import io.quarkus.oidc.OIDCException;
import io.quarkus.oidc.OidcTenantConfig;
Expand All @@ -24,23 +22,22 @@
@ApplicationScoped
public class OidcAuthenticationMechanism implements HttpAuthenticationMechanism {

@Inject
DefaultTenantConfigResolver resolver;
private final BearerAuthenticationMechanism bearerAuth = new BearerAuthenticationMechanism();
private final CodeAuthenticationMechanism codeAuth = new CodeAuthenticationMechanism();

private BearerAuthenticationMechanism bearerAuth = new BearerAuthenticationMechanism();
private CodeAuthenticationMechanism codeAuth = new CodeAuthenticationMechanism();
private final DefaultTenantConfigResolver resolver;

@PostConstruct
public void init() {
bearerAuth.setResolver(resolver);
codeAuth.setResolver(resolver);
public OidcAuthenticationMechanism(DefaultTenantConfigResolver resolver) {
this.resolver = resolver;
this.bearerAuth.setResolver(resolver);
this.codeAuth.setResolver(resolver);
}

@Override
public Uni<SecurityIdentity> authenticate(RoutingContext context,
IdentityProviderManager identityProviderManager) {
setTenantIdAttribute(context);
return resolve(context).chain(new Function<OidcTenantConfig, Uni<? extends SecurityIdentity>>() {
return resolve(context).chain(new Function<>() {
@Override
public Uni<? extends SecurityIdentity> apply(OidcTenantConfig oidcConfig) {
if (!oidcConfig.tenantEnabled) {
Expand All @@ -55,7 +52,7 @@ public Uni<? extends SecurityIdentity> apply(OidcTenantConfig oidcConfig) {
@Override
public Uni<ChallengeData> getChallenge(RoutingContext context) {
setTenantIdAttribute(context);
return resolve(context).chain(new Function<OidcTenantConfig, Uni<? extends ChallengeData>>() {
return resolve(context).chain(new Function<>() {
@Override
public Uni<? extends ChallengeData> apply(OidcTenantConfig oidcTenantConfig) {
if (!oidcTenantConfig.tenantEnabled) {
Expand All @@ -68,7 +65,7 @@ public Uni<? extends ChallengeData> apply(OidcTenantConfig oidcTenantConfig) {
}

private Uni<OidcTenantConfig> resolve(RoutingContext context) {
return resolver.resolveConfig(context).map(new Function<OidcTenantConfig, OidcTenantConfig>() {
return resolver.resolveConfig(context).map(new Function<>() {
@Override
public OidcTenantConfig apply(OidcTenantConfig oidcTenantConfig) {
if (oidcTenantConfig == null) {
Expand Down