Skip to content
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

[FEATURE SUGGESTION] Add a Basic or Bearer 'Authorization' header to Ollama API requests #106

Open
lambirou opened this issue May 30, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@lambirou
Copy link
Contributor

Currently, requests to the Ollama API do not include an 'Authorization' header. To strengthen the security of API calls, it is necessary to add an 'Authorization' header with Basic or Bearer authentication.

Tasks to complete:

  • Add an option to include an 'Authorization' header in API requests.
  • Allow the choice between Basic and Bearer authentication.
  • Update the documentation to explain how to configure and use this new feature.
@lambirou lambirou changed the title Add a Basic or Bearer 'Authorization' header to Ollama API requests [FEATURE SUGGESTION] Add a Basic or Bearer 'Authorization' header to Ollama API requests May 30, 2024
@n4ze3m n4ze3m added the enhancement New feature or request label May 30, 2024
@n4ze3m
Copy link
Owner

n4ze3m commented May 30, 2024

Hey, thanks for this great idea! Is there an API key on Ollama?

@aiseei
Copy link

aiseei commented Jun 1, 2024

@n4ze3m no ollama doesnt not have any auth built it.
the expectation is that it sits within a local host env behind a proxy server and app/backend and that auth is managed there. Trying to add auth header in this extension will not make the setup any more secure.

@n4ze3m
Copy link
Owner

n4ze3m commented Jun 1, 2024

I will add an option in the advanced URL configuration for the headers :)

@lambirou
Copy link
Contributor Author

Here is my nginx configuration to add an Authorization Basic header in the request to the Ollama API. I use Apache's htpasswd to manage HTTP users.

server {
  ...

  location @reverse_proxy {
    ...
    proxy_set_header  Authorization $http_authorization;
    proxy_pass_header Authorization;
    proxy_pass_request_headers on;
    ...
  }

  ...
  
  auth_basic           "Administrator’s Area";
  auth_basic_user_file /etc/apache2/.htpasswd;

  ...
}

The HTTP header:

Content-Type: application/json
Accept: application/json
Authorization: Basic cmVkaTpxSlczbk01cFlaNzM=

The hash is the concatenation of user:password hashed in base64.

@lambirou
Copy link
Contributor Author

@n4ze3m No Ollama does not integrate API key management but using Authorization headers in reverse proxy can be an interesting alternative.

@yusiwen
Copy link

yusiwen commented Jun 28, 2024

Any update? Need this feature badly...

@n4ze3m
Copy link
Owner

n4ze3m commented Jun 28, 2024

I will add an option to pass custom headers in the next version (v1.1.14), which will be released on Monday or Tuesday.

@n4ze3m n4ze3m mentioned this issue Jun 29, 2024
@n4ze3m
Copy link
Owner

n4ze3m commented Jul 1, 2024

Hello, everyone! v1.1.14 has been released, which includes the option to configure custom headers for Ollama. Please let me know if you encounter any issues using this feature. Thanks!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants