Closed yakovenkodenis closed 7 months ago
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
Yes, I'll give it a try
The PR is ready for review: https://github.com/fastify/fastify-auth/pull/217
Released in v4.5.0
Prerequisites
🚀 Feature Proposal
It seems that composite authentication should allow the
or
relation for sub-arrays, not onlyand
.It's currently stated in the docs that:
but this feels like a limiting and unnecessary constraint.
Motivation
It seems natural for the relation inside an auth subarray to be the opposite of the main array relation.
The only current use-case for composite auth looks like this:
which results in the
f1 OR f2 OR (f3 AND f4)
logical expression.However, it might be also useful to allow composite auth when
relation
is 'and', so that the code belowwould result in the following logical expression:
f1 AND f2 AND (f3 OR f4)
.Basically, when the main (default) array relation is
and
we want the relation for sub-arrays to beor
, and vice versa (like with the current implementation): when the main array relation isor
the relation inside subarrays isand
.Example
Current implementation of composite auth only allows a single use-case:
It would be great to allow also the oppisite use-case: