Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
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
Container Registry
Model registry
Operate
Environments
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
AURA
steering
Commits
e5c427a8
Verified
Commit
e5c427a8
authored
4 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: redact sensitive information for unauthenticated requests
parent
de317bac
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
program/serializers.py
+30
-0
30 additions, 0 deletions
program/serializers.py
with
30 additions
and
0 deletions
program/serializers.py
+
30
−
0
View file @
e5c427a8
...
...
@@ -114,6 +114,12 @@ class CBASerializer(serializers.ModelSerializer):
"
user_token
"
,
)
+
read_only_fields
def
to_representation
(
self
,
instance
):
if
not
self
.
parent
.
context
.
get
(
"
request
"
).
user
.
is_authenticated
:
return
None
return
super
().
to_representation
(
instance
)
class
UserSerializer
(
serializers
.
ModelSerializer
):
is_privileged
=
serializers
.
SerializerMethodField
()
...
...
@@ -401,6 +407,14 @@ class ProfileSerializer(serializers.ModelSerializer):
"
owner_ids
"
,
)
+
read_only_fields
def
to_representation
(
self
,
instance
):
representation
=
super
().
to_representation
(
instance
)
if
not
self
.
context
.
get
(
"
request
"
).
user
.
is_authenticated
:
del
representation
[
"
email
"
]
return
representation
def
create
(
self
,
validated_data
):
"""
Create and return a new Profile instance, given the validated data.
...
...
@@ -633,6 +647,14 @@ class ShowSerializer(serializers.HyperlinkedModelSerializer):
return
super
().
to_internal_value
(
data
)
def
to_representation
(
self
,
instance
):
representation
=
super
().
to_representation
(
instance
)
if
not
self
.
context
.
get
(
"
request
"
).
user
.
is_authenticated
:
del
representation
[
"
email
"
]
return
representation
def
create
(
self
,
validated_data
):
"""
Create and return a new Show instance, given the validated data.
...
...
@@ -995,6 +1017,14 @@ class TimeSlotSerializer(serializers.ModelSerializer):
def
get_end
(
obj
)
->
datetime
:
return
obj
.
end
.
astimezone
(
tz
=
ZoneInfo
(
settings
.
TIME_ZONE
))
def
to_representation
(
self
,
instance
):
representation
=
super
().
to_representation
(
instance
)
if
not
self
.
context
.
get
(
"
request
"
).
user
.
is_authenticated
:
del
representation
[
"
memo
"
]
return
representation
def
update
(
self
,
instance
,
validated_data
):
"""
Update and return an existing Show instance, given the validated data.
"""
...
...
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