Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
NACSOS Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
MCC APSIS
NACSOS
NACSOS Core
Commits
800192d4
Commit
800192d4
authored
2 years ago
by
Tim Repke
Browse files
Options
Downloads
Patches
Plain Diff
project_id now transmitted as header
parent
b08e3ff4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/util/security.py
+5
-5
5 additions, 5 deletions
server/util/security.py
with
5 additions
and
5 deletions
server/util/security.py
+
5
−
5
View file @
800192d4
...
...
@@ -3,7 +3,7 @@ from datetime import timedelta, datetime
from
pydantic
import
BaseModel
from
jose
import
JWTError
,
jwt
from
passlib.context
import
CryptContext
from
fastapi
import
Depends
,
HTTPException
,
status
,
Path
from
fastapi
import
Depends
,
HTTPException
,
status
,
Path
,
Header
from
fastapi.security
import
OAuth2PasswordBearer
from
nacsos_data.models.users
import
UserModel
...
...
@@ -128,7 +128,7 @@ class UserPermissionChecker:
self
.
permissions
=
[
self
.
permissions
]
async
def
__call__
(
self
,
project_id
:
str
=
Path
(),
x_
project_id
:
str
=
Header
(),
current_user
:
UserModel
=
Depends
(
get_current_active_user
))
->
UserPermissions
:
"""
This function checks the whether a set of required permissions is fulfilled
...
...
@@ -142,7 +142,7 @@ class UserPermissionChecker:
:return: `ProjectPermissions` if permissions are fulfilled, exception otherwise
:raises HTTPException if permissions are not fulfilled
"""
project_permissions
=
await
get_project_permissions_for_user
(
project_id
=
project_id
,
project_permissions
=
await
get_project_permissions_for_user
(
project_id
=
x_
project_id
,
current_user
=
current_user
)
user_permissions
=
UserPermissions
(
user
=
current_user
,
permissions
=
project_permissions
)
if
project_permissions
is
not
None
:
...
...
@@ -155,11 +155,11 @@ class UserPermissionChecker:
if
not
project_permissions
[
permission
]:
raise
HTTPException
(
status_code
=
status
.
HTTP_403_FORBIDDEN
,
detail
=
f
'
User does not have permission
"
{
permission
}
"
for project
"
{
project_id
}
"
.
'
,
detail
=
f
'
User does not have permission
"
{
permission
}
"
for project
"
{
x_
project_id
}
"
.
'
,
)
return
user_permissions
raise
HTTPException
(
status_code
=
status
.
HTTP_403_FORBIDDEN
,
detail
=
f
'
User does not have permission to access project
"
{
project_id
}
"
.
'
,
detail
=
f
'
User does not have permission to access project
"
{
x_
project_id
}
"
.
'
,
)
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