► |  | Web Server: PLT HTTP Server

1 | Running the Web Server
2 | Writing Servlets
3 | Extending the Web Server
4 | Troubleshooting and Tips
5 | Acknowledgements
| Index

► | 3 | Extending the Web Server

3.1 | Configuration
3.2 | Setting Up Servlets
3.3 | Dispatchers
3.4 | Web Config Unit
3.5 | Web Server Unit
3.6 | Internal

▼ | 3.3 | Dispatchers

3.3.1 | General
3.3.2 | Mapping URLs to Paths
3.3.3 | Sequencing
3.3.4 | Timeouts
3.3.5 | Lifting Procedures
3.3.6 | Filtering Requests
3.3.7 | Procedure Invocation upon Request
3.3.8 | Logging
3.3.9 | Password Protection
3.3.10 | Virtual Hosts
3.3.11 | Serving Files
3.3.12 | Serving Servlets
3.3.13 | Statistics
3.3.14 | Limiting Requests

On this page:

denied?/ c
make
authorized?/ c
make-basic-denied?/ path

Version: 4.1.4
top← prev up next →

##### 3.3.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.

denied?/c : contract?

Equivalent to (-> request? (or/c false/c string?)). The return is the authentication realm as a string if the request is not authorized and #f if the request is authorized.

(make |  | denied? |
| [ | #:authentication-responder authentication-responder]) |

→ dispatcher/c
denied? : denied?/c

| authentication-responder |  | : |  | (url? header? . -> . response?)
|  |  | = |  | (gen-authentication-responder "forbidden.html")

A dispatcher that checks if the request is denied based on denied?. If so, then authentication-responder is called with a header that requests credentials. If not, then next-dispatcher is invoked.

authorized?/c : contract?

Equivalent to (-> string? (or/c false/c bytes?) (or/c false/c bytes?) (or/c false/c string?)). The input is the URI as a string and the username and passwords as bytes. The return is the authentication realm as a string if the user is not authorized and #f if the request is authorized.

(make-basic-denied?/path password-file)

→

(-> void) |  | authorized?/c

password-file : path-string?

Creates an authorization procedure based on the given password file. The first returned value is a procedure that refreshes the password cache used by the authorization procedure.

password-file is parsed as:

(list ([domain : string?]
[path : string?] ; This string is interpreted as a regex
(list [user : symbol?]
[pass : string?])
...)
...)

For example:

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

top← prev up next →