-
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.
Update OIDC GitHub docs and update the test
- Loading branch information
1 parent
394bf2b
commit 2dfd477
Showing
4 changed files
with
147 additions
and
12 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
37 changes: 37 additions & 0 deletions
37
...s/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/CustomSecurityIdentityAugmentor.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,37 @@ | ||
package io.quarkus.it.keycloak; | ||
|
||
import java.security.Principal; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
|
||
import io.quarkus.oidc.UserInfo; | ||
import io.quarkus.security.identity.AuthenticationRequestContext; | ||
import io.quarkus.security.identity.SecurityIdentity; | ||
import io.quarkus.security.identity.SecurityIdentityAugmentor; | ||
import io.quarkus.security.runtime.QuarkusSecurityIdentity; | ||
import io.smallrye.mutiny.Uni; | ||
import io.vertx.ext.web.RoutingContext; | ||
|
||
@ApplicationScoped | ||
public class CustomSecurityIdentityAugmentor implements SecurityIdentityAugmentor { | ||
|
||
@Override | ||
public Uni<SecurityIdentity> augment(SecurityIdentity identity, AuthenticationRequestContext context) { | ||
RoutingContext routingContext = identity.getAttribute(RoutingContext.class.getName()); | ||
if (routingContext != null && routingContext.normalizedPath().endsWith("code-flow-user-info")) { | ||
QuarkusSecurityIdentity.Builder builder = QuarkusSecurityIdentity.builder(identity); | ||
UserInfo userInfo = identity.getAttribute("userinfo"); | ||
builder.setPrincipal(new Principal() { | ||
|
||
@Override | ||
public String getName() { | ||
return userInfo.getString("preferred_username"); | ||
} | ||
|
||
}); | ||
identity = builder.build(); | ||
} | ||
return Uni.createFrom().item(identity); | ||
} | ||
|
||
} |
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