File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export interface FastifyBasicAuthOptions {
2626 reply : FastifyReply ,
2727 done : ( err ?: Error ) => void
2828 ) : void | Promise < void | Error > ;
29- authenticate ?: boolean | { realm : string } ;
29+ authenticate ?: boolean | { realm : string | ( ( req : FastifyRequest ) => string ) } ;
3030 header ?: string ;
3131}
3232
Original file line number Diff line number Diff line change @@ -49,6 +49,26 @@ app.register(fastifyBasicAuth, {
4949 }
5050} )
5151
52+ //authenticate boolean
53+ app . register ( fastifyBasicAuth , {
54+ validate : ( ) => { } ,
55+ authenticate : true
56+ } )
57+
58+ //authenticate with realm
59+ app . register ( fastifyBasicAuth , {
60+ validate : ( ) => { } ,
61+ authenticate : { realm : 'example' }
62+ } )
63+
64+ //authenticate with realm (function)
65+ app . register ( fastifyBasicAuth , {
66+ validate : ( ) => { } ,
67+ authenticate : { realm : function realm ( req ) {
68+ return req . routerPath
69+ } }
70+ } )
71+
5272expectAssignable < onRequestHookHandler > ( app . basicAuth )
5373expectAssignable < preValidationHookHandler > ( app . basicAuth )
5474expectAssignable < preHandlerHookHandler > ( app . basicAuth )
You can’t perform that action at this time.
0 commit comments