Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marianoguerra/friend-json-workflow
json auth workflow for cemerick/friend
https://github.com/marianoguerra/friend-json-workflow
Last synced: about 1 month ago
JSON representation
json auth workflow for cemerick/friend
- Host: GitHub
- URL: https://github.com/marianoguerra/friend-json-workflow
- Owner: marianoguerra
- Created: 2013-01-14T10:38:06.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-03-26T13:01:46.000Z (over 11 years ago)
- Last Synced: 2024-08-23T15:31:59.711Z (3 months ago)
- Language: Clojure
- Size: 121 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.rest
Awesome Lists containing this project
README
friend-json-workflow
====================Adds support for json session workflow to cemerick's `friend library `_
Usage
-----see clojars page for install instructions:
https://clojars.org/org.marianoguerra/friend-json-workflow
see here for a complete example using `immutant `_:
https://github.com/marianoguerra/immutant-recipes/tree/master/friend-json-auth
the pieces you need to add it to your app are::
(ns myns.api
(:use [ring.middleware params keyword-params nested-params])(:require
[cemerick.friend :as friend]
(cemerick.friend [credentials :as creds])
[ring.middleware.session :as ring-session]
[marianoguerra.friend-json-workflow :as json-auth]))(def api-handler (-> my-api
wrap-keyword-params
wrap-nested-params
wrap-params))(def secure-app (-> api-handler
(friend/authenticate
{:login-uri "/myapp/api/session"
:unauthorized-handler json-auth/unauthorized-handler
:workflows [(json-auth/json-login
:login-uri "/myapp/api/session"
:login-failure-handler json-auth/login-failed
:credential-fn (partial creds/bcrypt-credential-fn logic/get-user-by-username))]})
(ring-session/wrap-session)))you will have to implement logic/get-user-by-username in the example above
* *POST /myapp/api/session* with a json body with the credentias will do the login
* *DELETE /myapp/api/session* will logout
* *GET /myapp/api/session* will return current credentialsLicense
-------Copyright © 2013 marianoguerra
Distributed under the Eclipse Public License, the same as Clojure.