feat: add deploy tokens (#37306)

Deploy keys only work over SSH. A deploy token is their counterpart for HTTPS: a repository scoped credential, used as the password of a Git request, with read or read and write access. It covers Git operations and LFS, and can be regenerated in place.

Signed-off-by: silverwind <me@silverwind.io>
Co-authored-by: Claude Mythos <noreply@anthropic.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: bircni <bircni@icloud.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
ToastyTheBot
2026-08-27 03:32:44 +08:00
committed by GitHub
parent 3c4d5a6a5c
commit 646ea0f253
76 changed files with 1594 additions and 831 deletions
+87 -5
View File
@@ -3973,6 +3973,26 @@
"type": "object",
"x-go-package": "gitea.dev/modules/structs"
},
"CreateDeployKeyTokenOption": {
"properties": {
"read_only": {
"description": "Describe if the token has only read access or read/write",
"type": "boolean",
"x-go-name": "ReadOnly"
},
"title": {
"description": "Title of the token to add",
"type": "string",
"uniqueItems": true,
"x-go-name": "Title"
}
},
"required": [
"title"
],
"type": "object",
"x-go-package": "gitea.dev/modules/structs"
},
"CreateEmailOption": {
"description": "CreateEmailOption options when creating email addresses",
"properties": {
@@ -4227,7 +4247,6 @@
"x-go-package": "gitea.dev/modules/structs"
},
"CreateKeyOption": {
"description": "CreateKeyOption options when creating a key",
"properties": {
"key": {
"description": "An armored SSH key to add",
@@ -5195,10 +5214,9 @@
"x-go-package": "gitea.dev/modules/structs"
},
"DeployKey": {
"description": "DeployKey a deploy key",
"properties": {
"created_at": {
"description": "Created is the time when the deploy key was added",
"description": "Created is the time when the deploy-key was added",
"format": "date-time",
"type": "string",
"x-go-name": "Created"
@@ -5209,7 +5227,7 @@
"x-go-name": "Fingerprint"
},
"id": {
"description": "ID is the unique identifier for the deploy key",
"description": "ID is the unique identifier for the deploy-key",
"format": "int64",
"type": "integer",
"x-go-name": "ID"
@@ -5225,6 +5243,15 @@
"type": "integer",
"x-go-name": "KeyID"
},
"key_type": {
"description": "Type tells whether the key authenticates over SSH or with a token over HTTPS",
"enum": [
"ssh",
"token"
],
"type": "string",
"x-go-name": "KeyType"
},
"read_only": {
"description": "ReadOnly indicates if the key has read-only access",
"type": "boolean",
@@ -5238,8 +5265,13 @@
"type": "string",
"x-go-name": "Title"
},
"token": {
"description": "Token is the plaintext token of an HTTPS key, only returned when it is created",
"type": "string",
"x-go-name": "Token"
},
"url": {
"description": "URL is the API URL for this deploy key",
"description": "URL is the API URL for this deploy-key",
"format": "uri",
"type": "string",
"x-go-name": "URL"
@@ -26543,6 +26575,56 @@
]
}
},
"/repos/{owner}/{repo}/keys/tokens": {
"post": {
"operationId": "repoCreateDeployToken",
"parameters": [
{
"description": "owner of the repo",
"in": "path",
"name": "owner",
"required": true,
"schema": {
"type": "string"
}
},
{
"description": "name of the repo",
"in": "path",
"name": "repo",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateDeployKeyTokenOption"
}
}
},
"x-originalParamName": "body"
},
"responses": {
"201": {
"$ref": "#/components/responses/DeployKey"
},
"404": {
"$ref": "#/components/responses/notFound"
},
"422": {
"$ref": "#/components/responses/validationError"
}
},
"summary": "Add a deploy token to a repository, it authenticates git over HTTPS",
"tags": [
"repository"
]
}
},
"/repos/{owner}/{repo}/keys/{id}": {
"delete": {
"operationId": "repoDeleteKey",