You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: buildResourceUrl strips port — ACL matching fails on non-standard ports #250
buildResourceUrl in src/auth/middleware.js uses request.hostname which in Fastify returns the hostname without port (e.g. localhost). But ACLs reference full URLs with port (e.g. http://localhost:4443/alice/public/premium.json).
The constructed resourceUrl http://localhost/alice/... never matches the ACL's accessTo of http://localhost:4443/alice/..., so conditional authorizations (like PaymentCondition) fail even when they should pass.
Reproduction
jss start --pay (runs on port 4443)
Create resource and ACL with accessTo: http://localhost:4443/alice/public/premium.json
PaymentCondition with amount 0, deposit sats, try to access
Gets 402 even though balance exists — because URL doesn't match
Fix
Use request.headers.host (includes port) instead of request.hostname (strips port) in buildResourceUrl.
Impact
Affects all ACL matching on non-standard ports. Default port 4443 is always affected. Only port 80/443 would accidentally work since browsers omit those from Host headers.
Activity
fix: use request.headers.host (with port) in buildResourceUrl