summaryrefslogtreecommitdiff
path: root/src/chef/routes.clj
diff options
context:
space:
mode:
Diffstat (limited to 'src/chef/routes.clj')
-rw-r--r--src/chef/routes.clj22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/chef/routes.clj b/src/chef/routes.clj
index 51c721a..c2fd6c7 100644
--- a/src/chef/routes.clj
+++ b/src/chef/routes.clj
@@ -1,5 +1,10 @@
(ns chef.routes
(:require [reitit.ring :as rring]
+ [ring.middleware.oauth2 :as rmoauth2]
+ [ring.middleware.params :as rmparams]
+ [ring.middleware.session :as rmsession]
+ [dotenv :as env]
+ [clojure.string :as cstr]
[chef.pages.home :as cphome]
[chef.pages.admin :as cpadmin]))
@@ -8,6 +13,17 @@
["/admin/" {:get {:handler cpadmin/handler}}]
["/static/*" (rring/create-resource-handler)]])
-(def ring-handler (-> router
- rring/router
- (rring/ring-handler (rring/redirect-trailing-slash-handler))))
+(def ring-handler (delay (-> router
+ rring/router
+ (rring/ring-handler (rring/redirect-trailing-slash-handler))
+ (rmoauth2/wrap-oauth2 {:auth {:authorize-uri (env/env "OAUTH_AUTH_URI")
+ :access-token-uri (env/env "OAUTH_ACCESS_TOKEN_URI")
+ :client-id (env/env "OAUTH_CLIENT_ID")
+ :client-secret (env/env "OAUTH_CLIENT_SECRET")
+ :scopes (cstr/split (env/env "OAUTH_SCOPES") #",")
+ :launch-uri "/auth"
+ :redirect-uri "/auth/callback"
+ :landing-uri "/"
+ :pkce? true}})
+ rmparams/wrap-params
+ rmsession/wrap-session)))