-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HP-2319 | Check allowed data fields when querying profiles #494
Conversation
4b5d514
to
9f33558
Compare
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
9f33558
to
09201eb
Compare
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
09201eb
to
46b3a26
Compare
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
46b3a26
to
4bbdc66
Compare
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code itself seems fine, just a bit confused about the documentation.
profiles/schema.py
Outdated
`allowed_data_fields_map` is a dictionary where the key is the `field_name` of the allowed data field | ||
`allowed_data_fields.json` and the value is an iterable of django model's field names that the `field_name` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean:
`allowed_data_fields_map` is a dictionary where the key is the `field_name` of the allowed data field -> in <-
`allowed_data_fields.json` and the value is an iterable of django model's field names that the `field_name`
profiles/schema.py
Outdated
Mixin class for checking allowed data fields per service. | ||
|
||
`allowed_data_fields_map` is a dictionary where the key is the `field_name` of the allowed data field | ||
`allowed_data_fields.json` and the value is an iterable of django model's field names that the `field_name` | ||
describes. For example, if the `field_name` is `name`, the value could be `("first_name", "last_name")`. | ||
e.g: | ||
allowed_data_fields_map = { | ||
"name": ("first_name", "last_name", "nickname"), | ||
"personalidentitycode": ("national_identification_number",), | ||
"address": ("address", "postal_code", "city", "country_code") | ||
} | ||
|
||
`always_allow_fields`: Since connections are not defined in `allowed_data_fields.json` they should be | ||
defined here. If the field is connection and the node does not inherit this mixin the data will be available | ||
to all services. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... what's allowed_data_fields.json
? 😅 No mention of it in README. It's a bit confusing for me at least.
The docstring doesn't quite click for me; I understand there's a mapping from some file's field name to model fields, but I'm not quite sure what this does. Checks for allowed data fields, which means...? Judging by the tests, it's some sort of an enforced filter for data? Yet there's no allowed_data_fields.json
anywhere, just AllowedDataField
instances. What role does allowed_data_fields.json
play in this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So... what's allowed_data_fields.json? 😅 No mention of it in README. It's a bit confusing for me at least.
Oh that's actually a good question in this github context. Our documentation elsewhere guides about using json file named like that to import the allowed data fields using command set_allowed_data_fields
. Which then creates the AllowedDataField
model instances mapped in the json file.
Checks for allowed data fields, which means...?
We need to check from the AllowedDataField
instances linked to Service
to which fields the service is allowed to access.
c94f001
to
b631a9f
Compare
I made some changes based on the comments and added the feature to be inside a feature flag as discussed irl. |
b631a9f
to
41d0b49
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #494 +/- ##
==========================================
- Coverage 95.56% 95.42% -0.14%
==========================================
Files 207 214 +7
Lines 8222 8616 +394
Branches 991 1037 +46
==========================================
+ Hits 7857 8222 +365
- Misses 279 301 +22
- Partials 86 93 +7 ☔ View full report in Codecov by Sentry. |
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
f4b6ca7
to
2e5f256
Compare
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
2e5f256
to
1f4fd99
Compare
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
1f4fd99
to
193c0e7
Compare
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
193c0e7
to
4284797
Compare
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
Refs HP-2319
4284797
to
d063e0a
Compare
When calling profile any kind there should be checked to which fields the service has access rights by using the allowed data fields. This adds middleware and mixin class for Profile model and VerifiedPersonalInfo models for checking that the queried fields are allowed for the service. Refs HP-2319
Adds setting for allowed data field check named as: ENABLE_ALLOWED_DATA_FIELDS_RESTRICTION The setting defaults False. When False, app logs a warning message when there is a query trying to access a field which is not in service's allowed_data_fields Refs HP-2319
d063e0a
to
95193fe
Compare
Quality Gate passedIssues Measures |
HELSINKI-PROFILE-API branch is deployed to platta: https://helsinki-profile-pr494.api.dev.hel.ninja 🚀🚀🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work! LGTM! 👍
Adds middleware for checking allowed_data_fields for service when querying profiles
Adds feature flag for the feature.
refs HP-2319