A Clojure library designed for easy and flexible authentication and authorization, especially in ring-based applications.
Consists of authentication, authorization, and a series of auth-specific libraries, including oauth2.
To install, add the following to your project's :dependencies
key:
[foe "0.3.0"]
Consider a Clams app where we want to authn/z a request. We can do that in one step using Foe, assuming that each request contains the needed user information:
;;; ...
(require '[foe.authentication :refer [wrap-authentication]])
(require '[clams.app :as app])
(defn- find-user-from-request [req]
...)
(defn- my-auth-function [req]
(if-let [user (find-user-from-request req)]
{:roles ["user"] :guid (:id user)}
{:error "Unauthorized"}))
(defn wrap-auth [app]
(wrap-authentication app my-auth-function))
(defn -main [& args]
(app/start-server 'sample {:middleware [wrap-auth]}))
To run the Foe tests, just:
lein test
Copyright © 2015 Standard Treasury
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.