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

Upgrade passport/saml to 5.0 #3247

Merged
merged 4 commits into from
Mar 15, 2025
Merged

Upgrade passport/saml to 5.0 #3247

merged 4 commits into from
Mar 15, 2025

Conversation

maidul98
Copy link
Collaborator

@maidul98 maidul98 commented Mar 15, 2025

This addresses the breaking changes in 5.0 listed here https://github.com/node-saml/node-saml/blob/v5.0.0/CHANGELOG.md#-major-changes

Todo: test with existing saml workflow

Summary by CodeRabbit

  • Chores

    • Upgraded the SAML authentication library to the latest major version, offering improved security, performance, and system compatibility.
  • Refactor

    • Enhanced how SAML configurations are processed by explicitly handling required fields.
    • Clarified the naming of the identity provider certificate to ensure a more reliable setup.
    • Updated import statements for the ms utility to utilize a local module, improving code organization.

This addresses the breaking changes in 5.0 listed here https://github.com/node-saml/node-saml/blob/v5.0.0/CHANGELOG.md#-major-changes

Todo: test with existing saml workflow
Copy link

coderabbitai bot commented Mar 15, 2025

Walkthrough

This pull request introduces updates to the SAML integration in the project. The dependency @node-saml/passport-saml has been upgraded in package.json from version ^4.0.4 to ^5.0.1. The implementation of the SAML router has been adjusted by changing the way request body properties are handled—specifically, the cert property has been renamed to idpCert, and destructuring assignment is used to extract key elements from req.body. Corresponding changes have been made in the SAML configuration service, where the functions for creating and updating SAML configurations now use idpCert instead of cert. The data transfer object types have also been updated to reflect this change by renaming the cert property to idpCert. Additionally, multiple import statements for the ms utility have been modified across various files to source it from a local module at @app/lib/ms.

Suggested reviewers

  • scott-ray-wilson

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

backend/src/ee/routes/v1/kmip-router.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/backend".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "backend/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

backend/src/ee/routes/v1/ssh-certificate-router.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/backend".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "backend/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

backend/src/ee/routes/v1/dynamic-secret-lease-router.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "@typescript-eslint/eslint-plugin".

(The package "@typescript-eslint/eslint-plugin" was not found when loaded as a Node module from the directory "/backend".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install @typescript-eslint/eslint-plugin@latest --save-dev

The plugin "@typescript-eslint/eslint-plugin" was referenced from the config file in "backend/.eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.

  • 27 others

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

akhilmhdh
akhilmhdh previously approved these changes Mar 15, 2025
Copy link

@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: 0

🧹 Nitpick comments (3)
backend/src/lib/ms/index.ts (3)

1-15: Add explicit return type and documentation for better maintainability

This is a good wrapper implementation for the ms library that adds proper validation and error handling. To improve maintainability, consider adding:

  1. An explicit return type to the function
  2. JSDoc comments explaining what the function does and providing examples
 import msFn, { StringValue } from "ms";

 import { BadRequestError } from "../errors";

+/**
+ * Convert a time string (e.g. '1d', '10h', '2.5y') to milliseconds
+ * Provides validation and consistent error handling
+ * @param val - The string to convert (e.g. '1d', '10h', '2.5y')
+ * @returns The number of milliseconds
+ * @throws {BadRequestError} If the input is not a string or the format is invalid
+ * @example
+ * ms('2 days') // 172800000
+ * ms('1d') // 86400000
+ * ms('10h') // 36000000
+ */
-export const ms = (val: string) => {
+export const ms = (val: string): number => {
   if (typeof val !== "string") {
     throw new BadRequestError({ message: `Date must be string` });
   }

   try {
     return msFn(val as StringValue);
   } catch {
     throw new BadRequestError({ message: `Invalid date format string: ${val}` });
   }
 };

11-11: Avoid type assertion when possible

The type assertion as StringValue might not be necessary since val is already validated as a string, and the ms library should handle compatible string inputs correctly.

-    return msFn(val as StringValue);
+    return msFn(val);

12-13: Consider catching specific error types

The current implementation catches all errors without discriminating. If the ms library throws specific error types, catching them explicitly would provide better error handling.

   try {
     return msFn(val as StringValue);
-  } catch {
+  } catch (error) {
+    // If there's specific error type information, you could use it here
     throw new BadRequestError({ message: `Invalid date format string: ${val}` });
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b71f7f and 7dffc08.

📒 Files selected for processing (30)
  • backend/src/ee/routes/v1/dynamic-secret-lease-router.ts (1 hunks)
  • backend/src/ee/routes/v1/dynamic-secret-router.ts (1 hunks)
  • backend/src/ee/routes/v1/identity-project-additional-privilege-router.ts (1 hunks)
  • backend/src/ee/routes/v1/kmip-router.ts (1 hunks)
  • backend/src/ee/routes/v1/ssh-certificate-router.ts (1 hunks)
  • backend/src/ee/routes/v1/ssh-certificate-template-router.ts (1 hunks)
  • backend/src/ee/routes/v1/user-additional-privilege-router.ts (1 hunks)
  • backend/src/ee/routes/v2/identity-project-additional-privilege-router.ts (1 hunks)
  • backend/src/ee/services/access-approval-request/access-approval-request-service.ts (2 hunks)
  • backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-service.ts (1 hunks)
  • backend/src/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service.ts (1 hunks)
  • backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts (1 hunks)
  • backend/src/ee/services/kmip/kmip-service.ts (1 hunks)
  • backend/src/ee/services/project-user-additional-privilege/project-user-additional-privilege-service.ts (1 hunks)
  • backend/src/ee/services/ssh-certificate-template/ssh-certificate-template-service.ts (1 hunks)
  • backend/src/ee/services/ssh/ssh-certificate-authority-fns.ts (1 hunks)
  • backend/src/lib/ms/index.ts (1 hunks)
  • backend/src/server/routes/v1/certificate-authority-router.ts (1 hunks)
  • backend/src/server/routes/v1/certificate-router.ts (1 hunks)
  • backend/src/server/routes/v1/certificate-template-router.ts (1 hunks)
  • backend/src/server/routes/v1/project-membership-router.ts (1 hunks)
  • backend/src/server/routes/v2/group-project-router.ts (1 hunks)
  • backend/src/server/routes/v2/identity-project-router.ts (1 hunks)
  • backend/src/services/certificate-authority/certificate-authority-service.ts (1 hunks)
  • backend/src/services/certificate-template/certificate-template-fns.ts (1 hunks)
  • backend/src/services/group-project/group-project-service.ts (1 hunks)
  • backend/src/services/identity-project/identity-project-service.ts (1 hunks)
  • backend/src/services/identity/identity-dal.ts (1 hunks)
  • backend/src/services/project-membership/project-membership-service.ts (1 hunks)
  • backend/src/services/super-admin/super-admin-service.ts (1 hunks)
✅ Files skipped from review due to trivial changes (29)
  • backend/src/server/routes/v1/certificate-router.ts
  • backend/src/ee/routes/v1/dynamic-secret-router.ts
  • backend/src/server/routes/v1/certificate-template-router.ts
  • backend/src/ee/routes/v2/identity-project-additional-privilege-router.ts
  • backend/src/server/routes/v1/project-membership-router.ts
  • backend/src/ee/routes/v1/user-additional-privilege-router.ts
  • backend/src/server/routes/v1/certificate-authority-router.ts
  • backend/src/services/identity/identity-dal.ts
  • backend/src/ee/routes/v1/dynamic-secret-lease-router.ts
  • backend/src/server/routes/v2/group-project-router.ts
  • backend/src/ee/services/ssh/ssh-certificate-authority-fns.ts
  • backend/src/ee/services/ssh-certificate-template/ssh-certificate-template-service.ts
  • backend/src/ee/services/dynamic-secret-lease/dynamic-secret-lease-service.ts
  • backend/src/services/identity-project/identity-project-service.ts
  • backend/src/services/certificate-template/certificate-template-fns.ts
  • backend/src/ee/routes/v1/kmip-router.ts
  • backend/src/server/routes/v2/identity-project-router.ts
  • backend/src/ee/services/project-user-additional-privilege/project-user-additional-privilege-service.ts
  • backend/src/ee/routes/v1/ssh-certificate-template-router.ts
  • backend/src/ee/services/access-approval-request/access-approval-request-service.ts
  • backend/src/ee/services/identity-project-additional-privilege/identity-project-additional-privilege-service.ts
  • backend/src/services/project-membership/project-membership-service.ts
  • backend/src/ee/routes/v1/identity-project-additional-privilege-router.ts
  • backend/src/ee/services/kmip/kmip-service.ts
  • backend/src/services/group-project/group-project-service.ts
  • backend/src/services/super-admin/super-admin-service.ts
  • backend/src/ee/routes/v1/ssh-certificate-router.ts
  • backend/src/services/certificate-authority/certificate-authority-service.ts
  • backend/src/ee/services/identity-project-additional-privilege-v2/identity-project-additional-privilege-v2-service.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Check TS and Lint
  • GitHub Check: Run integration test
  • GitHub Check: Check API Changes
🔇 Additional comments (1)
backend/src/lib/ms/index.ts (1)

1-15: Nice implementation of a wrapper function with proper error handling

Good job implementing this wrapper function that provides robust error handling around the ms library. This centralized approach will make working with time strings more consistent across the application and supports the SAML integration upgrade properly.

@maidul98 maidul98 merged commit 8f96653 into main Mar 15, 2025
7 checks passed
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.

2 participants