8000 Support custom cookie path. Improve oauth docs by MarcSkovMadsen · Pull Request #7911 · holoviz/panel · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@MarcSkovMadsen
Copy link
Collaborator
@MarcSkovMadsen MarcSkovMadsen commented May 11, 2025

Closing #7910 and adding oauth documentation that would have made my life much easier.

Todo

  • Create POC
  • Systematically go through code and implement feature similarly to how cookie_secret is implemented
  • Manual Tests
  • Documentation

POC

When setting PANEL_COOKIE_PATH=apps/debug-panel-oauth and opening /apps/debug-panel-oauth/script at my domain I see

image

When I open / at my domain I see

image

Which would solve my problem and let individually deployed Panel apps at my shared domain control oauth individually.

@codecov
Copy link
codecov bot commented May 11, 2025

Codecov Report

Attention: Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.

Project coverage is 87.10%. Comparing base (8116454) to head (501bbd6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
panel/command/serve.py 66.66% 2 Missing ⚠️
panel/auth.py 87.50% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7911   +/-   ##
=======================================
  Coverage   87.10%   87.10%           
=======================================
  Files         346      346           
  Lines       53133    53146   +13     
=======================================
+ Hits        46283    46295   +12     
- Misses       6850     6851    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MarcSkovMadsen MarcSkovMadsen changed the title Support custom cookie path Support custom cookie path. Improve oauth docs May 11, 2025
Copy link
Member
@philippjfr philippjfr left a comment

Choose a reason for hiding this comment

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

Thanks, happy with this, though I'd probably pull the Azure part out into it's own page now that it is quite detailed and do the same for the other providers eventually.

@MarcSkovMadsen MarcSkovMadsen marked this pull request as ready for review May 11, 2025 18:37
@MarcSkovMadsen MarcSkovMadsen requested a review from philippjfr May 11, 2025 18:38
Copy link
Collaborator Author
@MarcSkovMadsen MarcSkovMadsen left a comment

Choose a reason for hiding this comment

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

I believe this is ready for review.

I believe this works based on analysis of the code and manual tests. But I don't fully know what to change or how to test more systematically.

@MarcSkovMadsen MarcSkovMadsen requested a review from Copilot May 11, 2025 18:41
Copy link
Contributor
Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for custom cookie paths for OAuth authentication and updates relevant documentation to guide users on the new configuration.

  • Adds a new cookie_path parameter to key functions in the server, configuration, and authentication modules.
  • Updates the CLI and docs to reflect the new cookie_path option for finer control over cookie scoping.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
panel/io/server.py Adds cookie_path to get_server and integrates it into the server options.
panel/config.py Introduces the _cookie_path parameter and a cookie_path property using PANEL_COOKIE_PATH.
panel/command/serve.py Adds the --cookie-path CLI argument and enforces mutual exclusivity between CLI and env settings.
panel/auth.py Propagates cookie_path to secure cookie calls.
doc/tutorials/intermediate/serve.md Documents the use of --cookie-path in CLI usage.
doc/how_to/server/commandline.md Updates command line documentation to include cookie path settings.
doc/how_to/authentication/trouble_shooting.md Adds troubleshooting and usage guidance for OAuth along with cookie path examples.
doc/how_to/authentication/providers/* Updates OAuth providers documentation reflecting changes in cookie management.
doc/how_to/authentication/configuration.md Introduces a section on configuring cookie_path in both CLI and Python.
doc/api/config.md Updates the API documentation to include details about the new cookie_path configuration.

MarcSkovMadsen and others added 2 commits May 12, 2025 05:32
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@MarcSkovMadsen MarcSkovMadsen requested a review from Copilot May 12, 2025 06:11
Copy link
Contributor
Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for a custom cookie path and improves OAuth-related documentation. Key changes include adding a new "cookie_path" parameter in server configuration, updating the configuration and CLI for cookie path management, and revising documentation to reflect these enhancements.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
panel/io/server.py Added a "cookie_path" parameter and propagated it to the server opts.
panel/config.py Introduced internal configuration for cookie path support.
panel/command/serve.py Added a CLI argument for cookie path with conflict detection.
panel/auth.py Updated cookie-setting calls to include the custom cookie path.
Documentation files (serve.md, commandline.md, etc.) Updated usage and configuration instructions to include cookie path.
Comments suppressed due to low confidence (1)

panel/auth.py:352

  • [nitpick] Several calls to set_secure_cookie now specify cookie_path explicitly. Consider abstracting the common cookie options into a helper function to reduce duplication and ensure consistency.
handler.set_secure_cookie(CODE_COOKIE_NAME, code, expires_days=config.oauth_expiry, httponly=True, path=config.cookie_path)

@philippjfr philippjfr merged commit 3eba486 into main May 12, 2025
19 checks passed
@philippjfr philippjfr deleted the enhancement/cookie-path branch May 12, 2025 09:12
@github-actions
Copy link
github-actions bot commented Sep 9, 2025

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0