Skip to content

Commit

Permalink
Merge pull request #281 from psarando/CORE-1967-anonymous-metadata
Browse files Browse the repository at this point in the history
CORE-1967 Allow anonymous access in /filesystem/metadata endpoints
  • Loading branch information
slr71 authored Mar 12, 2024
2 parents dac5076 + e0e2863 commit 53edef5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/terrain/routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
(instant-launch-routes)
(secured-data-routes)
(secured-filesystem-routes)
(secured-filesystem-metadata-routes)
(secured-search-routes)
(app-category-routes)
(app-avu-routes)
Expand Down
8 changes: 8 additions & 0 deletions src/terrain/routes/filesystem.clj
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
(config/metadata-routes-enabled))]

(POST "/filesystem/metadata/csv-parser" [:as {:keys [user-info params] :as req}]
:middleware [require-authentication]
(meta/parse-metadata-csv-file user-info params))

(GET "/filesystem/metadata/templates" [:as req]
Expand All @@ -135,12 +136,15 @@
(controller req mt/do-metadata-template-view template-id))

(GET "/filesystem/metadata/template/:template-id/blank-csv" [template-id :as req]
:middleware [require-authentication]
(controller req meta-raw/get-template-csv template-id))

(GET "/filesystem/metadata/template/:template-id/guide-csv" [template-id :as req]
:middleware [require-authentication]
(controller req meta-raw/get-template-guide template-id))

(GET "/filesystem/metadata/template/:template-id/zip-csv" [template-id :as req]
:middleware [require-authentication]
(controller req meta-raw/get-template-zip template-id))

(GET "/filesystem/metadata/template/attr/:attr-id" [attr-id :as req]
Expand All @@ -150,15 +154,19 @@
(controller req meta/do-metadata-get :params data-id))

(POST "/filesystem/:data-id/metadata" [data-id :as req]
:middleware [require-authentication]
(controller req meta/do-metadata-set data-id :params :body))

(POST "/filesystem/:data-id/metadata/copy" [data-id :as req]
:middleware [require-authentication]
(controller req meta/do-metadata-copy :params data-id :body))

(POST "/filesystem/:data-id/metadata/save" [data-id :as req]
:middleware [require-authentication]
(controller req meta/do-metadata-save data-id :params :body))

(POST "/filesystem/:data-id/ore/save" [data-id :as req]
:middleware [require-authentication]
(controller req meta/do-ore-save data-id :params))))

(defn admin-filesystem-metadata-routes
Expand Down
8 changes: 5 additions & 3 deletions src/terrain/util/transformers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@
"Generates a set of query parameters to pass to a remote service that requires
the username of the authenticated user."
([]
(user-params {}))
(user-params {}))
([existing-params]
(assoc existing-params :user (:shortUsername current-user)))
(as-> (add-current-user-to-map {}) m
(select-keys m [:user])
(merge existing-params m)))
([existing-params param-keys]
(user-params (select-keys existing-params param-keys))))
(user-params (select-keys existing-params param-keys))))

0 comments on commit 53edef5

Please sign in to comment.