Created
October 12, 2013 01:11
-
-
Save cgag/6944435 to your computer and use it in GitHub Desktop.
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
... | |
(defroutes basic-routes | |
(GET "/" [] (str "<a href=\"/test\">test</a>")) | |
(GET "/test" [] (friend/authenticated (home/index)))) | |
(defroutes all-routes | |
basic-routes | |
<other routes>) | |
(def users | |
(def users {"root" {:username "root" | |
:password (creds/hash-bcrypt "admin_password") | |
:roles #{::admin}} | |
"jane" {:username "jane" | |
:password (creds/hash-bcrypt "user_password") | |
:roles #{::user}}})) | |
(def secured-app | |
(friend/authenticate | |
all-routes | |
{:allow-anon? true | |
:unauthenticated-handler (fn [e] {:status 200 :body (str e)}) | |
:workflows [(workflows/http-basic | |
:credential-fn (partial creds/bcrypt-credential-fn users))]})) | |
(def app (handler/site #'secured-app)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment