Repository navigation
Conversation
…a access are incorrectly overruled by other ACLs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment on lines
+98
to
+101
| catch (Exception ex) | ||
| { | ||
| logger.LogWarning("Could not access well-known from {Issuer}: {Reason}", LogSanitizer.Sanitize(issuer), LogSanitizer.Sanitize(ex.Message)); | ||
| } |
Comment on lines
+69
to
+74
| catch (Exception ex) | ||
| { | ||
| logger.LogWarning("Token rejected for issuer {Issuer} / kid {Kid}: {Reason}", | ||
| LogSanitizer.Sanitize(iss), LogSanitizer.Sanitize(kid), LogSanitizer.Sanitize(ex.Message)); | ||
| return false; | ||
| } |
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.
Title: Fix ACL merging (unconditional grants), add trust-list-based token validation
Summary
row-level conditions of the other ACLs. An unconditional grant now takes precedence.
kidheader are now accepted only from issuers/kids on the trustlist. The JWKS URL is taken from the trust list entry, never from the token. Issuer and audience are validated.
token:realm_accesscan now be used in access rules, so client-credentials tokens(no user name, no
roleMappingmatch) can be granted access via a realm role.Background
An empty SQL condition means "no restriction" (= TRUE). That makes it the neutral element for AND but the absorbing element
for OR.
SqlConditionsMerger.OrMergetreated it as neutral in both cases, so with two matching rulesA: FORMULA {"$boolean": true}andB: FORMULA {<some predicate>}the result was B's predicate only, silently dropping A's grant.
Changes
ACL merge (
Contracts/SqlConditions.cs,AasSecurity/SecurityService.cs)OrMerge/MergeConditions: empty or tautological operand absorbs under OR (result = unrestricted, all scope prefiltersand path/match/exists joins dropped). Operation is now a
MergeOpenum instead of a string.SqlConditionsMerger.IsUnrestricted().GetSqlConditions: a rule with neither FORMULA nor FILTER, or a merged result that is unrestricted, now returnsnull(=no restriction) instead of being skipped.
FORMULA {"$boolean": true}.Trust list (
AasSecurity/*)TrustedServermodel replaces the six parallel lists inGlobalSecurityVariables(ServerCertificates,ServerKid,...) which could get out of sync.
JwksTokenValidator(HTTP injected for testability). Lookup is byissfirst, thenkid; unlisted issuers arerejected.
trustlist.txtparser rewritten (ParseTrustListText): supportsissuer:,kid:,jwks:,audience:,domain:,certificate blocks; values are reset after each entry.
audience:, falling back to env varTOKEN_AUDIENCE. If neither is set, the audience is notvalidated and a warning is logged.
AasSecurityAuthenticationHandler.docs/security.md: new section 3.3 documenting the trust list format.Config
accessrules.txt: new rule allowing all rights on*for tokens whoserealm_accesscontainsaas-writer.trustlist.txt: added the Keycloak realmfxissuer with audienceaasx-server.Behavior changes to be aware of
kidheader from issuers not in the trust list were previously accepted (issuer/audience were notvalidated); they are now rejected. Deployments relying on this need a
trustlist.txtentry.combined with other rules.
Note on the diff
SecurityService.csshows about 2,700 changed lines, but the real change is about 100 lines (line endings were normalized).Use "Hide whitespace" in the Files changed view.
Tests
SecurityAccessRuleMergeTests(new): unconditional rule among restrictive rules, rule without FORMULA, OR-combination ofrestrictive rules, tree-submodel read, unchanged behavior for single restrictive rule.
SqlConditionsClaimScopeTests: updated for the new merge semantics.TrustListTests(new): parser (issuer/kid/audience/no leakage between entries), lookup (issuer wins over kid, trailingslash), validator (untrusted issuer, wrong key, wrong audience, audience array, kid-only entry).
AasxServerDB.Tests.Test plan
dotnet testforAasSecurityTestsandAasxServerDB.Tests$boolean: true, one restrictive): user sees all recordsaas-writercan write; without the role it cannottrustlist.txtis rejected; token with wrongaudis rejectedThings to check before you open the PR:
full write access to anyone with the aas-writer realm role. If those files are the defaults shipped in the repo, you may want
to drop or comment out those entries.
trailer. The PR text above is more complete, so you may want to squash with a better message.
install gh and I'll create it.