Repository navigation
Conversation
Cover the case where a logged-in user's principal name happens to collide with an unrelated configured role name, and the case where a role is configured as a fully-qualified "class:name" principal reference. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
isInAllowList is called on every guarded MBean operation and walks the allow list rules each time. Cache the result per ObjectName. The cache lives in JMXAccessControlList rather than in the guard so it sits next to the state it derives from and can be invalidated by the only mutator of that state, addToAllowList. Keeping it in the guard would leave it stale both when a new allow list entry is added and when setJMXAccessControlList swaps the whole list out. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Group a domain's access rules by the literal property name they apply to, so a lookup only evaluates the rules that can possibly match instead of walking every rule for every property of the ObjectName. Rules whose key is a plain literal go into an exact-match map. A key only counts as a literal when it holds no regex metacharacter at all: the key is otherwise compiled and evaluated as a regex against the whole "name=value" string, and bucketing must not quietly turn a metacharacter such as '.' into a literal. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A rule can only be bucketed under a literal property name when the part before the equal sign is itself a literal. Keys such as "*", "*=bar" or "ty.e=bar" may match more than one property name, so they go into the wildcard bucket and are tried against every property. The wildcard bucket is merged into each property bucket and re-sorted with the same comparator used elsewhere, so rules competing across buckets keep the longest-match-wins priority they have without bucketing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The bucketed domain cache was built on the first lookup and never invalidated, so a role access key added for a domain afterwards was silently ignored. Invalidate the domain's cache entry whenever a new key is added. Updates to existing keys mutate the cached Access objects in place and need no invalidation. Assisted-by: Claude Code Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
@jbertram thanks! I was checking the regex code and - like you said:
... there is the potential issue of I ran the JMH tests again on your branch just to make sure the numbers are still good. Same machine/same JVM as before. LGTM. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rather than continuing to go back and forth on #6403 I decided to make the modifications I think are necessary to get this merged and send my own PR. This is an exceptional circumstance because (to my knowledge) we've never had a PR with this many individual commits.
All commits retain @GChuf as author. I rebased onto current
mainand folded fixes into the commits that introduced each issue.Changes relative to #6403
JMXAccessControlListand invalidated fromaddToAllowList. In the guard it was stale both when an allow list entry was added after first use and whensetJMXAccessControlListswapped the whole list out. Invalidation isinvalidateAll()rather than per-domain becauseisInAllowListfalls back to the*domain, so a single new entry can change the answer for object names in every other domain.userRolesCache. Keyed onSubjectidentity, it snapshotted a mutableSubject, so principals added after the first authorization call were invisible for that subject's lifetime. It bought no measurable throughput gain, only a small gain for allocation.name=valuestring, so.,+,(,|and friends are live metacharacters. The bucketing split rules into exact matches vs regexes using an ad-hoc*/?/[test, which silently turned the rest into literals:key="address=foo.bar"stopped matchingaddress=fooXbar. A rule now only takes the exact-match path when its key contains no regex metacharacter at all.=is itself a literal. Otherwise it may match more than one property name and goes to the wildcard bucket. Without this,key="ty.e=bar"would be bucketed under the literal namety.eand never match anything.objectNameCacheis now an instance field rather thanstatic, so it no longer outlives the broker that created it.defaultRoleClasstoDEFAULT_ROLE_CLASS, and dropped the unusedAccessEntry.rawPatternrecord component.ArtemisMBeanServerGuard#currentUserHasRoleis removed. It waspublic staticbut had no callers oncecanInvokeandhandleInvokeboth moved to the set-based path.JMXAccessControlListTestandArtemisMBeanServerGuardTest.*domain and affects object names in another domain.,(a|b),+), and a purely literal key still matches exactly*in the key name portion still matches