Skip to content

Allow OIDC scopes to be configured via P_OIDC_SCOPE environment variable #1363

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

thenodon
Copy link

@thenodon thenodon commented Jun 30, 2025

Description

This PR adds support for customizing the OIDC scopes used during authentication by introducing a new environment variable:

P_OIDC_SCOPE

By default, the OIDC scope remains unchanged, as the current implementation: openid profile email
If P_OIDC_SCOPE is set, its value will be used instead during the OIDC authorization request.
This allows integrations (e.g., with Dex) to request additional claims like groups when needed for RBAC.

Motivation

In some OIDC providers (e.g., Dex), claims such as groups are only included in tokens if explicitly requested via the scope parameter. Since Parseable currently hardcodes the OIDC scope, there is no way to request such claims without modifying the code.

This PR enables more flexible OIDC integrations and ensures that role-based access control can work correctly with group-based identity providers.

Changes Introduced

  • Adds P_OIDC_SCOPE as an optional environment variable
  • Falls back to "openid profile email" if unset
  • Uses the configured scope during the OIDC authorization URL construction
  • Main change in handlers/http/oidc.rs in function redirect_to_oidc where the hardcoded scope string is replaced with variable

This PR has:

  • been tested to ensure log ingestion and log query works.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added documentation for new or modified features or behaviors.

Summary by CodeRabbit

  • New Features

    • Added a configurable OIDC scope option, allowing users to specify the scope via a command-line flag or environment variable.
  • Refactor

    • Updated the application to use the user-defined OIDC scope at runtime instead of a fixed value.

… P_OIDC_SCOPE, default to "openid profile email".
Copy link
Contributor

coderabbitai bot commented Jun 30, 2025

Walkthrough

A new configurable scope parameter for OIDC authentication was introduced, allowing the OAuth scope to be set via a command-line flag or environment variable instead of being hardcoded. The relevant constant was removed, and the scope is now dynamically passed through function calls involved in the OIDC login flow.

Changes

File(s) Change Summary
src/cli.rs Added scope field to Options struct; new CLI flag and env var for OIDC scope with default value.
src/handlers/http/oidc.rs Removed use of OIDC_SCOPE constant; updated functions to accept scope as a parameter; call sites updated.
src/handlers/mod.rs Removed OIDC_SCOPE constant.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant OIDC_Handler
    participant OIDC_Provider

    User->>CLI: Starts application with --oidc-scope or env var
    CLI->>OIDC_Handler: Passes configured scope to handler
    User->>OIDC_Handler: Initiates login
    OIDC_Handler->>OIDC_Provider: Redirects with dynamic scope in auth URL
    OIDC_Provider-->>User: Handles authentication with requested scope
Loading

Poem

In the warren of code, a new scope appears,
No longer hardcoded, it bends to our cheers.
From command-line or env, set it your way—
The OIDC dance is now more ballet.
Hop along, little rabbit, your login’s bespoke,
With a configurable, magical, runtime scope!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

Copy link
Contributor

github-actions bot commented Jun 30, 2025

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

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

🧹 Nitpick comments (1)
src/handlers/http/oidc.rs (1)

80-80: Optimize string conversion to avoid unnecessary allocation.

The string conversion PARSEABLE.options.scope.to_string().as_str() creates an unnecessary temporary string allocation. Since scope is already a String, you can pass a string slice directly.

Apply this diff to optimize the string passing:

-    redirect_to_oidc(query, client, PARSEABLE.options.scope.to_string().as_str())
+    redirect_to_oidc(query, client, &PARSEABLE.options.scope)
-    redirect_to_oidc(query, oidc_client, PARSEABLE.options.scope.to_string().as_str())
+    redirect_to_oidc(query, oidc_client, &PARSEABLE.options.scope)

Also applies to: 116-116

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b8a9bd0 and dbfe328.

📒 Files selected for processing (3)
  • src/cli.rs (1 hunks)
  • src/handlers/http/oidc.rs (4 hunks)
  • src/handlers/mod.rs (0 hunks)
💤 Files with no reviewable changes (1)
  • src/handlers/mod.rs
🧰 Additional context used
🧠 Learnings (1)
src/handlers/http/oidc.rs (1)
Learnt from: nikhilsinhaparseable
PR: parseablehq/parseable#1340
File: src/query/mod.rs:64-66
Timestamp: 2025-06-18T06:39:04.775Z
Learning: In src/query/mod.rs, QUERY_SESSION_STATE and QUERY_SESSION serve different architectural purposes: QUERY_SESSION_STATE is used for stats calculation and allows dynamic registration of individual parquet files from the staging path (files created every minute), while QUERY_SESSION is used for object store queries with the global schema provider. Session contexts with schema providers don't support registering individual tables/parquets, so both session objects are necessary for their respective use cases.
🔇 Additional comments (2)
src/cli.rs (1)

454-463: LGTM! Well-structured CLI configuration.

The OIDC scope configuration is properly implemented with appropriate CLI argument mapping, environment variable support, and maintains backward compatibility with the default value.

src/handlers/http/oidc.rs (1)

226-241: LGTM! Clean function signature update.

The function signature change to accept a configurable scope parameter is well-implemented and maintains the existing authorization URL construction logic correctly.

@thenodon
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

nitisht added a commit to parseablehq/.github that referenced this pull request Jun 30, 2025
@thenodon
Copy link
Author

thenodon commented Jul 2, 2025

@nitisht did this PR make sense?

Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable left a comment

Choose a reason for hiding this comment

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

approved

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