-
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.
Detect Basic auth implicitly required and enable the mechanism
- Loading branch information
1 parent
b2c935b
commit 0b209bd
Showing
9 changed files
with
183 additions
and
67 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
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
28 changes: 0 additions & 28 deletions
28
...sts/oidc-code-flow/src/main/java/io/quarkus/it/keycloak/CustomBasicHttpAuthMechanism.java
This file was deleted.
Oops, something went wrong.
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
65 changes: 65 additions & 0 deletions
65
...s/oidc-code-flow/src/main/java/io/quarkus/it/keycloak/TestSecurityAnnotationResource.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,65 @@ | ||
package io.quarkus.it.keycloak; | ||
|
||
import java.security.Principal; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.SecurityContext; | ||
|
||
import org.eclipse.microprofile.jwt.JsonWebToken; | ||
|
||
import io.quarkus.oidc.IdToken; | ||
import io.quarkus.oidc.OidcConfigurationMetadata; | ||
import io.quarkus.oidc.UserInfo; | ||
import io.quarkus.security.Authenticated; | ||
import io.quarkus.security.identity.SecurityIdentity; | ||
import io.quarkus.security.runtime.SecurityIdentityAssociation; | ||
|
||
@Path("test-security-annotation") | ||
@Authenticated | ||
public class TestSecurityAnnotationResource { | ||
|
||
@Inject | ||
SecurityIdentity identity; | ||
|
||
@Inject | ||
SecurityIdentityAssociation securityIdentityAssociation; | ||
|
||
@Inject | ||
Principal principal; | ||
|
||
@Context | ||
SecurityContext securityContext; | ||
|
||
@Inject | ||
@IdToken | ||
JsonWebToken idToken; | ||
|
||
@Inject | ||
OidcConfigurationMetadata configMetadata; | ||
|
||
@Inject | ||
UserInfo userInfo; | ||
|
||
@GET | ||
@Path("test-security") | ||
public String testSecurity() { | ||
return securityContext.getUserPrincipal().getName() + ":" + identity.getPrincipal().getName() + ":" | ||
+ principal.getName() + ":" | ||
+ securityIdentityAssociation.getDeferredIdentity().await().indefinitely().getPrincipal().getName(); | ||
} | ||
|
||
@GET | ||
@Path("test-security-oidc") | ||
public String testSecurityJwt() { | ||
return idToken.getName() + ":" + identity.getPrincipal().getName() + ":" + principal.getName() | ||
+ ":" + securityIdentityAssociation.getDeferredIdentity().await().indefinitely().getPrincipal().getName() | ||
+ ":" + idToken.getGroups().iterator().next() | ||
+ ":" + idToken.getClaim("email") | ||
+ ":" + userInfo.getString("sub") | ||
+ ":" + configMetadata.get("audience"); | ||
} | ||
|
||
} |
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
Oops, something went wrong.