Skip to content

Commit

Permalink
Merge pull request #877 from clojars/tobias/jar-level-permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias authored Dec 8, 2023
2 parents d25bdcc + e4c49cd commit fab7b2e
Show file tree
Hide file tree
Showing 19 changed files with 1,187 additions and 457 deletions.
14 changes: 14 additions & 0 deletions resources/public/js/permissions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const showHideNewJarInput = () => {
const tb = $('#scope_to_jar_new');
if ($('#scope_to_jar_select option:checked').val() === ':new') {
tb.show();
} else {
tb.hide();
tb.val('');
}
};

$(() => {
$('#scope_to_jar_select').on('change', showHideNewJarInput);
showHideNewJarInput();
});
12 changes: 4 additions & 8 deletions src/clojars/auth.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,18 @@
(defn with-account [f]
(friend/authenticated (try-account f)))

(defn authorized-admin? [db account group]
(defn authorized-admin? [db account group scope]
(when account
(let [adminnames (db/group-adminnames db group)
(let [adminnames (db/group-adminnames db group scope)
allnames (db/group-allnames db group)]
(or (some #{account} adminnames) (empty? allnames)))))

(defn authorized-member? [db account group]
(when account
(some #{account} (db/group-membernames db group))))

(defn authorized-group-access? [db account group]
(when account
(some #{account} (db/group-allnames db group))))

(defn require-admin-authorization [db account group f]
(if (authorized-admin? db account group)
(defn require-admin-authorization [db account group scope f]
(if (authorized-admin? db account group scope)
(f)
(friend/throw-unauthorized friend/*identity*
{:cemerick.friend/required-roles group})))
Expand Down
Loading

0 comments on commit fab7b2e

Please sign in to comment.