[PR #314] [MERGED] Token auth #8832

Closed
opened 2025-11-12 14:53:27 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/314
Author: @pdevine
Created: 8/9/2023
Status: Merged
Merged: 8/10/2023
Merged by: @pdevine

Base: mainHead: token-auth


📝 Commits (4)

  • 215a071 initial token auth
  • be764a7 more tokens auth
  • a571ea2 only attempt token auth if the registry gives a 401
  • 8556844 add timestamp and nonce to the token request

📊 Changes

3 files changed (+233 additions, -6 deletions)

View changed files

📝 api/types.go (+4 -0)
server/auth.go (+164 -0)
📝 server/images.go (+65 -6)

📄 Description

This change implements token authorization for the ollama server.

The basic steps for using auth are:

  1. make an authenticated call to the registry; if the registry returns a 401 w/ the Www-Authenticate header, then
  2. look for an SSH ed25519 key pair called ~/.ollama/id_ed25519
  3. make a call to the token endpoint from the Www-Authenticate header w/ the signed Authorization header (this will be in the form Authorization: <pub key>:<signature>). The other params are given in the original 401 Www-Authenticate header which will include the realm and the scope
  4. the token endpoint will issue a new signed JWT for the source specified with the correct scope
  5. the request is made again, this time filling in the header as Authorization: Bearer <jwt>
  6. success (the model can be pushed or pulled)

🔄 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/ollama/ollama/pull/314 **Author:** [@pdevine](https://github.com/pdevine) **Created:** 8/9/2023 **Status:** ✅ Merged **Merged:** 8/10/2023 **Merged by:** [@pdevine](https://github.com/pdevine) **Base:** `main` ← **Head:** `token-auth` --- ### 📝 Commits (4) - [`215a071`](https://github.com/ollama/ollama/commit/215a071f0d0cd8d5e97bbb16734d87b0a23d985c) initial token auth - [`be764a7`](https://github.com/ollama/ollama/commit/be764a703235a5bcc43864ee22f84b2088b7606f) more tokens auth - [`a571ea2`](https://github.com/ollama/ollama/commit/a571ea21b83c68cf627bd902ebae8b0955dfb5e9) only attempt token auth if the registry gives a 401 - [`8556844`](https://github.com/ollama/ollama/commit/85568440962c650f67ecb00a6189e0923d42bb39) add timestamp and nonce to the token request ### 📊 Changes **3 files changed** (+233 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+4 -0) ➕ `server/auth.go` (+164 -0) 📝 `server/images.go` (+65 -6) </details> ### 📄 Description This change implements token authorization for the ollama server. The basic steps for using auth are: 1. make an authenticated call to the registry; if the registry returns a 401 w/ the Www-Authenticate header, then 2. look for an SSH ed25519 key pair called `~/.ollama/id_ed25519` 3. make a call to the token endpoint from the Www-Authenticate header w/ the signed Authorization header (this will be in the form `Authorization: <pub key>:<signature>`). The other params are given in the original 401 Www-Authenticate header which will include the realm and the scope 4. the token endpoint will issue a new signed JWT for the source specified with the correct scope 5. the request is made again, this time filling in the header as `Authorization: Bearer <jwt>` 6. success (the model can be pushed or pulled) --- <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 2025-11-12 14:53:27 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama-ollama#8832
No description provided.