-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29715 from michalvavrik/feature/oidc-service-app-…
…user-info-token-verification Allow token verification with user info when no introspection endpoint is available
- Loading branch information
Showing
12 changed files
with
256 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...src/test/java/io/quarkus/oidc/test/OpaqueTokenVerificationWithUserInfoValidationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package io.quarkus.oidc.test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.runtime.configuration.ConfigurationException; | ||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class OpaqueTokenVerificationWithUserInfoValidationTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest test = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addAsResource(new StringAsset("quarkus.oidc.token.verify-access-token-with-user-info=true\n"), | ||
"application.properties")) | ||
.assertException(t -> { | ||
Throwable e = t; | ||
ConfigurationException te = null; | ||
while (e != null) { | ||
if (e instanceof ConfigurationException) { | ||
te = (ConfigurationException) e; | ||
break; | ||
} | ||
e = e.getCause(); | ||
} | ||
assertNotNull(te); | ||
// assert UserInfo is required | ||
assertTrue( | ||
te.getMessage() | ||
.contains("UserInfo is not required but 'verifyAccessTokenWithUserInfo' is enabled"), | ||
te.getMessage()); | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
Assertions.fail(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...ration-tests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/OpaqueGithubResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.quarkus.it.keycloak; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
import io.quarkus.oidc.AccessTokenCredential; | ||
import io.quarkus.oidc.UserInfo; | ||
import io.quarkus.security.Authenticated; | ||
import io.quarkus.security.identity.SecurityIdentity; | ||
|
||
@Authenticated | ||
@Path("/bearer-user-info-github-service") | ||
public class OpaqueGithubResource { | ||
|
||
@Inject | ||
UserInfo userInfo; | ||
|
||
@Inject | ||
SecurityIdentity identity; | ||
|
||
@Inject | ||
AccessTokenCredential accessTokenCredential; | ||
|
||
@GET | ||
public String access() { | ||
return String.format("%s:%s:%s", identity.getPrincipal().getName(), userInfo.getString("preferred_username"), | ||
accessTokenCredential.getToken()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.