forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
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 quarkusio#26457 from michalvavrik/feature/fix-secu…
…rityconstrainer-blocking-op-exception Resolve Sec. Identity in RESTEasy Reactive when Proactive Auth disabled
- Loading branch information
Showing
8 changed files
with
97 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,13 @@ | |
|
||
import javax.annotation.security.PermitAll; | ||
import javax.annotation.security.RolesAllowed; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
import io.quarkus.security.identity.CurrentIdentityAssociation; | ||
import io.smallrye.common.annotation.Blocking; | ||
import io.smallrye.common.annotation.NonBlocking; | ||
|
||
/** | ||
* @author Michal Szynkiewicz, [email protected] | ||
|
@@ -14,6 +17,10 @@ | |
@PermitAll | ||
@Blocking | ||
public class RolesAllowedBlockingResource { | ||
|
||
@Inject | ||
CurrentIdentityAssociation currentIdentityAssociation; | ||
|
||
@GET | ||
@RolesAllowed({ "user", "admin" }) | ||
public String defaultSecurity() { | ||
|
@@ -27,4 +34,12 @@ public String admin() { | |
return "admin"; | ||
} | ||
|
||
@NonBlocking | ||
@Path("/admin/security-identity") | ||
@RolesAllowed("admin") | ||
@GET | ||
public String getSecurityIdentity() { | ||
return currentIdentityAssociation.getIdentity().getPrincipal().getName(); | ||
} | ||
|
||
} |
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 |
---|---|---|
|
@@ -2,15 +2,23 @@ | |
|
||
import javax.annotation.security.PermitAll; | ||
import javax.annotation.security.RolesAllowed; | ||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
|
||
import io.quarkus.security.identity.CurrentIdentityAssociation; | ||
import io.smallrye.common.annotation.NonBlocking; | ||
|
||
/** | ||
* @author Michal Szynkiewicz, [email protected] | ||
*/ | ||
@Path("/roles") | ||
@PermitAll | ||
public class RolesAllowedResource { | ||
|
||
@Inject | ||
CurrentIdentityAssociation currentIdentityAssociation; | ||
|
||
@GET | ||
@RolesAllowed({ "user", "admin" }) | ||
public String defaultSecurity() { | ||
|
@@ -24,4 +32,12 @@ public String admin() { | |
return "admin"; | ||
} | ||
|
||
@NonBlocking | ||
@Path("/admin/security-identity") | ||
@RolesAllowed("admin") | ||
@GET | ||
public String getSecurityIdentity() { | ||
return currentIdentityAssociation.getIdentity().getPrincipal().getName(); | ||
} | ||
|
||
} |
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