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

Provide unique, consistent user identifier for repeated authentication attempts #376

Merged
merged 8 commits into from
Nov 22, 2023

Conversation

Gavinok
Copy link
Contributor

@Gavinok Gavinok commented Nov 20, 2023

When authenticating with VC-AuthN, there are currently two options for generating a subject_identifier for the authenticated user:

  • Using one of the proof-request attributes, if available and configured in the proof-configuration
  • Generating a new identifier for each authentication attempt

The first option is only available IF the VCs used to authenticate provide a unique identifier: this would be configured in the proof-configuration to be used as sub, and would be passed along to the relying party that initiated the authentication request.

The issue with this pattern when integrating VC-AuthN into an AIM system such as Keycloak is that, unless a unique user identifier is generated by VC-AuthN, it will not be possible to associate roles to the user account in the AIM system as every authentication attempt will appear as a new user trying to access the system.

Proposed solution:
Rather than generating a new random user identifier for every authentication attempt, VC-AuthN would generate a consistent user identifier by hashing a canonicalized version of the JSON containing the claims obtained from the proof-request.

Possible library to canonicalize JSON: https://pypi.org/project/canonicaljson/

The underlying Pyop library will generate a new value for the sub if non is provided. A couple of places we could look at plugging-in the generation of the subject identifier value:

  • here to generate the sub BEFORE pyop takes over to generate the token
  • by implementing a new SubjectidentifierFactory matching our criteria and injecting it in the code at the right time (here).

@esune esune added 2.0 Work related to 2.0 release enhancement New feature or request labels Oct 20, 2023
@esune esune changed the title Provide unique user identifier for authentication attempts Provide unique, consistent user identifier for repeated authentication attempts Oct 20, 2023
@Gavinok Gavinok self-assigned this Nov 14, 2023
@Gavinok Gavinok requested a review from esune November 20, 2023 19:51
@coveralls
Copy link

Coverage Status

coverage: 94.413%. remained the same
when pulling 6f4e9a2 on 376-unique-consistent-user-identifier
into ac7c5e7 on main.

@Gavinok Gavinok closed this Nov 20, 2023
@Gavinok Gavinok reopened this Nov 20, 2023
Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

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

Looking good, just a question regarding the new models

oidc-controller/api/core/oidc/issue_token_service.py Outdated Show resolved Hide resolved
@Gavinok Gavinok requested a review from esune November 22, 2023 20:41
Copy link
Member

@esune esune left a comment

Choose a reason for hiding this comment

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

👍🏻

@esune esune merged commit bc862e2 into main Nov 22, 2023
3 checks passed
@esune esune deleted the 376-unique-consistent-user-identifier branch November 22, 2023 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.0 Work related to 2.0 release enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants