Replies: 1 comment
-
|
Hi, we have the same requirement, but for (python based) Local Tools rather than Pipe Functions — a native, per-user OAuth2 Authorization Code flow so a Tool can authenticate the individual user against a 3rd-party API on demand. The architecture you describe fits our case almost exactly; the only real difference is the integration point (Tool call vs. Worth noting: most of this plumbing already exists for MCP tool servers; it just isn't generalized to Functions/Tools. The MCP OAuth 2.1 path already implements nearly everything proposed here:
So the gap is smaller than it looks: a way to register a per-Function/Tool OAuth client from persisted config, plus a lazy-loader so any instance can reconstruct it. For multi-instance deployments, the per-Function/Tool client must be reconstructable on any worker (in-memory-only registration already causes 404s for MCP — see #22756). Concretely, a minimal version of this proposal might be:
Happy to help prototype the Tools-oriented variant if there's maintainer interest in this direction. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone, I'd like to propose a new framework to handle OAuth2 callbacks securely within Functions, specifically to support user-level API authentication.
The Problem
Currently, implementing the standard OAuth2 Authorization Code Flow securely within Open WebUI Functions is highly challenging.
I am trying to implement a custom Model via a Pipe Function that routes chat requests to Azure OpenAI using the individual user's Entra ID credentials.
Since Functions run in an isolated Python environment, they cannot dynamically expose a callback URL to receive the authorization code. As a result, developers are forced to use the "Device Code Flow," which significantly degrades the chat UX by forcing users to manually copy-paste codes into separate browser tabs.
Why existing alternatives aren't the right fit:
The Proposed Solution
I propose implementing a generic, core-level OAuth callback framework that seamlessly integrates with
UserValves. This would allow Functions (especially Pipes) to easily request user authentication, handle the callback natively, and securely receive tokens without needing external infrastructure.Proposed Architecture:
/api/v1/functions/oauth/callback).stateparameter (to prevent CSRF) and PKCE (Proof Key for Code Exchange) parameters (code_verifierandcode_challenge). These are temporarily stored in the backend before redirecting the user's browser.code_verifier, and automatically injects the token into the specificUserValvesfor that user and Function.Example Function Interface Idea:
Enterprise Value (Additional Context)
As Open WebUI expands into enterprise environments, the need for secure, per-user authentication directly at the Model level becomes critical.
By providing a secure, PKCE-compliant built-in OAuth callback manager mapped to UserValves, we can unlock a massive ecosystem of API-integrated Pipe Functions securely.
I would love to hear your thoughts on this approach and whether this aligns with the architectural direction of Open WebUI!
Beta Was this translation helpful? Give feedback.
All reactions