Skip to content

Instantly share code, notes, and snippets.

@biesnecker
Created November 26, 2012 10:15
Show Gist options
  • Save biesnecker/4147504 to your computer and use it in GitHub Desktop.
Save biesnecker/4147504 to your computer and use it in GitHub Desktop.
(server/add-middleware
friend/authenticate
{ :credential-fn (partial creds/bcrypt-credential-fn users)
:workflows [(workflows/interactive-form)]
:login-uri "/login"
:unauthorized-redirect-uri "/login"
:default-landing-uri "/" })
(pre-route [:any "/app/*"] { :as req } (let [id (friend/identity req)]
(when-not (friend/authorized? [::user] id) (friend/throw-unauthorized id {}))))
(pre-route [:any "/admin/*"] { :as req } (let [id (friend/identity req)]
(when-not (friend/authorized? [::admin] id) (friend/throw-unauthorized id { :unauthorized-redirect-uri "/blarg" }))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment