-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into lunny/rename_middlewares
- Loading branch information
Showing
494 changed files
with
31,336 additions
and
14,479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
date: "2016-12-01T16:00:00+02:00" | ||
title: "進階" | ||
slug: "advanced" | ||
weight: 30 | ||
toc: false | ||
draft: false | ||
menu: | ||
sidebar: | ||
name: "進階" | ||
weight: 40 | ||
identifier: "advanced" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
date: "2016-12-01T16:00:00+02:00" | ||
title: "開發人員" | ||
slug: "developers" | ||
weight: 40 | ||
toc: false | ||
draft: false | ||
menu: | ||
sidebar: | ||
name: "開發人員" | ||
weight: 50 | ||
identifier: "developers" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
date: "2019-04-15T17:29:00+08:00" | ||
title: "整合" | ||
slug: "integrations" | ||
weight: 40 | ||
toc: false | ||
draft: false | ||
menu: | ||
sidebar: | ||
parent: "developers" | ||
name: "整合" | ||
weight: 65 | ||
identifier: "integrations" | ||
--- | ||
|
||
# 整合 | ||
|
||
Gitea 有著很棒的第三方整合社群, 以及其它有著一流支援的專案。 | ||
|
||
我們持續的整理一份清單以追蹤他們!請到 [awesome-gitea](https://gitea.com/gitea/awesome-gitea) 查看。 | ||
|
||
如果您正在找尋有關 [CI/CD](https://gitea.com/gitea/awesome-gitea#devops)、[SDK](https://gitea.com/gitea/awesome-gitea#sdk) 或是其它佈景主題,您可以在存儲庫 [awesome-gitea](https://gitea.com/gitea/awesome-gitea) 找到他們。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
date: "2019-04-15T17:29:00+08:00" | ||
title: "遷移介面" | ||
slug: "migrations-interfaces" | ||
weight: 30 | ||
toc: false | ||
draft: false | ||
menu: | ||
sidebar: | ||
parent: "developers" | ||
name: "遷移介面" | ||
weight: 55 | ||
identifier: "migrations-interfaces" | ||
--- | ||
|
||
# 遷移功能 | ||
|
||
完整的遷移從 Gitea 1.9.0 開始提供。它定義了兩個介面用來從其它 Git 託管平臺遷移儲存庫資料到 Gitea,未來或許會提供遷移到其它 git 託管平臺。 | ||
目前已實作了從 Github, Gitlab 和其它 Gitea 遷移資料。 | ||
|
||
Gitea 定義了一些基本物件於套件 [modules/migrations/base](https://github.com/go-gitea/gitea/tree/master/modules/migrations/base)。 | ||
分別是 `Repository`, `Milestone`, `Release`, `ReleaseAsset`, `Label`, `Issue`, `Comment`, `PullRequest`, `Reaction`, `Review`, `ReviewComment`。 | ||
|
||
## Downloader 介面 | ||
|
||
從新的 Git 託管平臺遷移,有兩個新的步驟。 | ||
|
||
- 您必須實作一個 `Downloader`,它用來取得儲存庫資訊。 | ||
- 您必須實作一個 `DownloaderFactory`,它用來偵測 URL 是否符合並建立上述的 `Downloader`。 | ||
- 您需要在 `init()` 透過 `RegisterDownloaderFactory` 來註冊 `DownloaderFactory`。 | ||
|
||
您可以在 [downloader.go](https://github.com/go-gitea/gitea/blob/master/modules/migrations/base/downloader.go) 中找到這些介面。 | ||
|
||
## Uploader 介面 | ||
|
||
目前只有 `GiteaLocalUploader` 被實作出來,所以我們只能通過 `Uploader` 儲存已下載的資料到本地的 Gitea 實例。 | ||
目前尚未支援其它 Uploader。 | ||
|
||
您可以在 [uploader.go](https://github.com/go-gitea/gitea/blob/master/modules/migrations/base/uploader.go) 中找到這些介面。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- | ||
date: "2019-04-19:44:00+01:00" | ||
title: "OAuth2 提供者" | ||
slug: "oauth2-provider" | ||
weight: 41 | ||
toc: false | ||
draft: false | ||
menu: | ||
sidebar: | ||
parent: "developers" | ||
name: "OAuth2 提供者" | ||
weight: 41 | ||
identifier: "oauth2-provider" | ||
--- | ||
|
||
# OAuth2 提供者 | ||
|
||
**目錄** | ||
|
||
{{< toc >}} | ||
|
||
Gitea 支援作為 OAuth2 提供者,能讓第三方程式能在使用者同意下存取 Gitea 的資源。此功能自 1.8.0 版開始提供。 | ||
|
||
## Endpoint | ||
|
||
| Endpoint | URL | | ||
| ---------------------- | --------------------------- | | ||
| Authorization Endpoint | `/login/oauth/authorize` | | ||
| Access Token Endpoint | `/login/oauth/access_token` | | ||
|
||
## 支援的 OAuth2 Grant | ||
|
||
目前 Gitea 只支援 [**Authorization Code Grant**](https://tools.ietf.org/html/rfc6749#section-1.3.1) 標準並額外支援下列擴充標準: | ||
|
||
- [Proof Key for Code Exchange (PKCE)](https://tools.ietf.org/html/rfc7636) | ||
- [OpenID Connect (OIDC)](https://openid.net/specs/openid-connect-core-1_0.html#CodeFlowAuth) | ||
|
||
若想要讓第三方程式使用 Authorization Code Grant,需先在「設定」(`/user/settings/applications`)中註冊一個新的應用程式。 | ||
|
||
## Scope | ||
|
||
目前 Gitea 尚未支援 scope (參見 [#4300](https://github.com/go-gitea/gitea/issues/4300)),所有的第三方程式都可獲得該使用者及他所屬的組織中所有資源的存取權。 | ||
|
||
## 範例 | ||
|
||
**備註:** 此範例未使用 PKCE。 | ||
|
||
1. 重新導向使用者到 authorization endpoint 以獲得他同意授權存取資源: | ||
<!-- 1. Redirect to user to the authorization endpoint in order to get his/her consent for accessing the resources: --> | ||
|
||
```curl | ||
https://[YOUR-GITEA-URL]/login/oauth/authorize?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI& response_type=code&state=STATE | ||
``` | ||
|
||
在設定中註冊應用程式以獲得 `CLIENT_ID`。`STATE` 是一個隨機的字串,它將在使用者授權後發送回您的應用程式。`state` 參數是選用的,但應該要用它來防止 CSRF 攻擊。 | ||
|
||
![Authorization Page](/authorize.png) | ||
|
||
使用者將會被詢問是否授權給您的應用程式。如果它們同意了,使用者將被重新導向到 `REDIRECT_URL`,例如: | ||
|
||
```curl | ||
https://[REDIRECT_URI]?code=RETURNED_CODE&state=STATE | ||
``` | ||
|
||
1. 使用重新導向提供的 `code`,您可以要求一個新的應用程式和 Refresh Token。Access Token Endpoint 接受 POST 請求使用 `application/json` 或 `application/x-www-form-urlencoded` 類型的請求內容,例如: | ||
|
||
```curl | ||
POST https://[YOUR-GITEA-URL]/login/oauth/access_token | ||
``` | ||
|
||
```json | ||
{ | ||
"client_id": "YOUR_CLIENT_ID", | ||
"client_secret": "YOUR_CLIENT_SECRET", | ||
"code": "RETURNED_CODE", | ||
"grant_type": "authorization_code", | ||
"redirect_uri": "REDIRECT_URI" | ||
} | ||
``` | ||
|
||
回應: | ||
|
||
```json | ||
{ | ||
"access_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjowLCJleHAiOjE1NTUxNzk5MTIsImlhdCI6MTU1NTE3NjMxMn0.0-iFsAwBtxuckA0sNZ6QpBQmywVPz129u75vOM7wPJecw5wqGyBkmstfJHAjEOqrAf_V5Z-1QYeCh_Cz4RiKug", | ||
"token_type": "bearer", | ||
"expires_in": 3600, | ||
"refresh_token": "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJnbnQiOjIsInR0IjoxLCJjbnQiOjEsImV4cCI6MTU1NzgwNDMxMiwiaWF0IjoxNTU1MTc2MzEyfQ.S_HZQBy4q9r5SEzNGNIoFClT43HPNDbUdHH-GYNYYdkRfft6XptJBkUQscZsGxOW975Yk6RbgtGvq1nkEcklOw" | ||
} | ||
``` | ||
|
||
`CLIENT_SECRET` 是產生給此應用程式的唯一密鑰。請記住該密鑰只會在您於 Gitea 建立/註冊應用程式時出現一次。若您遺失密鑰,您必須在該應用程式的設定中重新產生密鑰。 | ||
|
||
`access_token` 請求中的 `REDIRECT_URI` 必須符合 `authorize` 請求中的 `REDIRECT_URI`。 | ||
|
||
1. 發送 [API requests](https://docs.gitea.io/en-us/api-usage#oauth2) 時使用 `access_token` 以存取使用者的資源。 |
Oops, something went wrong.