moved security.

This commit is contained in:
Bryce Covert
2018-04-06 09:20:51 -07:00
parent b93808f1df
commit c74e4fceaa
7 changed files with 100 additions and 90 deletions

View File

@@ -13,7 +13,7 @@
[ring.middleware.edn :refer [wrap-edn-params]]
[clojure.java.jdbc :as j]
[config.core :refer [env]]
[buddy.auth :refer [authenticated?]]
[buddy.auth.backends.token :refer [jws-backend]]
[buddy.auth.middleware :refer [wrap-authorization wrap-authentication]]
[auto-ap.routes.companies :as companies]
@@ -24,26 +24,17 @@
(defcredential "AKIAIRKDGLBX7J7VJZ6Q" "OtRw2t/xktJBDjP8Jnx1Yf6G+uzBfIkrQEc6nmgo" "us-east-1")
(defn wrap-secure [handler]
(fn [request]
(if (authenticated? request)
(handler request)
{:status 401
:body "not authenticated"})))
(defroutes static-routes
(GET "/" [] (response/resource-response "index.html" {:root "public"}))
(route/resources "/")
(routes (ANY "*" [] (response/resource-response "index.html" {:root "public"}))))
(defroutes api-routes
(context "/api" []
(wrap-routes invoices/routes wrap-secure)
(wrap-routes companies/routes wrap-secure)
(wrap-routes vendors/routes wrap-secure)
(wrap-routes reminders/routes wrap-secure)
invoices/routes
companies/routes
vendors/routes
reminders/routes
auth/routes))