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

feat(auth-admin): system national ids lookup #16568

Merged
merged 15 commits into from
Nov 7, 2024

Conversation

magnearun
Copy link
Contributor

@magnearun magnearun commented Oct 25, 2024

What

Use NationalRegistryV3 for IdentityModule

Why

V3 can look up system nationalId, V2 can not.

Screenshots / Gifs

Attach Screenshots / Gifs to help reviewers understand the scope of the pull request

Checklist:

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Formatting passes locally with my changes
  • I have rebased against main before asking for a review

Summary by CodeRabbit

  • New Features

    • Integrated National Registry V3 API for enhanced data retrieval capabilities.
  • Bug Fixes

    • Updated identity retrieval methods to align with the new API structure, improving data accuracy.
  • Documentation

    • Adjusted mappings for identity properties to reflect changes in the data structure from the National Registry V3.

Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes in this pull request involve updates to the integration of the National Registry API within the application. Specifically, a new client configuration for NationalRegistryV3ClientConfig is introduced in the app.module.ts file. The IdentityClientModule is modified to use NationalRegistryV3ClientModule instead of its predecessor. Additionally, the IdentityClientService class is updated to replace the old service with NationalRegistryV3ClientService, altering method calls and the structure of the data retrieved.

Changes

File Path Change Summary
apps/application-system/api/src/app/app.module.ts Added import for NationalRegistryV3ClientConfig in ConfigModule.forRoot imports array.
libs/clients/identity/src/lib/identityClient.module.ts Updated import from NationalRegistryClientModule to NationalRegistryV3ClientModule.
libs/clients/identity/src/lib/identityClient.service.ts Replaced NationalRegistryClientService with NationalRegistryV3ClientService, updated method calls, and changed data mapping.

Possibly related PRs

Suggested labels

automerge


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@datadog-island-is
Copy link

datadog-island-is bot commented Oct 25, 2024

Datadog Report

All test runs 88b5015 🔗

6 Total Test Services: 0 Failed, 6 Passed
🔻 Test Sessions change in coverage: 1 decreased (-0.1%), 1 increased (+0.01%), 13 no change

Test Services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
api 0 0 0 4 0 2.32s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 9.89s 1 no change Link
application-system-api 0 0 0 120 2 3m 21.96s 1 decreased (-0.1%) Link
application-template-api-modules 0 0 0 123 0 2m 36.65s 1 increased (+0.01%) Link
application-templates-public-debt-payment-plan 0 0 0 3 0 11.6s 1 no change Link
application-ui-shell 0 0 0 74 0 36.73s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (1)

  • application-system-api - jest 36.78% (-0.1%) - Details

Copy link

codecov bot commented Oct 25, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 36.58%. Comparing base (3856383) to head (6ce53bb).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...clients/identity/src/lib/identityClient.service.ts 33.33% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #16568      +/-   ##
==========================================
+ Coverage   36.53%   36.58%   +0.04%     
==========================================
  Files        6890     6880      -10     
  Lines      143638   143200     -438     
  Branches    40924    40781     -143     
==========================================
- Hits        52481    52384      -97     
+ Misses      91157    90816     -341     
Flag Coverage Δ
api 3.37% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
application-system-api 41.12% <50.00%> (+0.01%) ⬆️
application-template-api-modules 27.68% <ø> (-0.02%) ⬇️
application-ui-shell 20.86% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
apps/application-system/api/src/app/app.module.ts 100.00% <100.00%> (ø)
.../clients/identity/src/lib/identityClient.module.ts 100.00% <100.00%> (ø)
...clients/identity/src/lib/identityClient.service.ts 25.64% <33.33%> (-1.39%) ⬇️

... and 28 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0f7cb58...6ce53bb. Read the comment docs.

@magnearun magnearun marked this pull request as ready for review October 28, 2024 14:15
@magnearun magnearun requested review from a team as code owners October 28, 2024 14:15
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 443e724 and 2f45a8a.

📒 Files selected for processing (3)
  • apps/application-system/api/src/app/app.module.ts (2 hunks)
  • libs/clients/identity/src/lib/identityClient.module.ts (1 hunks)
  • libs/clients/identity/src/lib/identityClient.service.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
apps/application-system/api/src/app/app.module.ts (1)

Pattern apps/**/*: "Confirm that the code adheres to the following:

  • NextJS best practices, including file structure, API routes, and static generation methods.
  • Efficient state management and server-side rendering techniques.
  • Optimal use of TypeScript for component and utility type safety."
libs/clients/identity/src/lib/identityClient.module.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
libs/clients/identity/src/lib/identityClient.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (6)
libs/clients/identity/src/lib/identityClient.module.ts (2)

4-4: Verify the V3 client compatibility across the application.

The upgrade to NationalRegistryV3 client is aligned with the PR objectives to enable system national IDs lookup.

Let's verify the impact of this upgrade:

#!/bin/bash
# Check for any remaining V2 imports that might need updating
rg -l "NationalRegistryClientModule" --type ts

# Check for any direct usage of V2 types or services that might need migration
rg -l "NationalRegistryClientService" --type ts

9-9: LGTM! Module configuration properly updated.

The module imports are correctly configured with the V3 client while maintaining the CompanyRegistryClientModule integration.

Let's verify the module is properly exported for reuse:

✅ Verification successful

Module is properly exported and used correctly across the codebase

The verification confirms that:

  • The module is correctly exported from its source file
  • The module is properly imported and used in several domain modules:
    • User Profile module
    • Identity module
    • Auth module
    • Template API modules
  • No circular dependencies were detected
  • The module exports its service as intended
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for module usage across NextJS apps
rg -l "IdentityClientModule" --type ts

# Verify no circular dependencies were introduced
ast-grep --pattern 'import { $_ } from "./identityClient.module"'

Length of output: 506


Script:

#!/bin/bash
# Check if the module is properly exported from the barrel file
rg -l "export.*IdentityClientModule" --type ts

# Check the module's exports
cat libs/clients/identity/src/lib/identityClient.module.ts

# Check for any potential circular dependencies with corrected syntax
ast-grep --pattern 'import { $_ } from "./identityClient.module.ts"'

# Verify the module usage pattern in dependent files
rg "IdentityClientModule" -A 2 -B 2 --type ts

Length of output: 5251

apps/application-system/api/src/app/app.module.ts (2)

64-64: LGTM! Clean import statement.

The import follows the established pattern and is correctly placed with other client imports.


125-125: Verify if both National Registry versions are needed.

Both NationalRegistryClientConfig (V2) and NationalRegistryV3ClientConfig are loaded in the ConfigModule. Please verify if this is intentional for a gradual migration or if V2 should be removed.

Let's check for any remaining V2 dependencies:

✅ Verification successful

The search results show extensive usage of National Registry V2 across multiple applications and services. Let me verify if V3 is also actively used:


Both National Registry versions are currently needed - gradual migration in progress

The search results confirm that both versions are actively used in the codebase:

  • V2 is still heavily used in auth-related services, delegations, and various application templates
  • V3 is being adopted in newer services and there's an ongoing migration, evidenced by:
    • Feature flag shouldAuthIdsApiUseNationalRegistryV3 controlling the migration
    • Comment in user-profile.controller.spec.ts: "TODO: Delete this file when shouldAuthIdsApiUseNationalRegistryV3 feature flag is removed"
    • Presence of both V2 and V3 implementations in several modules, particularly in auth services

The dual presence is intentional for a controlled migration strategy.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for remaining dependencies on National Registry V2

# Test 1: Search for imports of V2 client
echo "Checking for V2 imports..."
rg -l "from.*@island.is/clients/national-registry-v2"

# Test 2: Search for usage of V2 client service
echo "Checking for V2 service usage..."
rg "NationalRegistryClientService"

Length of output: 19006


Script:

#!/bin/bash
# Check for V3 usage
echo "Checking for V3 imports and usage..."
rg -l "from.*@island.is/clients/national-registry-v3"

echo "Checking for V3 service usage..."
rg "NationalRegistryV3"

Length of output: 16838

libs/clients/identity/src/lib/identityClient.service.ts (2)

5-5: Import the new National Registry V3 Client Service

The import statement correctly brings in NationalRegistryV3ClientService from the updated client package.


80-80: Ensure proper error handling with the new service method

The method getAllDataIndividual from NationalRegistryV3ClientService is called to retrieve person data. Verify that this method handles errors appropriately and that any exceptions are correctly propagated or caught, especially if the behavior differs from the previous client service.

libs/clients/identity/src/lib/identityClient.service.ts Outdated Show resolved Hide resolved
libs/clients/identity/src/lib/identityClient.service.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 2f45a8a and 7e435a3.

📒 Files selected for processing (1)
  • libs/clients/identity/src/lib/identityClient.service.ts (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/clients/identity/src/lib/identityClient.service.ts (1)

Pattern libs/**/*: "Confirm that the code adheres to the following:

  • Reusability of components and hooks across different NextJS apps.
  • TypeScript usage for defining props and exporting types.
  • Effective tree-shaking and bundling practices."
🔇 Additional comments (3)
libs/clients/identity/src/lib/identityClient.service.ts (3)

5-5: LGTM: Import statement follows best practices

The import statement correctly imports the new V3 client service and follows TypeScript module import conventions.


17-17: LGTM: Clean dependency injection

The constructor properly injects the V3 client service with a clear and descriptive parameter name.


80-82: Consider performance implications of getAllDataIndividual

The method name suggests it fetches all available data for an individual, which might be more than what's needed for identity verification. Consider using a more specific API endpoint if available to optimize payload size.

Copy link
Member

@eirikurn eirikurn left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@magnearun magnearun added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Oct 31, 2024
@magnearun magnearun removed the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Nov 4, 2024
@magnearun magnearun added the deprecated:automerge (Disabled) Merge this PR as soon as all checks pass label Nov 7, 2024
Copy link
Member

@HjorturJ HjorturJ left a comment

Choose a reason for hiding this comment

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

LGTM

@kodiakhq kodiakhq bot merged commit aaebdbf into main Nov 7, 2024
38 checks passed
@kodiakhq kodiakhq bot deleted the feat/system-nationalIds-lookup branch November 7, 2024 10:37
robertaandersen pushed a commit that referenced this pull request Nov 11, 2024
* use national-registry-v3 in identity lookup

* Adds missing NationalRegistryV3ClientConfig

* chore: nx format:write update dirty files

* rename service and small type fix

---------

Co-authored-by: andes-it <[email protected]>
jonnigs pushed a commit that referenced this pull request Nov 12, 2024
* use national-registry-v3 in identity lookup

* Adds missing NationalRegistryV3ClientConfig

* chore: nx format:write update dirty files

* rename service and small type fix

---------

Co-authored-by: andes-it <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated:automerge (Disabled) Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants