Files
main.tsmain
What you'll learn
- Accept a bearer token or basic credentials on the same routes with some(), and know whose challenge a refused request sees
- Chain checks that must all pass with every(), in order
- Exclude paths from a guard with except(), by pattern or by a function of the context
Press Run tests to start the app. Its log appears here.Graded endpoints
except() skips the whole combination for /api/public/*: no credentials, no request id
Both guards in some() refused; the last one's challenge is the answer, so the Basic realm is what a browser sees
The first guard accepts, so the second never runs; every() also ran requestId(), which the handler reads
The bearer guard refuses and some() moves on to basicAuth, which accepts admin:secret
Refused by both: again the last guard's challenge
The same combined guard on every method under /api
Past the guard, the handler's 404
Tom is gone for everyone