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): add grant type and acr values to OIDC configs #10798

Closed
wants to merge 1 commit into from

Conversation

mrjefflewis
Copy link
Contributor

@mrjefflewis mrjefflewis commented Jun 27, 2024

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

Summary by CodeRabbit

  • New Features

    • Added support for grantType and acrValues configurations in Single Sign-On (SSO) settings.
  • Configuration

    • Introduced new configuration options: auth.oidc.acrValues and auth.oidc.grantType.

Copy link
Contributor

coderabbitai bot commented Jun 27, 2024

Walkthrough

The recent updates enrich the OpenID Connect (OIDC) authentication with additional configuration options for grantType and acrValues. These options offer more control over authentication flows, enhancing flexibility and compliance with various security policies.

Changes

File Relative Path Change Summary
...auth/sso/oidc/OidcConfigs.java Added grantType and acrValues as optional configurations with default values.
...auth/sso/oidc/OidcProvider.java Updated createPac4jClient method to set grant_type and acr_values in the oidcConfiguration.
.../conf/application.conf Added configuration declarations for auth.oidc.acrValues and auth.oidc.grantType.

Sequence Diagram(s)

sequenceDiagram
    participant Config as Configuration
    participant OidcConfigs as OidcConfigs
    participant OidcProvider as OidcProvider
    participant Pac4jClient as Pac4jClient

    Config->>OidcConfigs: Load grantType and acrValues
    OidcConfigs->>OidcProvider: Provide grantType and acrValues
    OidcProvider->>Pac4jClient: Set grant_type and acr_values
    Pac4jClient-->>OidcProvider: Client ready with configurations
Loading

Poem

🐇🌟
In code's embrace, we find anew,
Grant types and values too.
Configs whisper, secrets shared,
By OIDC, we’re now prepared.
A rabbit’s hop through fields of auth,
With acr values, we wander forth.
🌟🐇


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

@mrjefflewis mrjefflewis requested a review from RyanHolstien June 27, 2024 18:39
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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d63f25f and 35be1fb.

Files selected for processing (3)
  • datahub-frontend/app/auth/sso/oidc/OidcConfigs.java (1 hunks)
  • datahub-frontend/app/auth/sso/oidc/OidcProvider.java (2 hunks)
  • datahub-frontend/conf/application.conf (1 hunks)
Additional comments not posted (2)
datahub-frontend/app/auth/sso/oidc/OidcConfigs.java (1)

166-167: Validate default values for new OIDC configurations.

The added lines correctly implement default values for grantType and acrValues. It's important to ensure these defaults align with the expected security standards and OIDC specifications.

datahub-frontend/conf/application.conf (1)

190-192: Confirm the correct setup of environment variables for new OIDC settings.

The configuration lines for auth.oidc.acrValues and auth.oidc.grantType are correctly set up to be overridden by environment variables, which is crucial for flexible deployment configurations.

@@ -75,6 +75,7 @@ private Client<OidcCredentials> createPac4jClient() {
oidcConfiguration.setPreferredJwsAlgorithm(preferred);
});

oidcConfiguration.setCustomParams(ImmutableMap.of("grant_type", _oidcConfigs.getGrantType(), "acr_values", _oidcConfigs.getAcrValues()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Ensure proper handling of custom parameters in OIDC configuration.

The addition of grant_type and acr_values to the OIDC configuration is crucial for the new feature. However, there is no evidence of these parameters being validated before being set, which could lead to potential security issues. Please implement validation for these parameters to ensure they are correctly handled.

  • Files to review:
    • datahub-frontend/app/auth/sso/oidc/OidcProvider.java
    • datahub-frontend/app/auth/sso/oidc/OidcCallbackLogic.java
    • datahub-frontend/app/auth/sso/oidc/custom/CustomOidcAuthenticator.java
Analysis chain

Ensure proper handling of custom parameters in OIDC configuration.

The addition of grant_type and acr_values to the OIDC configuration is crucial for the new feature. However, ensure that these parameters are properly validated before being set to avoid potential security issues.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the provided grant_type and acr_values are validated.

# Test: Search for validation logic related to grant_type and acr_values.
rg --type java "(validate|check).*(grantType|acrValues)" datahub-frontend/app/auth/sso/oidc/

Length of output: 94



Script:

#!/bin/bash
# Description: Verify the provided grant_type and acr_values are validated.

# Search for any validation logic related to _oidcConfigs.
rg --type java "(validate|check).*(oidcConfigs|_oidcConfigs)" datahub-frontend/

# Search for validation logic within OIDC-related classes and files.
rg --type java "(validate|check)" datahub-frontend/app/auth/sso/oidc/

Length of output: 663



Script:

#!/bin/bash
# Description: Extract and examine validation logic within CustomOidcAuthenticator.java and OidcCallbackLogic.java.

# Extract the validate method from CustomOidcAuthenticator.java
ast-grep --lang java --pattern 'public void validate($_, $_) { $$$ }' datahub-frontend/app/auth/sso/oidc/custom/CustomOidcAuthenticator.java

# Extract the validation-related code from OidcCallbackLogic.java
rg --type java 'validate' datahub-frontend/app/auth/sso/oidc/OidcCallbackLogic.java

Length of output: 323

@github-actions github-actions bot added the product PR or Issue related to the DataHub UI/UX label Jun 27, 2024
@@ -75,6 +75,7 @@ private Client<OidcCredentials> createPac4jClient() {
oidcConfiguration.setPreferredJwsAlgorithm(preferred);
});

oidcConfiguration.setCustomParams(ImmutableMap.of("grant_type", _oidcConfigs.getGrantType(), "acr_values", _oidcConfigs.getAcrValues()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

are we overriding the previous customParams set on line 69?

@@ -163,6 +163,8 @@ public Builder from(final com.typesafe.config.Config configs) {
responseType = getOptional(configs, OIDC_RESPONSE_TYPE);
responseMode = getOptional(configs, OIDC_RESPONSE_MODE);
useNonce = getOptional(configs, OIDC_USE_NONCE).map(Boolean::parseBoolean);
grantType = getOptional(configs, OIDC_GRANT_TYPE, DEFAULT_OIDC_GRANT_TYPE);
Copy link
Collaborator

Choose a reason for hiding this comment

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

where is DEFAULT_OIDC_GRANT_TYPE defined?

@RyanHolstien
Copy link
Collaborator

#11116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR or Issue related to the DataHub UI/UX
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants