[PR #7326] [MERGED] fix: Include Authorization header in /api/pull and /api/chat requests #22043

Closed
opened 2026-04-20 03:53:34 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/7326
Author: @bnodnarb
Created: 11/25/2024
Status: Merged
Merged: 11/25/2024
Merged by: @tjbck

Base: devHead: fix/ollama-authentication


📝 Commits (1)

  • 8dc73e8 Fix: Add authorization header with bearer token for remote Ollama server endpoints

📊 Changes

1 file changed (+35 additions, -11 deletions)

View changed files

📝 backend/open_webui/apps/ollama/main.py (+35 -11)

📄 Description

Changelog Entry

Description

This pull request fixes a significant functional issue where the Authorization header was not being passed to certain Ollama API endpoints, specifically POST /api/pull and POST /api/chat. As a result, these requests failed with a 401 Unauthorized error when the Ollama server required authentication.

This issue has been highlighted in discussion thread #6856 and has also been confirmed in the Discord Development Channel

Fixed

  • Authorization Header Not Passed to Certain Ollama API Endpoints: Resolved an issue where the Authorization header was not being included in requests to the POST /api/pull and POST /api/chat endpoints. This omission caused requests to fail with a 401 Unauthorized error when connecting to an Ollama server that requires authentication.
  • Consistent Inclusion of Authorization Header: Updated the code to ensure that all Ollama API endpoints now correctly include the Authorization header when a bearer token is provided, aligning the behavior with other endpoints like GET /api/version and GET /api/tags.

Users can now successfully perform actions such as pulling models and initiating chat sessions when connected to authenticated Ollama servers.


Additional Information

Demonstration of Bug (Before Fix)

Successful Requests (Authorization header being sent as expected):

66.8.245.246 - - [24/Nov/2024:21:20:40 +0000] "GET /api/version HTTP/1.1" 200 20 "-" "Python/3.11 aiohttp/3.10.8" Authorization: "Bearer [TOKEN]"
66.8.245.246 - - [24/Nov/2024:21:20:54 +0000] "GET /api/tags HTTP/1.1" 200 660 "-" "python-requests/2.32.3" Authorization: "Bearer [TOKEN]"
66.8.245.246 - - [24/Nov/2024:21:21:07 +0000] "DELETE /api/delete HTTP/1.1" 200 0 "-" "python-requests/2.32.3" Authorization: "Bearer [TOKEN]"
66.8.245.246 - - [24/Nov/2024:21:21:08 +0000] "GET /api/tags HTTP/1.1" 200 338 "-" "Python/3.11 aiohttp/3.10.8" Authorization: "Bearer [TOKEN]"

Failed Requests (Authorization header not being sent):

66.8.245.246 - - [24/Nov/2024:21:21:32 +0000] "POST /api/pull HTTP/1.1" 401 188 "-" "Python/3.11 aiohttp/3.10.8" Authorization: "-"
66.8.245.246 - - [24/Nov/2024:21:22:08 +0000] "POST /api/chat HTTP/1.1" 401 188 "-" "Python/3.11 aiohttp/3.10.8" Authorization: "-"


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/7326 **Author:** [@bnodnarb](https://github.com/bnodnarb) **Created:** 11/25/2024 **Status:** ✅ Merged **Merged:** 11/25/2024 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `fix/ollama-authentication` --- ### 📝 Commits (1) - [`8dc73e8`](https://github.com/open-webui/open-webui/commit/8dc73e87440c92fd8ab41052a3b3cbfd46593911) Fix: Add authorization header with bearer token for remote Ollama server endpoints ### 📊 Changes **1 file changed** (+35 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/apps/ollama/main.py` (+35 -11) </details> ### 📄 Description # Changelog Entry ### Description This pull request fixes a significant functional issue where the Authorization header was not being passed to certain Ollama API endpoints, specifically `POST /api/pull` and `POST /api/chat.` As a result, these requests failed with a `401 Unauthorized` error when the Ollama server required authentication. This issue has been highlighted in discussion thread #6856 and has also been confirmed in the [Discord Development Channel](https://discord.com/channels/1170866489302188073/1210732510250541067/1310361188735123508) ### Fixed - **Authorization Header Not Passed to Certain Ollama API Endpoints**: Resolved an issue where the Authorization header was not being included in requests to the `POST /api/pull` and `POST /api/chat` endpoints. This omission caused requests to fail with a `401 Unauthorized` error when connecting to an Ollama server that requires authentication. - **Consistent Inclusion of Authorization Header**: Updated the code to ensure that all Ollama API endpoints now correctly include the Authorization header when a bearer token is provided, aligning the behavior with other endpoints like `GET /api/version` and `GET /api/tags`. Users can now successfully perform actions such as pulling models and initiating chat sessions when connected to authenticated Ollama servers. --- ### Additional Information Demonstration of Bug (Before Fix) ``` Successful Requests (Authorization header being sent as expected): 66.8.245.246 - - [24/Nov/2024:21:20:40 +0000] "GET /api/version HTTP/1.1" 200 20 "-" "Python/3.11 aiohttp/3.10.8" Authorization: "Bearer [TOKEN]" 66.8.245.246 - - [24/Nov/2024:21:20:54 +0000] "GET /api/tags HTTP/1.1" 200 660 "-" "python-requests/2.32.3" Authorization: "Bearer [TOKEN]" 66.8.245.246 - - [24/Nov/2024:21:21:07 +0000] "DELETE /api/delete HTTP/1.1" 200 0 "-" "python-requests/2.32.3" Authorization: "Bearer [TOKEN]" 66.8.245.246 - - [24/Nov/2024:21:21:08 +0000] "GET /api/tags HTTP/1.1" 200 338 "-" "Python/3.11 aiohttp/3.10.8" Authorization: "Bearer [TOKEN]" Failed Requests (Authorization header not being sent): 66.8.245.246 - - [24/Nov/2024:21:21:32 +0000] "POST /api/pull HTTP/1.1" 401 188 "-" "Python/3.11 aiohttp/3.10.8" Authorization: "-" 66.8.245.246 - - [24/Nov/2024:21:22:08 +0000] "POST /api/chat HTTP/1.1" 401 188 "-" "Python/3.11 aiohttp/3.10.8" Authorization: "-" ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 03:53:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#22043