Digest Authentication Example


This example defines users, groups, and realms within the digest authentication scheme for HTTP. Read the code below before trying this examples so that you will know the necessary users, passwords, and groups.


The above example is defined in http:examples;exports.lisp by the following LISP code:

(in-package :http-user)
;; ADD-REALM a new authentication realm using the digest authentication scheme.
(add-realm :digest-realm :digest)

;; The realm must contain groups before user objects refer to them.
(add-groups :digest-realm :members :elite-members)

;; Set up two users, assigning realms and groups.
(add-user "mike" :digest-realm
          :password "mike-foo"
          :groups '(:members)
          :personal-name "Mike Smith"
          :email-address "mike@foo.com")

(add-user "joe" :digest-realm
          :password "joe-foo"
          :groups '(:members :elite-members)
          :personal-name "Joe Doe"
          :email-address "joe@foo.com")

;; Define a set of capabilities giving the :elite-members group basic access
(add-access-control-group :elite-members-access
                          :digest-realm
                          :capabilities '((:get :elite-members)
                                          (:head :elite-members)))

;; Export some access-controlled urls
(export-url #u"/cl-http/authentication/members.html"
            :html-computed
            :response-function #'display-url-authentication-status
            :authentication-realm :digest-realm
            :capabilities nil ;;no capabilities means anyone in the realm has access
            :expiration '(:no-expiration-header)
            :keywords '(:cl-http :authentication :demo))

(export-url #u"/cl-http/authentication/elite-members.html"
            :html-computed
            :response-function #'display-url-authentication-status
            :authentication-realm :digest-realm
            :capabilities :elite-members-access
            :expiration '(:no-expiration-header)
            :keywords '(:cl-http :authentication :demo))

Back to CL-HTTP Authentication


Christopher R. Vincent -- Christopher_Vincent@nospam.alum.mit.edu
M.I.T. Computer Science & Artificial Intelligence Laboratory