Skip to content

Commit

Permalink
Issue 10343: Disabled default quarkus-oidc tenant blocks access to th…
Browse files Browse the repository at this point in the history
…e public resources
  • Loading branch information
Sgitario committed Jul 2, 2020
1 parent 9663f0c commit 5a58161
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
10 changes: 10 additions & 0 deletions extensions/oidc/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-codegen</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jackson</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public class OidcAuthenticationMechanism implements HttpAuthenticationMechanism
@Override
public Uni<SecurityIdentity> authenticate(RoutingContext context,
IdentityProviderManager identityProviderManager) {
return isWebApp(context) ? codeAuth.authenticate(context, identityProviderManager, resolver)
: bearerAuth.authenticate(context, identityProviderManager, resolver);
return Uni.createFrom().deferred(() -> isWebApp(context),
isWebApp -> isWebApp ? codeAuth.authenticate(context, identityProviderManager, resolver)
: bearerAuth.authenticate(context, identityProviderManager, resolver));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package io.quarkus.oidc.runtime;

import static org.mockito.Mockito.verifyNoInteractions;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import io.quarkus.security.identity.IdentityProviderManager;
import io.vertx.ext.web.RoutingContext;

public class OidcAuthenticationMechanismTest {

@Mock
private DefaultTenantConfigResolver resolver;

@Mock
private RoutingContext context;

@Mock
private IdentityProviderManager identityProviderManager;

@InjectMocks
private OidcAuthenticationMechanism mechanism = new OidcAuthenticationMechanism();

@BeforeEach
public void setUp() {
MockitoAnnotations.initMocks(this);
}

@Test
public void shouldNotCheckWebAppInSync() {
whenAuthenticate();
thenResolverIsNotCalled();
}

private void whenAuthenticate() {
mechanism.authenticate(context, identityProviderManager);
}

private void thenResolverIsNotCalled() {
verifyNoInteractions(resolver);
}
}

0 comments on commit 5a58161

Please sign in to comment.