Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DataCatalog
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eFlows4HPC WP2
DataCatalog
Commits
3cd0607c
Commit
3cd0607c
authored
3 years ago
by
Christian Boettcher
Browse files
Options
Downloads
Patches
Plain Diff
add logging, send seret values via body and not query parameter
parent
396468e4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
apiserver/main.py
+21
-20
21 additions, 20 deletions
apiserver/main.py
with
21 additions
and
20 deletions
apiserver/main.py
+
21
−
20
View file @
3cd0607c
...
...
@@ -15,6 +15,8 @@ from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from
pydantic
import
UUID4
from
starlette.responses
import
RedirectResponse
from
apiserver.security.user
import
Secret
from
.config
import
ApiserverSettings
from
.security
import
(
ACCESS_TOKEN_EXPIRES_MINUTES
,
JsonDBInterface
,
Token
,
User
,
authenticate_user
,
create_access_token
,
...
...
@@ -140,7 +142,7 @@ async def update_specific_dataset(location_data_type: LocationDataType,
@app.delete
(
"
/{location_data_type}/{dataset_id}
"
)
async
def
delete_specific_dataset
(
location_data_type
:
LocationDataType
,
dataset_id
:
UUID4
,
user
:
st
r
=
Depends
(
my_user
)):
user
:
Use
r
=
Depends
(
my_user
)):
"""
delete a specific dataset
"""
# TODO: 404 is the right answer? 204 could also be the right one
log
.
debug
(
"
Authenticed User:
'
%s
'
deleted /%s/%s
"
,
user
.
username
,
location_data_type
.
value
,
dataset_id
)
...
...
@@ -149,10 +151,10 @@ async def delete_specific_dataset(location_data_type: LocationDataType,
@app.get
(
"
/{location_data_type}/{dataset_id}/secrets
"
)
async
def
list_dataset_secrets
(
location_data_type
:
LocationDataType
,
dataset_id
:
UUID4
,
user
:
st
r
=
Depends
(
my_user
)):
user
:
Use
r
=
Depends
(
my_user
)):
"""
list the secrets of a specific dataset
"""
# TODO log
if
userdb
.
get
(
user
).
has_secrets_access
:
if
user
.
has_secrets_access
:
log
.
debug
(
"
Authenticed User:
'
%s
'
listed the secrets of /%s/%s
"
,
user
.
username
,
location_data_type
.
value
,
dataset_id
)
return
adapter
.
list_secrets
(
location_data_type
,
dataset_id
,
user
)
else
:
raise
HTTPException
(
403
)
...
...
@@ -161,24 +163,23 @@ async def list_dataset_secrets(location_data_type: LocationDataType,
async
def
get_dataset_secret
(
location_data_type
:
LocationDataType
,
dataset_id
:
UUID4
,
key
:
str
,
user
:
st
r
=
Depends
(
my_user
)):
"""
get the secret
s
of a specific dataset
"""
# TODO log
if
userdb
.
get
(
user
).
has_secrets_access
:
user
:
Use
r
=
Depends
(
my_user
)):
"""
get the secret of a specific dataset
"""
if
user
.
has_secrets_access
:
log
.
debug
(
"
Authenticed User:
'
%s
'
listed the secret %s of /%s/%s
"
,
user
.
username
,
key
,
location_data_type
.
value
,
dataset_id
)
return
adapter
.
get_secret
(
location_data_type
,
dataset_id
,
key
,
user
)
else
:
raise
HTTPException
(
403
)
@app.p
u
t
(
"
/{location_data_type}/{dataset_id}/secrets
/{key}
"
)
@app.p
os
t
(
"
/{location_data_type}/{dataset_id}/secrets
"
)
async
def
add_update_dataset_secret
(
location_data_type
:
LocationDataType
,
dataset_id
:
UUID4
,
key
:
str
,
value
:
str
,
user
:
str
=
Depends
(
my_user
)):
"""
get the secrets of a specific dataset
"""
# TODO log
if
userdb
.
get
(
user
).
has_secrets_access
:
return
adapter
.
add_update_secret
(
location_data_type
,
dataset_id
,
key
,
value
,
user
)
secret
:
Secret
,
user
:
User
=
Depends
(
my_user
)):
"""
add or update a secrets to a specific dataset
"""
if
user
.
has_secrets_access
:
log
.
debug
(
"
Authenticed User:
'
%s
'
added or updated the secret %s of /%s/%s
"
,
user
.
username
,
secret
.
key
,
location_data_type
.
value
,
dataset_id
)
return
adapter
.
add_update_secret
(
location_data_type
,
dataset_id
,
secret
.
key
,
secret
.
secret
,
user
)
else
:
raise
HTTPException
(
403
)
...
...
@@ -186,10 +187,10 @@ async def add_update_dataset_secret(location_data_type: LocationDataType,
async
def
get_dataset_secrets
(
location_data_type
:
LocationDataType
,
dataset_id
:
UUID4
,
key
:
str
,
user
:
st
r
=
Depends
(
my_user
)):
"""
delete a secret
o
f a specific dataset
"""
# TODO log
if
userdb
.
get
(
user
).
has_secrets_access
:
user
:
Use
r
=
Depends
(
my_user
)):
"""
delete a secret f
rom
a specific dataset
"""
if
user
.
has_secrets_access
:
log
.
debug
(
"
Authenticed User:
'
%s
'
deleted the secret %s from /%s/%s
"
,
user
.
username
,
key
,
location_data_type
.
value
,
dataset_id
)
return
adapter
.
delete_secret
(
location_data_type
,
dataset_id
,
key
,
user
)
else
:
raise
HTTPException
(
403
)
...
...
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