- (lexical-let ((handler handler)
- (credentials credentials)
- (realm realm)
- (unauth unauth)
- (invalid invalid))
- (lambda (request)
- (with-slots (process headers) request
- (let ((auth (cddr (assoc :AUTHORIZATION headers))))
- (cond
- ;; no authentication information provided
- ((not auth)
- (if unauth
- (funcall unauth request)
- (ws-response-header process 401
- (cons "WWW-Authenticate"
- (format "Basic realm=%S" (or realm "restricted")))
- '("Content-type" . "text/plain"))
- (process-send-string process "authentication required")))
- ;; valid authentication information
- ((string= (cdr auth) (cdr (assoc (car auth) credentials)))
- (funcall handler request))
- ;; invalid authentication information
- (t
- (if invalid
- (funcall invalid request)
- (ws-response-header process 403 '("Content-type" . "text/plain"))
- (process-send-string process "invalid credentials")))))))))
+ (lambda (request)
+ (with-slots (process headers) request
+ (let ((auth (cddr (assoc :AUTHORIZATION headers))))
+ (cond
+ ;; no authentication information provided
+ ((not auth)
+ (if unauth
+ (funcall unauth request)
+ (ws-response-header process 401
+ (cons "WWW-Authenticate"
+ (format "Basic realm=%S" (or realm "restricted")))
+ '("Content-type" . "text/plain"))
+ (process-send-string process "authentication required")))
+ ;; valid authentication information
+ ((string= (cdr auth) (cdr (assoc (car auth) credentials)))
+ (funcall handler request))
+ ;; invalid authentication information
+ (t
+ (if invalid
+ (funcall invalid request)
+ (ws-response-header process 403 '("Content-type" . "text/plain"))
+ (process-send-string process "invalid credentials"))))))))