Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
a35b2d9c
Commit
a35b2d9c
authored
10 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
permission checks on all org membership modification endpoints.
parent
e19e5ba2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/api/org.clj
+14
-9
14 additions, 9 deletions
src/metabase/api/org.clj
with
14 additions
and
9 deletions
src/metabase/api/org.clj
+
14
−
9
View file @
a35b2d9c
...
...
@@ -20,16 +20,19 @@
{
:status
200
:body
{}})
(
defendpoint
GET
"/:id"
[
id
]
(
let-404
[{
:keys
[
can_read
]
:as
org
}
(
sel
:one
Org
:id
id
)]
(
check-403
@
can_read
)
org
))
(
defendpoint
GET
"/slug/:slug"
[
slug
]
(
let-404
[{
:keys
[
can_read
]
:as
org
}
(
sel
:one
Org
:slug
slug
)]
(
check-403
@
can_read
)
org
))
(
defendpoint
PUT
"/:id"
[
id
:as
{
body
:body
}]
(
let-404
[{
:keys
[
can_write
]
:as
org
}
(
sel
:one
Org
:id
id
)]
(
check-403
@
can_write
)
...
...
@@ -77,28 +80,30 @@
(
defendpoint
POST
"/:id/members/:user-id"
[
id
user-id
:as
{
body
:body
}]
;; TODO - permissions check
(
let-404
[
org
(
sel
:one
Org
:id
id
)]
; user must have admin perms on org to proceed
(
let-404
[{
:keys
[
can_write
]
:as
org
}
(
sel
:one
Org
:id
id
)]
(
check-403
@
can_write
)
(
let-404
[
user
(
sel
:one
User
:id
user-id
)]
(
grant-org-perm
id
user-id
(
or
(
:admin
body
)
false
))
{
:success
true
})))
(
defendpoint
PUT
"/:id/members/:user-id"
[
id
user-id
:as
{
body
:body
}]
;
; TODO - permissions check
;; HMMM, same body as endpoint above in this case. how can we unify the impl of 2 endpoints?
(
let-404
[
org
(
sel
:one
Org
:id
id
)]
;
user must have admin perms on org to proceed
(
let-404
[{
:keys
[
can_write
]
:as
org
}
(
sel
:one
Org
:id
id
)]
(
check-403
@
can_write
)
(
let-404
[
user
(
sel
:one
User
:id
user-id
)]
(
grant-org-perm
id
user-id
(
or
(
:admin
body
)
false
))
{
:success
true
})))
(
defendpoint
DELETE
"/:id/members/:user-id"
[
id
user-id
:as
{
body
:body
}]
;
; TODO - permissions check
;; HMMM, same body as endpoint above in this case. how can we unify the impl of 2 endpoints?
(
let-404
[
org
(
sel
:one
Org
:id
id
)]
;
user must have admin perms on org to proceed
(
let-404
[{
:keys
[
can_write
]
:as
org
}
(
sel
:one
Org
:id
id
)]
(
check-403
@
can_write
)
(
let-404
[
user
(
sel
:one
User
:id
user-id
)]
(
del
OrgPerm
:user_id
user-id
:organization_id
id
))))
(
del
OrgPerm
:user_id
user-id
:organization_id
id
)
{
:success
true
})))
(
define-routes
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment