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

fix(auth-api-lib): Migration bff admin portal back_channel_logout_uri #16710

Merged
merged 4 commits into from
Nov 4, 2024

Conversation

snaerseljan
Copy link
Contributor

@snaerseljan snaerseljan commented Nov 4, 2024

IDS db migration

What

Migration to update bff admin portal client back_channel_logout_uri

Why

This cant be done in the ids admin

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

    • Implemented a database migration to update the logout URI for the client @admin.island.is/bff-stjornbord.
  • Bug Fixes

    • Added the ability to revert the logout URI change if necessary, ensuring database integrity.

@snaerseljan snaerseljan requested review from a team as code owners November 4, 2024 14:51
Copy link
Contributor

coderabbitai bot commented Nov 4, 2024

Walkthrough

This pull request introduces a new migration file for updating the database schema related to the "client" table. It includes two asynchronous functions: up, which sets the back_channel_logout_uri for a specific client, and down, which reverts this change by nullifying the back_channel_logout_uri. This migration facilitates the application and reversion of changes, ensuring database integrity.

Changes

File Change Summary
libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js Added new migration file with up and down functions for updating back_channel_logout_uri for a specific client.

Suggested labels

automerge

Suggested reviewers

  • thordurhhh
  • eirikurn

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.

@snaerseljan snaerseljan changed the title fix(auth-api-lib): Migration to update bff admin portal back_channel_… fix(auth-api-lib): Migration bff admin portal back_channel_logout_uri Nov 4, 2024
@snaerseljan snaerseljan added automerge Merge this PR as soon as all checks pass and removed automerge Merge this PR as soon as all checks pass labels Nov 4, 2024
Copy link
Member

@GunnlaugurG GunnlaugurG left a comment

Choose a reason for hiding this comment

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

💯

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

🧹 Outside diff range and nitpick comments (2)
libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js (2)

1-1: Remove redundant 'use strict' directive

The 'use strict' directive is unnecessary in ES modules as they are automatically in strict mode.

-'use strict'
🧰 Tools
🪛 Biome

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)


1-27: Consider adding back_channel_logout_uri management to admin interface

While this migration addresses the immediate need, consider adding the capability to manage back_channel_logout_uri through the IDS admin interface to avoid future migrations for similar changes.

🧰 Tools
🪛 Biome

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 66dd836 and 076a43d.

📒 Files selected for processing (1)
  • libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js (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."
🪛 Biome
libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

coderabbitai[bot]
coderabbitai bot previously requested changes Nov 4, 2024
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

🧹 Outside diff range and nitpick comments (1)
libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js (1)

1-2: Remove redundant 'use strict' directive

The 'use strict' directive is unnecessary as JavaScript modules are automatically in strict mode.

-'use strict'
-
🧰 Tools
🪛 Biome

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 66dd836 and 076a43d.

📒 Files selected for processing (1)
  • libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js (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."
🪛 Biome
libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

🔇 Additional comments (2)
libs/auth-api-lib/migrations/20241104143212-add_back_channel_logout_uri_to_client_bff-stjornbord.js (2)

3-4: LGTM! Good use of constant for client ID

Using a constant for the client ID improves maintainability and reduces the risk of typos.


1-27: Verify client existence before applying migration

Let's verify that the client exists in the database before applying this migration.

✅ Verification successful

Let me analyze the database schema and seed data to verify if this client is properly initialized before the migration.


Client ID exists in configuration across environments

Based on the search results, the client ID @admin.island.is/bff-stjornbord is properly configured in all environment values files (dev, staging, and production). This indicates the client is an expected part of the system setup. While we cannot directly verify the database state, the consistent presence in configuration files across all environments provides reasonable confidence that this is a valid client ID for the migration.

  • Found in:
    • charts/islandis/values.dev.yaml
    • charts/islandis/values.staging.yaml
    • charts/islandis/values.prod.yaml
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for references to the BFF admin portal client ID
# to ensure it exists in the codebase

# Look for client ID references in SQL files and migrations
rg -t sql -t js "@admin.island.is/bff-stjornbord"

# Look for client configuration
fd -e json -e yaml -e config | xargs rg "@admin.island.is/bff-stjornbord"

Length of output: 588


Script:

#!/bin/bash
# Search for any seed data or initial client setup in auth-api-lib
fd -e sql -e js | rg -l "client" | xargs rg -A 5 -B 5 "@admin.island.is/bff-stjornbord"

# Look for client registration or setup code
ast-grep --pattern 'INSERT INTO "client"'
ast-grep --pattern 'CREATE TABLE "client"'

Length of output: 222

🧰 Tools
🪛 Biome

[error] 1-1: Redundant use strict directive.

The entire contents of JavaScript modules are automatically in strict mode, with no statement needed to initiate it.
Safe fix: Remove the redundant use strict directive.

(lint/suspicious/noRedundantUseStrict)

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 4, 2024

Datadog Report

All test runs 6b5e3c9 🔗

70 Total Test Services: 0 Failed, 67 Passed
🔻 Test Sessions change in coverage: 2 decreased, 2 increased, 196 no change

Test Services
This report shows up to 10 services
Service Name Failed Known Flaky New Flaky Passed Skipped Total Time Code Coverage Change Test Service View
air-discount-scheme-backend 0 0 0 82 0 32.26s 1 no change Link
air-discount-scheme-web 0 0 0 2 0 6.98s 1 no change Link
api 0 0 0 4 0 2.31s N/A Link
api-domains-air-discount-scheme 0 0 0 6 0 15.61s 1 no change Link
api-domains-assets 0 0 0 3 0 9.46s 1 no change Link
api-domains-auth-admin 0 0 0 18 0 10.11s N/A Link
api-domains-communications 0 0 0 5 0 27.11s 1 no change Link
api-domains-criminal-record 0 0 0 5 0 8.19s 1 no change Link
api-domains-driving-license 0 0 0 23 0 27.38s N/A Link
api-domains-education 0 0 0 8 0 17.33s 1 no change Link

🔻 Code Coverage Decreases vs Default Branch (2)

  • application-core - jest 79.62% (-0.1%) - Details
  • application-template-api-modules - jest 30.04% (-0.01%) - Details

@snaerseljan snaerseljan added the automerge Merge this PR as soon as all checks pass label Nov 4, 2024
Copy link

codecov bot commented Nov 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.55%. Comparing base (8471bef) to head (f8c47f1).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #16710   +/-   ##
=======================================
  Coverage   36.55%   36.55%           
=======================================
  Files        6883     6883           
  Lines      143432   143432           
  Branches    40880    40880           
=======================================
+ Hits        52433    52435    +2     
+ Misses      90999    90997    -2     
Flag Coverage Δ
air-discount-scheme-backend 54.03% <ø> (ø)
air-discount-scheme-web 0.00% <ø> (ø)
api 3.37% <ø> (ø)
api-domains-air-discount-scheme 36.96% <ø> (ø)
api-domains-assets 26.71% <ø> (ø)
api-domains-auth-admin 48.48% <ø> (ø)
api-domains-communications 39.80% <ø> (ø)
api-domains-criminal-record 47.40% <ø> (ø)
api-domains-driving-license 44.44% <ø> (ø)
api-domains-education 31.20% <ø> (ø)
api-domains-health-insurance 34.23% <ø> (ø)
api-domains-mortgage-certificate 34.63% <ø> (ø)
api-domains-payment-schedule 41.19% <ø> (ø)
application-api-files 56.49% <ø> (ø)
application-core 71.85% <ø> (-0.09%) ⬇️
application-system-api 41.30% <ø> (ø)
application-template-api-modules 27.79% <ø> (+0.01%) ⬆️
application-templates-accident-notification 29.21% <ø> (ø)
application-templates-car-recycling 3.12% <ø> (ø)
application-templates-criminal-record 26.26% <ø> (ø)
application-templates-driving-license 18.40% <ø> (ø)
application-templates-estate 12.18% <ø> (ø)
application-templates-example-payment 25.17% <ø> (ø)
application-templates-financial-aid 15.56% <ø> (ø)
application-templates-general-petition 23.40% <ø> (ø)
application-templates-inheritance-report 6.52% <ø> (ø)
application-templates-marriage-conditions 15.20% <ø> (ø)
application-templates-mortgage-certificate 43.52% <ø> (ø)
application-templates-parental-leave 29.93% <ø> (ø)
application-types 6.62% <ø> (ø)
application-ui-components 1.27% <ø> (ø)
application-ui-shell 20.86% <ø> (ø)
clients-charge-fjs-v2 24.11% <ø> (ø)
clients-driving-license 40.12% <ø> (ø)
clients-driving-license-book 43.38% <ø> (ø)
clients-financial-statements-inao 48.91% <ø> (ø)
clients-license-client 1.83% <ø> (ø)
clients-regulations 42.18% <ø> (ø)
clients-rsk-company-registry 29.76% <ø> (ø)
clients-rsk-personal-tax-return 38.00% <ø> (ø)
clients-smartsolutions 12.77% <ø> (ø)
clients-syslumenn 49.15% <ø> (ø)
cms 0.42% <ø> (ø)
cms-translations 38.92% <ø> (ø)
content-search-toolkit 8.14% <ø> (ø)
contentful-apps 4.69% <ø> (ø)
dokobit-signing 62.40% <ø> (ø)
download-service 44.23% <ø> (ø)
email-service 60.24% <ø> (ø)
feature-flags 90.32% <ø> (ø)
file-storage 52.41% <ø> (ø)
financial-aid-backend 51.24% <ø> (ø)
judicial-system-api 19.57% <ø> (ø)
judicial-system-audit-trail 68.53% <ø> (ø)
judicial-system-backend 55.22% <ø> (ø)
judicial-system-message 66.66% <ø> (ø)
judicial-system-message-handler 47.53% <ø> (ø)
judicial-system-scheduler 70.35% <ø> (ø)
license-api 42.59% <ø> (+0.05%) ⬆️
nest-config 77.74% <ø> (ø)
nest-feature-flags 50.83% <ø> (ø)
nova-sms 61.71% <ø> (ø)
portals-admin-regulations-admin 1.85% <ø> (ø)
portals-core 15.96% <ø> (ø)
services-auth-admin-api 51.87% <ø> (ø)
services-auth-delegation-api 57.52% <ø> (ø)
services-auth-ids-api 51.45% <ø> (+<0.01%) ⬆️
services-auth-personal-representative 45.05% <ø> (-0.03%) ⬇️
services-auth-personal-representative-public 41.27% <ø> (ø)
services-auth-public-api 48.96% <ø> (+<0.01%) ⬆️
services-endorsements-api 53.58% <ø> (ø)
services-sessions 65.36% <ø> (+0.04%) ⬆️
services-university-gateway 49.28% <ø> (-0.03%) ⬇️
services-user-notification 46.88% <ø> (+0.02%) ⬆️
services-user-profile 61.73% <ø> (-0.10%) ⬇️
web 1.80% <ø> (ø)

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

see 2 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 8471bef...f8c47f1. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants