-
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 #43846 from michalvavrik/feature/permissions-allow…
…ed-user-exp-improvements Add annotation to allow using custom CDI bean methods as permission checkers
- Loading branch information
Showing
54 changed files
with
3,077 additions
and
268 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
29 changes: 29 additions & 0 deletions
29
...st/java/io/quarkus/resteasy/reactive/server/test/security/BeanParamPermissionChecker.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,29 @@ | ||
package io.quarkus.resteasy.reactive.server.test.security; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
|
||
import io.quarkus.security.PermissionChecker; | ||
|
||
@RequestScoped | ||
public class BeanParamPermissionChecker { | ||
|
||
@PermissionChecker("say-hello") | ||
boolean canSayHello(String customAuthorizationHeader, String name, String query) { | ||
boolean queryParamAllowedForPermissionName = checkQueryParams(query); | ||
boolean usernameWhitelisted = isUserNameWhitelisted(name); | ||
boolean customAuthorizationMatches = checkCustomAuthorization(customAuthorizationHeader); | ||
return queryParamAllowedForPermissionName && usernameWhitelisted && customAuthorizationMatches; | ||
} | ||
|
||
static boolean checkCustomAuthorization(String customAuthorization) { | ||
return "customAuthorization".equals(customAuthorization); | ||
} | ||
|
||
static boolean isUserNameWhitelisted(String userName) { | ||
return "admin".equals(userName); | ||
} | ||
|
||
static boolean checkQueryParams(String queryParam) { | ||
return "myQueryParam".equals(queryParam); | ||
} | ||
} |
34 changes: 0 additions & 34 deletions
34
.../quarkus/resteasy/reactive/server/test/security/BeanParamPermissionIdentityAugmentor.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
60 changes: 0 additions & 60 deletions
60
...test/java/io/quarkus/resteasy/reactive/server/test/security/OtherBeanParamPermission.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.