From 3a04d6f43f429957323dd58d0e720d8d3bf7fee1 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 16 May 2021 09:41:37 +0100 Subject: [PATCH 01/28] Systemd needs After as well as Require (#15881) If the gitea service is stopped because of the db going down it needs an `After=db.service` to ensure it is restarted in addition to the `Requires=db.service` to ensure that the db is started before gitea is started. Fix #15866 Signed-off-by: Andrew Thornton Co-authored-by: Lunny Xiao --- contrib/systemd/gitea.service | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/systemd/gitea.service b/contrib/systemd/gitea.service index ac6a13ec573e7..cd3b8f9ec4bfd 100644 --- a/contrib/systemd/gitea.service +++ b/contrib/systemd/gitea.service @@ -7,10 +7,19 @@ After=network.target ### # #Requires=mysql.service +#After=mysql.service +# #Requires=mariadb.service +#After=mariadb.service +# #Requires=postgresql.service +#After=postgresql.service +# #Requires=memcached.service +#After=memcached.service +# #Requires=redis.service +#After=redis.service # ### # If using socket activation for main http/s From 0bf8d34630a9f4fa9314dfa1ecbd32505f341675 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 16 May 2021 19:58:26 +0800 Subject: [PATCH 02/28] improve empty notice (#15890) --- models/admin.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/models/admin.go b/models/admin.go index 7911ce75112cd..3a784d66964ab 100644 --- a/models/admin.go +++ b/models/admin.go @@ -114,6 +114,11 @@ func DeleteNotice(id int64) error { // DeleteNotices deletes all notices with ID from start to end (inclusive). func DeleteNotices(start, end int64) error { + if start == 0 && end == 0 { + _, err := x.Exec("DELETE FROM notice") + return err + } + sess := x.Where("id >= ?", start) if end > 0 { sess.And("id <= ?", end) From c3aaf5eafd91b881ca67ab51e0cc2fd17a5b7921 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Sun, 16 May 2021 23:51:53 +1000 Subject: [PATCH 03/28] Rework Token API comments (#15162) Move the token API discussion into a common section discussing the generation and listing of the tokens. Add a note on the display of the sha1 during creation and listing. Co-authored-by: Norwin --- .../content/doc/developers/api-usage.en-us.md | 58 ++++++++++++------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/docs/content/doc/developers/api-usage.en-us.md b/docs/content/doc/developers/api-usage.en-us.md index 15fedbe2c164d..06cbc9b72e1e1 100644 --- a/docs/content/doc/developers/api-usage.en-us.md +++ b/docs/content/doc/developers/api-usage.en-us.md @@ -40,8 +40,42 @@ better understand this by looking at the code -- as of this writing, Gitea parses queries and headers to find the token in [modules/auth/auth.go](https://github.com/go-gitea/gitea/blob/6efdcaed86565c91a3dc77631372a9cc45a58e89/modules/auth/auth.go#L47). -You can create an API key token via your Gitea installation's web interface: -`Settings | Applications | Generate New Token`. +## Generating and listing API tokens + +A new token can be generated with a `POST` request to +`/users/:name/tokens`. + +Note that `/users/:name/tokens` is a special endpoint and requires you +to authenticate using `BasicAuth` and a password, as follows: + + +```sh +$ curl -XPOST -H "Content-Type: application/json" -k -d '{"name":"test"}' -u username:password https://gitea.your.host/api/v1/users//tokens +{"id":1,"name":"test","sha1":"9fcb1158165773dd010fca5f0cf7174316c3e37d","token_last_eight":"16c3e37d"} +``` + +The ``sha1`` (the token) is only returned once and is not stored in +plain-text. It will not be displayed when listing tokens with a `GET` +request; e.g. + +```sh +$ curl --request GET --url https://yourusername:password@gitea.your.host/api/v1/users//tokens +[{"name":"test","sha1":"","token_last_eight:"........":},{"name":"dev","sha1":"","token_last_eight":"........"}] +``` + +To use the API with basic authentication with two factor authentication +enabled, you'll need to send an additional header that contains the one +time password (6 digitrotating token). +An example of the header is `X-Gitea-OTP: 123456` where `123456` +is where you'd place the code from your authenticator. +Here is how the request would look like in curl: + +```sh +$ curl -H "X-Gitea-OTP: 123456" --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens +``` + +You can also create an API key token via your Gitea installation's web +interface: `Settings | Applications | Generate New Token`. ## OAuth2 Provider @@ -82,26 +116,6 @@ or on The OpenAPI document is at: `https://gitea.your.host/swagger.v1.json` -## Listing your issued tokens via the API - -As mentioned in -[#3842](https://github.com/go-gitea/gitea/issues/3842#issuecomment-397743346), -`/users/:name/tokens` is special and requires you to authenticate -using BasicAuth, as follows: - -### Using basic authentication: - -```sh -$ curl --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens -[{"name":"test","sha1":"..."},{"name":"dev","sha1":"..."}] -``` - -As of v1.8.0 of Gitea, if using basic authentication with the API and your user has two factor authentication enabled, you'll need to send an additional header that contains the one time password (6 digit rotating token). An example of the header is `X-Gitea-OTP: 123456` where `123456` is where you'd place the code from your authenticator. Here is how the request would look like in curl: - -```sh -$ curl -H "X-Gitea-OTP: 123456" --request GET --url https://yourusername:yourpassword@gitea.your.host/api/v1/users/yourusername/tokens -``` - ## Sudo The API allows admin users to sudo API requests as another user. Simply add either a `sudo=` parameter or `Sudo:` request header with the username of the user to sudo. From 892e6561ff76d1fb4fd498b7ac4ed4ff77acbb7b Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 17 May 2021 02:24:47 +0800 Subject: [PATCH 04/28] Use a special name for update default branch on repository setting (#15893) --- options/locale/locale_en-US.ini | 1 + templates/repo/settings/branches.tmpl | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 936677e31d333..ac1a0d9726395 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1550,6 +1550,7 @@ settings.email_notifications.disable = Disable Email Notifications settings.email_notifications.submit = Set Email Preference settings.site = Website settings.update_settings = Update Settings +settings.branches.update_default_branch = Update Default Branch settings.advanced_settings = Advanced Settings settings.wiki_desc = Enable Repository Wiki settings.use_internal_wiki = Use Built-In Wiki diff --git a/templates/repo/settings/branches.tmpl b/templates/repo/settings/branches.tmpl index fbe9a7463e5e2..ccf6abbb81c01 100644 --- a/templates/repo/settings/branches.tmpl +++ b/templates/repo/settings/branches.tmpl @@ -35,7 +35,7 @@ {{end}} - + {{end}} From a32bfd867dc1619f3247310d16845c8b7b854e0e Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 16 May 2021 22:18:18 +0200 Subject: [PATCH 05/28] Issue sidebar and misc css fixes (#15524) - Replace remaining font icons with SVG in issue sidebar - Rework issue due date display - Realign avatar in timeline - Fix font size in repo search and code explore - Consolidate active button styles - Fix loading form on arc-green - Align time tracker buttons vertically Fixes: https://github.com/go-gitea/gitea/issues/15896 --- templates/explore/code.tmpl | 2 +- .../repo/issue/view_content/sidebar.tmpl | 114 +++++++++--------- templates/repo/search.tmpl | 2 +- templates/user/profile.tmpl | 20 +-- web_src/less/_base.less | 16 ++- web_src/less/_editor.less | 4 + web_src/less/_repository.less | 2 +- web_src/less/helpers.less | 1 - web_src/less/themes/theme-arc-green.less | 15 +-- 9 files changed, 92 insertions(+), 84 deletions(-) diff --git a/templates/explore/code.tmpl b/templates/explore/code.tmpl index 6332413a173a6..8cc1b71a7ad0a 100644 --- a/templates/explore/code.tmpl +++ b/templates/explore/code.tmpl @@ -50,7 +50,7 @@ {{.}} {{end}} -
    {{.FormattedLines | Safe}}
+ {{.FormattedLines | Safe}} diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 30acb839b50ac..e3530fc45ba1f 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -6,12 +6,12 @@