On this page:
make
Version: 4.1

5.9 Password Protection

 (require web-server/dispatchers/dispatch-passwords)

The web-server/dispatchers/dispatch-passwords module defines a dispatcher constructor that performs HTTP Basic authentication filtering.

(make

 [

#:password-file password-file

 

 

 

#:authentication-responder authentication-responder])

 

 

 

(-> void)

 

dispatcher?

  password-file : path-string? = "passwords"

  

authentication-responder

 

:

 

((url url?) (header header?) . -> . response?)

 

 

 

=

 

(gen-authentication-responder "forbidden.html")

The first returned value is a procedure that refreshes the password file used by the dispatcher.

The dispatcher that is returned does the following: Checks if the request contains Basic authentication credentials, and that they are included in password-file. If they are not, authentication-responder is called with a header that requests credentials. If they are, then next-dispatcher is invoked.

password-file is parsed as:

  (list ([domain : string?]

         [path : string-regexp?]

         (list [user : symbol?]

               [pass : string?])

         ...)

        ...)

For example:

  '(("secret stuff" "/secret(/.*)?" (bubba "bbq") (Billy "BoB")))