The owner select dropdown was recently added to the asset edit form, allowing ADMIN/SECCHAMPION users to assign asset ownership to a system user by storing their username in the Asset.owner field. However, assigning a user as owner does not grant them visibility of the asset — they still see 0 assets.
Root cause: Asset.owner is a purely metadata String field. The access control logic in AssetFilterService and the unified SQL query in AssetRepository.findAccessibleAssets() never check the owner field. Access is determined by workgroup membership, manualCreator FK, scanUploader FK, AWS account mappings, and AD domain mappings — but not by the owner string.
Plan
Add an 8th access control criterion: if Asset.owner matches the user's username, grant access.
1. Update the unified native SQL query in AssetRepository
In getAccessibleAssets(): extract the username from authentication.name
Pass it to both getAccessibleAssetsUnified() and getAccessibleAssetsMultiQuery()
In getAccessibleAssetsUnified(): pass it to assetRepository.findAccessibleAssets()
Files to Modify
#
File
Change
1
AssetRepository.kt
Add username param + OR a.owner = :username to findAccessibleAssets()
2
AssetFilterService.kt
Extract authentication.name, pass through, add findByOwner() to multi-query path
Existing Methods Reused
AssetRepository.findByOwner(owner: String): List<Asset> — already exists at line 84
authentication.name — standard Micronaut auth, returns the username
Verification
./gradlew build — clean compilation
Log in as secmanadmin, assign an asset's owner to secmanuser
Log in as secmanuser — the asset should now be visible
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/flake/.claude/projects/-Users-flake-sources-misc-secman/0fa43d35-d049-44a5-9b20-cc5a085745bb.jsonl
Assistant
Let me read the two files that need modification.
Assistant
★ Insight ─────────────────────────────────────
The current access control has 7 criteria checked via two code paths:
Unified path (Feature 073, default): A single native SQL query with OR clauses — efficient, one DB round-trip
Multi-query fallback: Multiple separate repository calls, merged in Kotlin with distinctBy
The owner field is a plain String (username), not a FK to User. This means the SQL check is a simple equality comparison a.owner = :username, and the existing findByOwner() method already handles the multi-query path.
─────────────────────────────────────────────────
Let me make both changes now.
Assistant
Now update the two private methods to accept and use the username parameter.
Assistant
Now I need to check if findAccessibleAssets is called from anywhere else that also needs updating.
Assistant
Good — findAccessibleAssets is only called from AssetFilterService, and the spec files are just documentation. Let me also update the CLAUDE.md access control documentation to include the new 8th criterion, and then run the build.
First, let me update the docstring comment in AssetFilterService to document the new criterion.
Assistant
Now let's build to verify compilation.
Assistant
Build successful with no errors. Now let me update the CLAUDE.md to document the new 8th access criterion.
Assistant
All done. Here's a summary of the changes:
AssetRepository.kt — Added username: String parameter to findAccessibleAssets() and appended OR a.owner = :username to the native SQL WHERE clause.
AssetFilterService.kt — Extracted authentication.name as username, passed it through to both code paths:
Unified path: forwarded to findAccessibleAssets(userId, userEmail, username)
Multi-query fallback: added assetRepository.findByOwner(username) to the merge set
CLAUDE.md — Documented criterion #8 in the Unified Access Control section.
★ Insight ─────────────────────────────────────
The owner field is a String storing a username, not a foreign key to User. This makes the SQL check trivial (a.owner = :username) but means ownership isn't enforced at the schema level — renaming a user would silently break the link.
Both access control paths (unified SQL and multi-query fallback) needed updating because MemoryOptimizationConfig.lazyLoadingEnabled controls which path is active. The unified path is the default in production, but the fallback exists for feature-flag rollback.
The existing findByOwner() method at line 84 was already available in the repository, so the multi-query path required zero new queries — just including its result in the deduplication merge.
─────────────────────────────────────────────────
User
there is a Javascript error, please fix this, i still cannot see the asset
User
[Image: image/png]
User
[Image: image/png]
User
[Image: source: /var/folders/k7/jz4z13354rlbg2yhm0vw9g2w0000gn/T/TemporaryItems/NSIRD_screencaptureui_VmZFkk/Screenshot 2026-03-08 at 16.46.08.png]
User
[Image: source: /var/folders/k7/jz4z13354rlbg2yhm0vw9g2w0000gn/T/TemporaryItems/NSIRD_screencaptureui_THDBge/Screenshot 2026-03-08 at 16.46.35.png]
Assistant
The 403 on /api/workgroups is expected for non-admin users and is already handled gracefully in the frontend. The real problem is the backend returning 0 accessible assets despite our changes. Let me check the AssetController to trace the flow.
Assistant
The backend log shows "Found 0 accessible assets" — this likely means the backend hasn't been restarted with the new code yet. But you also mentioned a JavaScript error — the 403 on /api/workgroups is showing as a red error in the console. Let me check how the frontend handles that.
Assistant
Two separate issues here:
JavaScript error (403 on /api/workgroups): The frontend fetches workgroups for all users, but only ADMINs can access that endpoint. The 403 is handled gracefully in code but still shows as a red error in the console.
0 assets: The backend needs to be restarted for the code changes to take effect. The log shows the old code running.
Let me fix the frontend to skip the workgroups fetch for non-admin users:
Assistant
★ Insight ─────────────────────────────────────
The /api/workgroups endpoint is @Secured("ADMIN"), so non-admin users always get a 403. While the frontend handler at line 119-121 gracefully catches this, the browser always logs HTTP errors (4xx/5xx) to the console — there's no way to suppress that. The fix is to avoid making the request in the first place.
The workgroups filter is only useful for admins anyway (non-admins don't have workgroup data), so the existing fallback at line 779 (deriving workgroup names from the asset data itself) still populates the dropdown for non-admins.
─────────────────────────────────────────────────
Now for the 0 assets issue — the backend log shows Found 0 accessible assets for user: secmanuser, which means the old code (without the OR a.owner = :username clause) is still running. You need to restart the backend for the code changes to take effect. Stop the current backendng:run and re-run:
code
./gradlew :backendng:run
After restarting, the unified SQL query will include the new OR a.owner = :username condition, and assets owned by secmanuser should appear.
User
please propose a fix for this error, which is ultimatly blocking ownership assignments
User
[Image: image/png]
User
[Image: source: /var/folders/k7/jz4z13354rlbg2yhm0vw9g2w0000gn/T/TemporaryItems/NSIRD_screencaptureui_FswtX3/Screenshot 2026-03-08 at 16.54.26.png]
Assistant
The console shows PUT /api/assets/47626 returning 403 Forbidden for user secmanadmin with roles Array(3). This is the update endpoint. Let me check what's happening — the @Secured annotation on the controller is IS_AUTHENTICATED, but the update method has an internal ADMIN-only check for workgroup reassignment. The issue is likely that the owner field update is being sent together with workgroupIds, and the non-ADMIN role check is blocking it.
Wait — secmanadmin should have ADMIN. Let me look more carefully. The roles are Array(3) but we can't see what they are. Let me check the update endpoint logic and the owner-candidates endpoint.
Assistant
The PUT to /api/assets/47626 returns 403 for an admin user — that shouldn't happen. Let me check the auth utility to see how PUT requests are sent.
Assistant
Wait — the CORS finding doesn't apply here. The browser is on https://secman.covestro.net/assets making a PUT to https://secman.covestro.net/api/assets/47626 — that's same-origin, so CORS preflight doesn't apply. The 403 must come from somewhere else.
Let me look at the actual security config and the handleSubmit flow more carefully.
Assistant
I see the issue now. Let me look at the CORS config more carefully.
Assistant
Found it. Here's the root cause:
★ Insight ─────────────────────────────────────
The web CORS config (line 18-37) allows PUT but only for localhost origins
The mcp CORS config (line 40-58) has allowed-origins-regex: ".*" which matches all origins — including the production origin https://secman.covestro.net
The mcp config is missing PUT from its allowed methods (line 44-47)
In production, the backend runs on http://localhost:8080 behind a reverse proxy. The browser sends Origin: https://secman.covestro.net, which doesn't match the web config's localhost origins, so Micronaut falls through to the mcp config (which matches everything via .*). Since mcp doesn't allow PUT, the preflight response rejects it → 403 Forbidden.
GET and POST work fine because they're listed in the mcp config. Only PUT is missing.
─────────────────────────────────────────────────
The fix is to add PUT to the mcp CORS config:
Assistant
After restarting the backend, the PUT to /api/assets/{id} will no longer return 403, and owner assignments will work.
The deeper issue is that the web CORS config only lists localhost origins, so in production all requests fall through to the mcp catch-all config. You may want to also add the production origin (https://secman.covestro.net) to the web config's allowed-origins so production browser requests use the proper web CORS config instead of the MCP one.