-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🗃️ [#4246] Expand AuthInfo model to capture mandate context
* Added fields for the (optional) legal subject (authorizee) * Added fields for the (optional) acting subject (authorizee) * Added check constraints to enforce data integrity * Organized the admin in logical groups The authentication context data model identifies two parties: the representee and the authorizee. There is always an authorizee - it *can* be the same actor as the representee if no mandate is in involved. An authorizee has two aspects: legal subject and acting subject. There is always a legal subject. If no acting subject is provided, it is inferred from the legal subject. So, a simple DigiD login in this model is represented by a legal subject authorizee of type BSN. We still keep storing this data in the attribute + value fields, but in the event of a mandate, we will store the additional information for the legal/acting subject.
- Loading branch information
1 parent
3e8f3cb
commit ff451e3
Showing
4 changed files
with
285 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
src/openforms/authentication/migrations/0002_add_authentication_context_mandate_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Generated by Django 4.2.11 on 2024-05-31 07:13 | ||
|
||
from django.db import migrations, models | ||
import openforms.authentication.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("of_authentication", "0001_initial_to_openforms_v230"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="authinfo", | ||
name="acting_subject_identifier_type", | ||
field=models.CharField( | ||
blank=True, | ||
choices=[("opaque", "Opaque")], | ||
help_text="The identifier type determines how to interpret the identifier value.", | ||
max_length=50, | ||
verbose_name="acting subject identifier type", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="authinfo", | ||
name="acting_subject_identifier_value", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="(Contextually) unique identifier for the acting subject.", | ||
max_length=250, | ||
verbose_name="acting subject identifier", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="authinfo", | ||
name="legal_subject_identifier_type", | ||
field=models.CharField( | ||
blank=True, | ||
choices=[("bsn", "BSN"), ("kvk", "KvK number"), ("rsin", "RSIN")], | ||
help_text="The identifier type determines how to interpret the identifier value.", | ||
max_length=50, | ||
verbose_name="legal subject identifier type", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="authinfo", | ||
name="legal_subject_identifier_value", | ||
field=models.CharField( | ||
blank=True, | ||
help_text="(Contextually) unique identifier for the legal subject.", | ||
max_length=250, | ||
verbose_name="legal subject identifier", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="authinfo", | ||
name="mandate_context", | ||
field=models.JSONField( | ||
blank=True, | ||
help_text="If a mandate is in play, then the mandate context must be provided. The details are tracked here, in line with the authentication context data JSON schema definition.", | ||
null=True, | ||
verbose_name="mandate context", | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="authinfo", | ||
constraint=openforms.authentication.models.ConjointConstraint( | ||
fields=( | ||
"acting_subject_identifier_type", | ||
"acting_subject_identifier_value", | ||
), | ||
name="acting_subject_integrity", | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="authinfo", | ||
constraint=openforms.authentication.models.ConjointConstraint( | ||
fields=( | ||
"legal_subject_identifier_type", | ||
"legal_subject_identifier_value", | ||
), | ||
name="legal_subject_integrity", | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="authinfo", | ||
constraint=models.CheckConstraint( | ||
check=models.Q( | ||
models.Q( | ||
("legal_subject_identifier_value", ""), | ||
("mandate_context__isnull", True), | ||
), | ||
models.Q( | ||
models.Q(("legal_subject_identifier_value", ""), _negated=True), | ||
("mandate_context__isnull", False), | ||
), | ||
_connector="OR", | ||
), | ||
name="mandate_context_not_null", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters