|
9 | 9 | [clojars.friend.oauth.github :as github] |
10 | 10 | [clojars.friend.oauth.gitlab :as gitlab] |
11 | 11 | [clojars.friend.registration :as registration] |
12 | | - [clojars.http-utils :refer [wrap-secure-session wrap-additional-security-headers]] |
| 12 | + [clojars.http-utils :refer [wrap-additional-security-headers |
| 13 | + wrap-secure-session]] |
13 | 14 | [clojars.log :as log] |
14 | 15 | [clojars.middleware :refer [wrap-ignore-trailing-slash]] |
15 | 16 | [clojars.routes.api :as api] |
|
22 | 23 | [clojars.routes.user :as user] |
23 | 24 | [clojars.routes.verify :as verify] |
24 | 25 | [clojars.web.browse :refer [browse]] |
25 | | - [clojars.web.common :as common :refer [html-doc]] |
| 26 | + [clojars.web.common :as common :refer [html-doc raw]] |
26 | 27 | [clojars.web.dashboard :refer [dashboard index-page]] |
27 | | - [clojars.web.safe-hiccup :refer [raw]] |
28 | 28 | [clojars.web.search :as search] |
29 | 29 | [clojure.java.io :as io] |
30 | 30 | [compojure.core :refer [ANY context GET PUT routes]] |
|
55 | 55 | (let [db (:spec db)] |
56 | 56 | (routes |
57 | 57 | (GET "/" _ |
58 | | - (try-account |
59 | | - #(if % |
60 | | - (dashboard db %) |
61 | | - (index-page db stats %)))) |
| 58 | + (try-account |
| 59 | + #(if % |
| 60 | + (dashboard db %) |
| 61 | + (index-page db stats %)))) |
62 | 62 | (GET "/search" {:keys [params]} |
63 | | - (try-account |
64 | | - #(let [validated-params (-> params |
65 | | - (update :page try-parse-page))] |
66 | | - (search/search search % validated-params)))) |
| 63 | + (try-account |
| 64 | + #(let [validated-params (-> params |
| 65 | + (update :page try-parse-page))] |
| 66 | + (search/search search % validated-params)))) |
67 | 67 | (GET "/projects" {:keys [params]} |
68 | | - (try-account |
69 | | - #(let [validated-params |
70 | | - (-> params |
71 | | - (update :from (partial common/check-no-null-bytes "from")) |
72 | | - (update :page try-parse-page))] |
73 | | - (browse db % validated-params)))) |
| 68 | + (try-account |
| 69 | + #(let [validated-params |
| 70 | + (-> params |
| 71 | + (update :from (partial common/check-no-null-bytes "from")) |
| 72 | + (update :page try-parse-page))] |
| 73 | + (browse db % validated-params)))) |
74 | 74 | (GET "/security" [] |
75 | | - (try-account |
76 | | - #(html-doc "Security" {:account %} |
77 | | - (raw (slurp (io/resource "security.html")))))) |
| 75 | + (try-account |
| 76 | + #(html-doc "Security" {:account %} |
| 77 | + (raw (slurp (io/resource "security.html")))))) |
78 | 78 | (GET "/dmca" [] |
79 | | - (try-account |
80 | | - #(html-doc "DMCA" {:account %} |
81 | | - (raw (slurp (io/resource "dmca.html")))))) |
| 79 | + (try-account |
| 80 | + #(html-doc "DMCA" {:account %} |
| 81 | + (raw (slurp (io/resource "dmca.html")))))) |
82 | 82 | session/routes |
83 | 83 | (group/routes db event-emitter) |
84 | 84 | (artifact/routes db stats) |
|
90 | 90 | (api/routes db stats) |
91 | 91 | (PUT "*" _ {:status 405 :headers {} :body "Did you mean to use /repo?"}) |
92 | 92 | (ANY "*" _ |
93 | | - (try-account |
94 | | - #(not-found |
95 | | - (html-doc "Page not found" {:account %} |
96 | | - [:div.small-section |
97 | | - [:h1 "Page not found"] |
98 | | - [:p "Thundering typhoons! I think we lost it. Sorry!"]]))))))) |
| 93 | + (try-account |
| 94 | + #(not-found |
| 95 | + (html-doc "Page not found" {:account %} |
| 96 | + [:div.small-section |
| 97 | + [:h1 "Page not found"] |
| 98 | + [:p "Thundering typhoons! I think we lost it. Sorry!"]]))))))) |
99 | 99 |
|
100 | 100 | (def ^:private defaults-config |
101 | 101 | (-> ring-defaults/secure-site-defaults |
|
149 | 149 | (let [db (:spec db)] |
150 | 150 | (routes |
151 | 151 | (-> (context |
152 | | - "/repo" _ |
153 | | - (-> (repo/routes storage db event-emitter search) |
154 | | - (friend/authenticate |
155 | | - {:credential-fn (auth/token-credential-fn db) |
156 | | - :workflows [(workflows/http-basic :realm "clojars")] |
157 | | - :allow-anon? false |
158 | | - :unauthenticated-handler |
159 | | - (partial workflows/http-basic-deny "clojars")}) |
160 | | - (repo/wrap-reject-non-token db) |
161 | | - (repo/wrap-exceptions error-reporter) |
162 | | - (repo/wrap-file (:repo (config))) |
163 | | - (log/wrap-request-context) |
164 | | - (repo/wrap-reject-double-dot))) |
| 152 | + "/repo" _ |
| 153 | + (-> (repo/routes storage db event-emitter search) |
| 154 | + (friend/authenticate |
| 155 | + {:credential-fn (auth/token-credential-fn db) |
| 156 | + :workflows [(workflows/http-basic :realm "clojars")] |
| 157 | + :allow-anon? false |
| 158 | + :unauthenticated-handler |
| 159 | + (partial workflows/http-basic-deny "clojars")}) |
| 160 | + (repo/wrap-reject-non-token db) |
| 161 | + (repo/wrap-exceptions error-reporter) |
| 162 | + (repo/wrap-file (:repo (config))) |
| 163 | + (log/wrap-request-context) |
| 164 | + (repo/wrap-reject-double-dot))) |
165 | 165 | (wrap-secure-session)) |
166 | 166 | (-> (token-breach/routes db event-emitter) |
167 | 167 | (wrap-exceptions error-reporter) |
|
0 commit comments