-
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.
Support for combining OIDC with other auth mechanisms
- Loading branch information
1 parent
948d8a3
commit c5e1538
Showing
8 changed files
with
56 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
package io.quarkus.it.keycloak; | ||
|
||
import java.security.Principal; | ||
|
||
import javax.annotation.security.RolesAllowed; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
|
@@ -11,29 +9,31 @@ | |
|
||
import org.eclipse.microprofile.jwt.JsonWebToken; | ||
|
||
import io.quarkus.security.identity.SecurityIdentity; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Pedro Igor</a> | ||
*/ | ||
@Path("/api/users") | ||
public class UsersResource { | ||
|
||
@Inject | ||
Principal identity; | ||
SecurityIdentity identity; | ||
|
||
@GET | ||
@Path("/me") | ||
@RolesAllowed("user") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public User principalName() { | ||
return new User(identity.getName()); | ||
return new User(identity.getPrincipal().getName()); | ||
} | ||
|
||
@GET | ||
@Path("/preferredUserName") | ||
@RolesAllowed("user") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public User preferredUserName() { | ||
return new User(((JsonWebToken) identity).getClaim("preferred_username")); | ||
return new User(((JsonWebToken) identity.getPrincipal()).getClaim("preferred_username")); | ||
} | ||
|
||
public static class User { | ||
|
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