【发布时间】:2015-12-17 13:49:45
【问题描述】:
我通过使用friend 库的基本身份验证来保护使用compojure 创建的几个HTTP 路由。它看起来像这样:
(defroutes my-routes
(context "/ctx" []
(GET "/x" [] ...)
(GET "/y" [] ...)
(GET "/z" [] ...)))
(let [friend-auth-cfg {:allow-anon? false
:unauthenticated-handler #(workflows/http-basic-deny "Unauthorized" %)
:workflows [(workflows/http-basic
:credential-fn #(creds/bcrypt-credential-fn {"username" {:password (creds/hash-bcrypt "password")}} %)
:realm "My realm")]}
my-route (-> (wrap-defaults my-routes api-defaults)
(friend/authenticate friend-auth-cfg))]
(run-jetty (routes my-route)))
我想做的是排除“y”路由 (/ctx/y) 不受基本身份验证的保护(但 x 和 z 仍应受到保护)。我怎样才能做到这一点?
【问题讨论】:
标签: clojure basic-authentication compojure