Skip to content

Instantly share code, notes, and snippets.

@geraldodev
Created May 20, 2020 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geraldodev/9251af0c18ed219c73870e07e2e06d8d to your computer and use it in GitHub Desktop.
Save geraldodev/9251af0c18ed219c73870e07e2e06d8d to your computer and use it in GitHub Desktop.
(defn wrap-enforce-roles [handler]
(fn [{::keys [roles request-method] :as request}]
(let [required (some-> request (ring/get-match) :data request-method ::roles)]
(if (and (seq required) (not (set/subset? required roles)))
{:status 403, :body "forbidden"}
(handler request)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment