Created
November 29, 2011 23:00
-
-
Save dima767/1407022 to your computer and use it in GitHub Desktop.
Higher order function for cas-server-clojure prototype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))))) |
Sure. This is just a first pass to get the ball rolling :-) I now feel we could create a very lean CAS core out of small composable functions without a lot of "extra baggage"
D.
…Sent from my iPhone
On Nov 29, 2011, at 20:04, "William G. Thompson, ***@***.*** wrote:
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))))
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1407022
Actually this is what the code does - goes through the provided authenticators and returns the first successful authN result. There are diff. ways of doing it, I'm sure and is subject to refactoring :-)
…Sent from my iPhone
On Nov 29, 2011, at 20:04, "William G. Thompson, ***@***.*** wrote:
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))))
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/1407022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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))))