- ๐น๐ผTaiwan g-brodiei
Adding new tags for steps to reproduce and requires summary update for new contributors to step in easier.
While working on #2737719: EntityResource: Provide comprehensive test coverage: for every entity type, every format, every method โ , I encountered 403 responses when I expected to get 406 responses. Let me quote #2737719-38: EntityResource: Provide comprehensive test coverage: for every entity type, every format, every method โ , which is where this is being reported:
The struggle is because of the weird interaction/design of the routing + authentication system, which causes things to fail miserably in an unfriendly way when the user forgets to specify
?_format=nonsense
, or has a typo (for example?_format=haljson
on a URL that already has a HTML route.It's very very very confusing how Symfony's routing system first grants access because a user is authenticated via basic auth, and so
AccessAwareRouter
says everything is okay, and then afterwards, duringAuthenticationSubscriber::onKenrelRequestFilterProvider()
, we choose to deny access after all becausebasic_auth
isn't a globally allowed access provider, and the matched route (which matches the HTML, non-REST route due to the missing?format=
) is lacking an_auth
route option. You can either get a 406 (which is what we want), or a 403 with HTML (in case of non-specified or invalid format) or a 403 in the expected format (in case of non-specified or invalid format plusAccept
header, even though we don't actually supportAccept
headersโฆ thanks toDefaultExceptionSubscriber
callingRequest::getAcceptableContentTypes()
).
Worse, it's even possible to get the appropriate 406 response in case of an invalid format, but for that response to be sent withContent-Type: text/html
! (In case of anonymous.)More edge cases than I can count.
Seems like the authentication system and routing system are integrated in a brittle, confusing, backward manner. And the content negotiation system makes it that tiny bit extra unpredictable. This is no one's fault. This is complex software with (too) many layers, and without comprehensive integration tests, this sort of thing is to be expected.
TBD
None.
TBD, hopefully none.
TBD, hopefully none.
Needs work
10.1 โจ
Enhances developer experience.
Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Adding new tags for steps to reproduce and requires summary update for new contributors to step in easier.