[plt-scheme] Digest Authentication in the PLT Scheme Web Server

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Wed Feb 4 14:06:01 EST 2009

>From http://jay-mccarthy.blogspot.com/2009/02/digest-authentication-in-plt-scheme-web.html:

The PLT Scheme Web Server now has built-in support for Digest Authentication.

It is provided by the web-server/http/digest-auth module (and through
the web-server/http wrapper that is included in all servlets.)

Here's an example:

  #lang web-server/insta
  (require scheme/pretty)

  (define private-key "private-key")
  (define opaque "opaque")

  (define (start req)
    (match (request->digest-credentials req)
        401 #"Unauthorized" (current-seconds)
        (list (make-digest-auth-header
               (format "Digest Auth Test: ~a" (gensym))
               private-key opaque)))]
       (define check
           (lambda (username realm) "pass"))))
       (define pass?
         (check "GET" alist))
       `(html (head (title "Digest Auth Test"))
               (h1 ,(if pass? "Pass!" "No Pass!"))
               (pre ,(pretty-format alist))))]))

Documentation at:


And at


after tonight.

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93

Posted on the users mailing list.