feat(basic-auth): add context key and callback options (#4645)
* feat(basic-auth): add usernameContextKey and onAuthSuccess options Add two new options to basicAuth middleware: - `usernameContextKey`: stores authenticated username in context - `true`: uses default key 'basicAuthUsername' - `string`: uses custom key name - `onAuthSuccess`: callback invoked after successful authentication This allows route handlers to access the authenticated username without re-parsing the Authorization header. * test(basic-auth): add tests for usernameContextKey and onAuthSuccess Add test cases for: - usernameContextKey with default key 'basicAuthUsername' - usernameContextKey with custom key - usernameContextKey not set (should not store username) - usernameContextKey with verifyUser mode - onAuthSuccess callback execution - onAuthSuccess async callback support - onAuthSuccess not called on failed auth - onAuthSuccess with verifyUser mode - Both options used together * remove `usernameContextKey` * remove unnecessary comments * remove unnecessary comments --------- Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
A
AprilNEA committed
bf37828d6df56618bb90649c65c1c4deb2f9bcd6
Parent: 9524923
Committed by GitHub <noreply@github.com>
on 2/19/2026, 10:20:20 AM