[Account] Add wildcard security key to authorize all possible values#159
[Account] Add wildcard security key to authorize all possible values#159
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces support for a special security key value (SECURITY_KEY_ALL_VALUES = "*") that represents "all values" in authorization rules, enabling rules that are always true or always false regardless of field values. This is useful for granting or denying universal access in security contexts.
Key changes:
- Added
SECURITY_KEY_ALL_VALUESconstant toUserAuthorizationsclass - Updated SQL, Search, and Criteria translators to handle the special "*" value by generating always-true (
1=1or*:*) or always-false (0=1or-*:*) expressions - Added test coverage for the new functionality with three test cases validating different scenarios
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| UserAuthorizations.java | Introduced SECURITY_KEY_ALL_VALUES constant and improved JavaDoc formatting |
| SqlSecurityRuleTranslator.java | Added logic to translate "*" value to SQL 1=1/0=1 expressions and fixed field name positioning |
| SearchSecurityRuleTranslator.java | Added logic to translate "*" value to search query *:* expressions |
| CriteriaSecurityRuleTranslator.java | Added logic to translate "*" value to alwaysTrue()/alwaysFalse() criteria |
| DslSecurityRulesBuilderTest.java | Added test cases for the new "*" value functionality and minor code formatting cleanup |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @author pchretien, npiedeloup | ||
| */ | ||
| public final class UserAuthorizations implements Serializable { | ||
|
|
There was a problem hiding this comment.
The constant SECURITY_KEY_ALL_VALUES lacks documentation explaining its purpose and usage. Consider adding a JavaDoc comment to clarify that this special value represents "all values" in security rules and is used to create always-true or always-false authorization conditions.
| /** | |
| * Special value representing "all values" in security rules. | |
| * This constant can be used to create always-true or always-false authorization conditions, | |
| * by matching all possible security keys. | |
| */ |
ca5abda to
ad0f434
Compare
You should use constant `UserAuthorizations.SECURITY_KEY_ALL_VALUES` for this usage.
ad0f434 to
d9eb36a
Compare
You should use constant
UserAuthorizations.SECURITY_KEY_ALL_VALUESfor this usage.