rudder-server icon indicating copy to clipboard operation
rudder-server copied to clipboard

feat: update oauth module in server to interception pattern

Open ItsSudip opened this issue 1 year ago • 3 comments

Description

We are updating our OAuth module to the new format. We are moving it to an interception pattern. As of now if anyone wants to use the OAuth module they need to augment the accessToken to the payload and along with that they need to parse the response and call refershToken if required. We are omitting those by introducing an HTTP client to do the augmentation and response parsing and send the request.

Linear Ticket

Resolves INT-1012 Resolves INT-956

Security

  • [ ] The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Summary by CodeRabbit

  • New Features
    • Introduced OAuth V2 support across various components, enhancing authentication and authorization capabilities.
    • Added new OAuth V2 related functionality, including token fetching, refreshing, and authorization status management.
    • Implemented OAuth V2 enabled HTTP client and transport layer for improved security and efficiency in handling OAuth requests.
    • Enhanced destination management with OAuth V2 support for Bing Ads, including token generation and authentication handling.
  • Enhancements
    • Updated HTTP client setup and API manager initialization to support OAuth V2 configurations.
    • Improved error handling and response processing for OAuth V2 scenarios in regulation worker and router components.
    • Introduced cache interface and implementation for efficient OAuth V2 token and status management.
  • Bug Fixes
    • Adjusted async upload timeout configuration for better reliability in data processing.
  • Tests
    • Added extensive test coverage for OAuth V2 functionality, including mock implementations, unit tests, and integration tests across services and components.
  • Documentation
    • Enhanced inline documentation and summaries for better understanding of OAuth V2 integration and its impact on the system.

ItsSudip avatar Jan 18 '24 04:01 ItsSudip

[!IMPORTANT]

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The recent updates introduce comprehensive support for OAuth v2 across various components, focusing on mock implementations for testing, enhanced OAuth v2 functionality, and improved error handling. Significant changes include the addition of OAuth v2 client and authorization capabilities, mock services for interface testing, and updates to the regulation-worker and router components to support OAuth v2. These changes aim to modernize authentication mechanisms, streamline testing processes, and refine error management for OAuth-related operations.

Changes

File Path Change Summary
mocks/services/oauthV2/... Introduced mock implementations for OAuth v2 interfaces including TokenProvider, Authorizer, and RoundTripper.
regulation-worker/cmd/main.go
regulation-worker/internal/delete/api/api.go
Added OAuth v2 support with new imports, variables, and updated HTTP client setup. Introduced IsOAuthV2Enabled field and enhanced error handling in APIManager.
router/batchrouter/asyncdestinationmanager/bing-ads/... Updated bing-ads package to support OAuth v2 with new parameters and OAuth client initialization.
router/batchrouter/handle_lifecycle.go
router/handle_lifecycle.go
router/transformer/...
router/types.go
router/worker.go
Enhanced router and transformer components for OAuth v2 support, including new imports, configuration variables, and OAuth v2 client handling.
runner/runner.go Initialized OAuth v2 support in the runner component.
services/oauth/v2/... Added new files for OAuth v2 service implementation, including cache management, control plane connector, HTTP client, and utility functions. Implemented tests for these functionalities.

This table summarizes the key changes, grouping files with similar modifications to streamline the overview of the update's scope.

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-tests 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 tests 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 tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

coderabbitai[bot] avatar Jan 18 '24 04:01 coderabbitai[bot]

@ItsSudip Let's use non-sugared structured logging for logs. More about it in here.

achettyiitr avatar Feb 27 '24 12:02 achettyiitr

@coderabbitai review

koladilip avatar Feb 27 '24 13:02 koladilip

Codecov Report

Attention: Patch coverage is 83.28009% with 157 lines in your changes are missing coverage. Please review.

Project coverage is 75.52%. Comparing base (559d701) to head (35889e8). Report is 1 commits behind head on master.

Files Patch % Lines
...chrouter/asyncdestinationmanager/bing-ads/token.go 0.00% 38 Missing :warning:
services/oauth/v2/http/transport.go 81.25% 22 Missing and 8 partials :warning:
services/oauth/v2/oauth.go 92.66% 14 Missing and 5 partials :warning:
regulation-worker/cmd/main.go 61.29% 12 Missing :warning:
services/oauth/v2/controlplane/cp_connector.go 86.81% 9 Missing and 3 partials :warning:
utils/tests/oauth-cp-requests.go 71.79% 8 Missing and 3 partials :warning:
regulation-worker/internal/delete/api/api.go 90.36% 5 Missing and 3 partials :warning:
...router/asyncdestinationmanager/bing-ads/manager.go 33.33% 6 Missing :warning:
services/oauth/v2/destination_info.go 68.42% 3 Missing and 3 partials :warning:
services/oauth/v2/extensions/augmenter.go 72.72% 3 Missing and 3 partials :warning:
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4329      +/-   ##
==========================================
+ Coverage   75.24%   75.52%   +0.28%     
==========================================
  Files         381      392      +11     
  Lines       46469    47361     +892     
==========================================
+ Hits        34965    35771     +806     
- Misses       9215     9277      +62     
- Partials     2289     2313      +24     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Mar 05 '24 13:03 codecov[bot]