Skip to content

Commit d9a633a

Browse files
authored
Add roles to request context map (#102)
1 parent 23e32d2 commit d9a633a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/juxt/site/alpha/handler.clj

+10
Original file line numberDiff line numberDiff line change
@@ -809,12 +809,22 @@
809809
'representation (dissoc resource ::http/body ::http/content)
810810
'environment {}}
811811

812+
user-id (:juxt.pass.alpha/user subject)
813+
814+
roles (crux/q db '{:find [role]
815+
:where [[role-mapping :juxt.site.alpha/type "UserRoleMapping"]
816+
[role-mapping :juxt.pass.alpha/assignee user-id]
817+
[role-mapping :juxt.pass.alpha/role role]]
818+
:in [user-id]}
819+
user-id)
820+
812821
authz (when (not= method :options)
813822
(pdp/authorization db request-context))
814823

815824
req (cond-> req
816825
true (assoc ::pass/request-context request-context)
817826
authz (assoc ::pass/authorization authz)
827+
roles (assoc ::pass/roles roles)
818828
;; If the max-content-length has been modified, update that in the
819829
;; resource
820830
(::http/max-content-length authz)

0 commit comments

Comments
 (0)