Skip to content
/ foe Public
forked from 99plus2/foe

Authentication and Authorization Clojure Library

License

Notifications You must be signed in to change notification settings

lildata/foe

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Foe

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.

Usage

To install, add the following to your project's :dependencies key:

[foe "0.3.0"]

Example

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]}))

Testing

To run the Foe tests, just:

lein test

License

Copyright © 2015 Standard Treasury

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Authentication and Authorization Clojure Library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Clojure 100.0%