Skip to content

Instantly share code, notes, and snippets.

@dima767
Created November 29, 2011 23:00
Show Gist options
  • Save dima767/1407022 to your computer and use it in GitHub Desktop.
Save dima767/1407022 to your computer and use it in GitHub Desktop.
Higher order function for cas-server-clojure prototype
(defn cas-process-auth [cred handlers]
(if (empty? handlers)
{:authenticated false :handler :none}
(let [assertion ((first handlers) cred)]
(if (:authenticated assertion)
assertion
(recur cred (rest handlers))))))
@wgthom
Copy link

wgthom commented Nov 30, 2011

improvement? still feels to procedural...how about somehow mapping the authenicators until the first returns a valid authN?

(ns jasig.cas)

(defn authenticate-user [authenticators credentials]
{:pre [(seq authenticators) (seq credentials)]}
(if-let [auth-results ((first authenticators) credentials))]
auth-results
(recur credentials (rest authenticators))))

@dima767
Copy link
Author

dima767 commented Nov 30, 2011 via email

@dima767
Copy link
Author

dima767 commented Nov 30, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment