Skip to content
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

Add registration variables for auth context (objects API registration v2) #4449

Merged

Conversation

sergei-maertens
Copy link
Member

@sergei-maertens sergei-maertens commented Jun 27, 2024

Partly closes #4246

Changes

  • Added registration variable for full auth context data
  • Added registration variables for the nested properties inside (until we can handle complex schema's with better typing support)

Checklist

Check off the items that are completed or not relevant.

  • Impact on features

    • Checked copying a form
    • Checked import/export of a form
    • Config checks in the configuration overview admin page
    • Problem detection in the admin email digest is handled
  • Release management

    • I have labelled the PR as "needs-backport" accordingly
  • I have updated the translations assets (you do NOT need to provide translations)

    • Ran ./bin/makemessages_js.sh
    • Ran ./bin/compilemessages_js.sh
  • Commit hygiene

    • Commit messages refer to the relevant Github issue
    • Commit messages explain the "why" of change, not the how

@sergei-maertens sergei-maertens force-pushed the feature/4246-register-auth-context-in-objects-api-v2 branch 2 times, most recently from 141e98c to 144be1c Compare June 28, 2024 11:06
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.57%. Comparing base (f96a10c) to head (e1e6a11).
Report is 592 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4449      +/-   ##
==========================================
+ Coverage   96.51%   96.57%   +0.06%     
==========================================
  Files         720      720              
  Lines       23899    24000     +101     
  Branches     2817     2843      +26     
==========================================
+ Hits        23065    23179     +114     
+ Misses        566      559       -7     
+ Partials      268      262       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sergei-maertens sergei-maertens force-pushed the feature/4246-register-auth-context-in-objects-api-v2 branch from 422518c to 62f2041 Compare June 28, 2024 15:08
@sergei-maertens sergei-maertens changed the title 🚧 [#4246] Add registration variables for auth context Add registration variables for auth context (objects API registration v2) Jun 28, 2024
@sergei-maertens sergei-maertens requested a review from Viicos June 28, 2024 16:05
@sergei-maertens sergei-maertens marked this pull request as ready for review June 28, 2024 16:05
@sergei-maertens sergei-maertens force-pushed the feature/4246-register-auth-context-in-objects-api-v2 branch from a9da7c3 to a5ad075 Compare July 1, 2024 07:00
@sergei-maertens sergei-maertens marked this pull request as draft July 1, 2024 07:01
@sergei-maertens sergei-maertens force-pushed the feature/4246-register-auth-context-in-objects-api-v2 branch 3 times, most recently from 4c19b80 to a8b802f Compare July 1, 2024 10:18
@sergei-maertens sergei-maertens requested a review from Viicos July 1, 2024 12:37
@sergei-maertens sergei-maertens marked this pull request as ready for review July 1, 2024 12:37
@sergei-maertens sergei-maertens requested a review from stevenbal July 1, 2024 12:39
@sergei-maertens
Copy link
Member Author

@stevenbal can you review the documentation changes, as they're in Dutch? 😬

Copy link
Contributor

@stevenbal stevenbal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments regarding the docs

docs/manual/forms/variables.rst Outdated Show resolved Hide resolved
docs/manual/forms/variables.rst Show resolved Hide resolved
docs/manual/forms/variables.rst Outdated Show resolved Hide resolved
Er zijn geen plannen om deze laatste te verwijderen.

De variabele bevat een bak aan informatie, gestructureerd volgens het
authenticatiecontextdatamodel (TODO: add link). De structuur is als volgt:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this be added later?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, though I need to check if I can share those gitbook links and people outside of our team probably need to review/tweak the content, so I don't think we should block this PR on that TODO.

Comment on lines +122 to +134
Merk op dat niet alle attributen aanwezig zijn, dit hangt af van het inlogmiddel (
DigiD, eHerkenning) en of er wel/niet sprake is van een machtiging én de soort
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Merk op dat niet alle attributen aanwezig zijn, dit hangt af van het inlogmiddel (
DigiD, eHerkenning) en of er wel/niet sprake is van een machtiging én de soort
Merk op dat niet alle attributen aanwezig zijn, dit hangt af van het inlogmiddel (DigiD, eHerkenning) en of er wel/niet sprake is van een machtiging én de soort

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the difference or mistake 😅

De onderdelen van deze structuur worden ook als individuele variabelen aangeboden:

``auth_context_source``
Middel van inloggen: de waarde is ``"digid"`` of ``eherkenning``, of een lege string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Middel van inloggen: de waarde is ``"digid"`` of ``eherkenning``, of een lege string
Middel van inloggen: de waarde is ``"digid"`` of ``"eherkenning"``, of een lege string

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the quotes on digid instead to make it consistent with other example values.

Comment on lines +161 to +175
``auth_context_acting_subject_identifier_type``
In de praktijk zal de waarde altijd ``opaque`` of leeg zijn. Geeft aan hoe de
identificatie van de handelende persoon ("de persoon aan de knoppen")
geïnterpreteerd moet worden.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this means, does this mean that the value literally is "opaque"? Is this like a convenience variable to not have to check if machtigen is used when determining the acting subjects auth info?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the identifier type value is indeed "opaque", as opposed to "bsn" or "kvkNummer" (or the future "RSIN").

Currently it's the only possible type, but in the future more types could be possible (this could for example be used for a registrator at the service desk too, at some point). It basically means that you have zero guarantees about the meaning of the identifier value except that it's a value tied to a particular staff member. It could look like a BSN, but if you use it to consult the BRP, it may sometimes work, it will most likely not. It is not expected to be decrypted.

Comment on lines +699 to +701
Zie :ref:`manual_forms_variables_auth_context` voor een voorbeeld van de structuur, en
een overzicht van alle "onderdelen" waaruit de ``auth_context`` variabele bestaat. Je
kan deze allemaal individueel gebruiken in de sjablonen.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a preference when it comes to using these variables and does it make a difference (aside from number of characters), e.g. auth_context_loa vs auth_context.levelOfAssurance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is a slight difference in that the static variables will always yield a string, while missing other attributes could theoretically return None and template authors would have to check for that.

In practice, I think the DTL fallback to empty string will result in the same outcome (most of the time).

@@ -26,6 +26,17 @@ class Registry(BaseRegistry[BaseStaticVariable]):
"""The Objects API registration variables registry."""


@register("public_reference")
class PublicReference(BaseStaticVariable):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this variable mentioned in the Vaste variabelen section, should this be mentioned there? Or is this mentioned in a specific page for Objects API registration?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not a static variable, but a registration variable and visible in the UI when you select an objects API registration backend :) and there the title + type are displayed (it's "self-documenting" via the registry).

Comment on lines -339 to -343
"auth_context": (
submission.auth_info.to_auth_context_data()
if submission.is_authenticated
else None
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my understanding, this is no longer needed because the auth_context variable is always available for the registration backend now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, precisely. I assumed wrongly that the auth_context should be provided only as objects registration variables, but it acts at the same level as the existing auth static variable, so we can expose it directly to all registration backends automatically :)

@sergei-maertens sergei-maertens force-pushed the feature/4246-register-auth-context-in-objects-api-v2 branch from 66ce62a to e92ed0d Compare July 1, 2024 16:11
This was reported verbally at some point by DH when they want to use
the 'objects API contract' feature.
Tests for the happy flow where all information is available.
We notice now logic is written based on auth.plugin rather than
auth.attribute, which makes using a different auth backend providing
the same attribute hard.

Instead, provide the auth_type variable to have a better name, and
update the docs to favour this one.
Instead of only exposing them as objects API registration variables.

These variables are available at all times, after authenticating, so
they belong in the static variables.
The static variables can also be used as-is in the templates, no special
treatment is required. The documentation is updated accordingly, with a
pointer to the static variables section that describes the
authentication context data.
@sergei-maertens sergei-maertens force-pushed the feature/4246-register-auth-context-in-objects-api-v2 branch 3 times, most recently from ba61561 to dc23c68 Compare July 2, 2024 07:52
* Use nicer way to check if a registrator is present or not
* Documentation fixes
@sergei-maertens sergei-maertens force-pushed the feature/4246-register-auth-context-in-objects-api-v2 branch from dc23c68 to e1e6a11 Compare July 2, 2024 08:02
@stevenbal stevenbal self-requested a review July 2, 2024 08:30
@sergei-maertens sergei-maertens merged commit 5c7c538 into master Jul 2, 2024
30 checks passed
@sergei-maertens sergei-maertens deleted the feature/4246-register-auth-context-in-objects-api-v2 branch July 2, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Capture authentication context data
3 participants