0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

lib-noirでアクセス権限を設定する

Posted at

セッションに格納されているキーで判別し、権限を分けています。
defroutes ではなく、def-restricted-routes を使わないといけないことに気づかずハマってしまいました。

core.clj
(def-restricted-routes api-routes
  (GET "/" req (index-page)
  (GET "/hoge" req (hoge-page))

(defn user-access [req]
  (contains? (:session req) :user))

(def access-rules
  [{:uri "/hoge" :rule user-access}])

(def app
  (noir-middleware/app-handler
    [api-routes]
    :access-rules access-rules))
)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?