Skip to content

Commit 2575481

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: (45 commits) Include resource state events in Gitlab downloads (go-gitea#29382) Add API to get PR by base/head (go-gitea#29242) [skip ci] Updated translations via Crowdin Improve Documentation for Restoration from backup (go-gitea#29321) Refactor "user/active" related logic (go-gitea#29390) Remove jQuery AJAX from the archive download links (go-gitea#29380) Add tailwindcss (go-gitea#29357) Add missing space (go-gitea#29393) Integrate alpine `noarch` packages into other architectures index (go-gitea#29137) enforce maxlength in frontend (go-gitea#29389) Remove incorrect and unnecessary Escape from templates (go-gitea#29394) Make actions animation rotate counterclockwisely (go-gitea#29378) Use `crypto/sha256` (go-gitea#29386) Add `io.Closer` guidelines (go-gitea#29387) Remove jQuery AJAX from the notice selection deletion button (go-gitea#29381) Refactor Safe modifier (go-gitea#29392) Add attachment support for code review comments (go-gitea#29220) Refactor modules/git global variables (go-gitea#29376) Remove jQuery from the code diff expansion buttons (go-gitea#29385) Remove jQuery AJAX from the markdown editor preview (go-gitea#29384) ...
2 parents 0009684 + 17f170e commit 2575481

File tree

283 files changed

+4179
-2571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

283 files changed

+4179
-2571
lines changed

.github/workflows/pull-db-tests.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ jobs:
3737
MINIO_ROOT_PASSWORD: 12345678
3838
ports:
3939
- "9000:9000"
40-
simplesaml:
41-
image: allspice/simple-saml
42-
ports:
43-
- "8080:8080"
44-
env:
45-
SIMPLESAMLPHP_SP_ENTITY_ID: http://localhost:3002/user/saml/test-sp/metadata
46-
SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE: http://localhost:3002/user/saml/test-sp/acs
47-
SIMPLESAMLPHP_SP_SINGLE_LOGOUT_SERVICE: http://localhost:3002/user/saml/test-sp/acs
4840
steps:
4941
- uses: actions/checkout@v4
5042
- uses: actions/setup-go@v5

.stylelintrc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ rules:
9898
at-rule-allowed-list: null
9999
at-rule-disallowed-list: null
100100
at-rule-empty-line-before: null
101-
at-rule-no-unknown: true
101+
at-rule-no-unknown: [true, {ignoreAtRules: [tailwind]}]
102102
at-rule-no-vendor-prefix: true
103103
at-rule-property-required-list: null
104104
block-no-empty: true

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ Rui Chen <[email protected]> (@chenrui333)
5959
Nanguan Lin <[email protected]> (@lng2020)
6060
kerwin612 <[email protected]> (@kerwin612)
6161
Gary Wang <[email protected]> (@BLumia)
62+
Tim-Niclas Oelschläger <[email protected]> (@zokkis)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/m
119119
FOMANTIC_WORK_DIR := web_src/fomantic
120120

121121
WEBPACK_SOURCES := $(shell find web_src/js web_src/css -type f)
122-
WEBPACK_CONFIGS := webpack.config.js
122+
WEBPACK_CONFIGS := webpack.config.js tailwind.config.js
123123
WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
124124
WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts public/assets/img/webpack
125125

assets/go-licenses.json

Lines changed: 0 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/generate-svg.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ import {optimize} from 'svgo';
44
import {parse} from 'node:path';
55
import {readFile, writeFile, mkdir} from 'node:fs/promises';
66
import {fileURLToPath} from 'node:url';
7+
import {exit} from 'node:process';
78

89
const glob = (pattern) => fastGlob.sync(pattern, {
910
cwd: fileURLToPath(new URL('..', import.meta.url)),
1011
absolute: true,
1112
});
1213

13-
function exit(err) {
14+
function doExit(err) {
1415
if (err) console.error(err);
15-
process.exit(err ? 1 : 0);
16+
exit(err ? 1 : 0);
1617
}
1718

1819
async function processFile(file, {prefix, fullName} = {}) {
@@ -64,7 +65,7 @@ async function main() {
6465
}
6566

6667
try {
67-
exit(await main());
68+
doExit(await main());
6869
} catch (err) {
69-
exit(err);
70+
doExit(err);
7071
}

docs/content/administration/backup-and-restore.en-us.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ cd gitea-dump-1610949662
9292
mv app.ini /etc/gitea/conf/app.ini
9393
mv data/* /var/lib/gitea/data/
9494
mv log/* /var/lib/gitea/log/
95-
mv repos/* /var/lib/gitea/gitea-repositories/
95+
mv repos/* /var/lib/gitea/data/gitea-repositories/
9696
chown -R gitea:gitea /etc/gitea/conf/app.ini /var/lib/gitea
9797

9898
# mysql
@@ -111,6 +111,8 @@ With Gitea running, and from the directory Gitea's binary is located, execute: `
111111

112112
This ensures that application and configuration file paths in repository Git Hooks are consistent and applicable to the current installation. If these paths are not updated, repository `push` actions will fail.
113113

114+
If you still have issues, consider running `./gitea doctor check` to inspect possible errors (or run with `--fix`).
115+
114116
### Using Docker (`restore`)
115117

116118
There is also no support for a recovery command in a Docker-based gitea instance. The restore process contains the same steps as described in the previous section but with different paths.

docs/content/administration/mail-templates.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ the messages. Here's a list of some of them:
266266
| `AppDomain` | - | Any | Gitea's host name |
267267
| `EllipsisString` | string, int | Any | Truncates a string to the specified length; adds ellipsis as needed |
268268
| `Str2html` | string | Body only | Sanitizes text by removing any HTML tags from it. |
269-
| `Safe` | string | Body only | Takes the input as HTML; can be used for `.ReviewComments.RenderedContent`. |
269+
| `SafeHTML` | string | Body only | Takes the input as HTML; can be used for `.ReviewComments.RenderedContent`. |
270270

271271
These are _functions_, not metadata, so they have to be used:
272272

docs/content/administration/mail-templates.zh-cn.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,14 @@ _主题_ 和 _邮件正文_ 由 [Golang的模板引擎](https://go.dev/pkg/text/
242242

243243
模板系统包含一些函数,可用于进一步处理和格式化消息。以下是其中一些函数的列表:
244244

245-
| 函数名 | 参数 | 可用于 | 用法 |
246-
| ----------------- | ----------- | ------------ | --------------------------------------------------------------------------------- |
247-
| `AppUrl` | - | 任何地方 | Gitea 的 URL |
248-
| `AppName` | - | 任何地方 |`app.ini` 中设置,通常为 "Gitea" |
249-
| `AppDomain` | - | 任何地方 | Gitea 的主机名 |
250-
| `EllipsisString` | string, int | 任何地方 | 将字符串截断为指定长度;根据需要添加省略号 |
251-
| `Str2html` | string | 仅正文部分 | 通过删除其中的 HTML 标签对文本进行清理 |
252-
| `Safe` | string | 仅正文部分 | 将输入作为 HTML 处理;可用于 `.ReviewComments.RenderedContent` 等字段 |
245+
| 函数名 | 参数 | 可用于 | 用法 |
246+
|------------------| ----------- | ------------ | --------------------------------------------------------------------------------- |
247+
| `AppUrl` | - | 任何地方 | Gitea 的 URL |
248+
| `AppName` | - | 任何地方 |`app.ini` 中设置,通常为 "Gitea" |
249+
| `AppDomain` | - | 任何地方 | Gitea 的主机名 |
250+
| `EllipsisString` | string, int | 任何地方 | 将字符串截断为指定长度;根据需要添加省略号 |
251+
| `Str2html` | string | 仅正文部分 | 通过删除其中的 HTML 标签对文本进行清理 |
252+
| `SafeHTML` | string | 仅正文部分 | 将输入作为 HTML 处理;可用于 `.ReviewComments.RenderedContent` 等字段 |
253253

254254
这些都是 _函数_,而不是元数据,因此必须按以下方式使用:
255255

docs/content/contributing/guidelines-backend.en-us.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ i.e. `services/user`, `models/repository`.
101101
Since there are some packages which use the same package name, it is possible that you find packages like `modules/user`, `models/user`, and `services/user`. When these packages are imported in one Go file, it's difficult to know which package we are using and if it's a variable name or an import name. So, we always recommend to use import aliases. To differ from package variables which are commonly in camelCase, just use **snake_case** for import aliases.
102102
i.e. `import user_service "code.gitea.io/gitea/services/user"`
103103

104+
### Implementing `io.Closer`
105+
106+
If a type implements `io.Closer`, calling `Close` multiple times must not fail or `panic` but return an error or `nil`.
107+
104108
### Important Gotchas
105109

106110
- Never write `x.Update(exemplar)` without an explicit `WHERE` clause:

docs/content/usage/authentication.en-us.md

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -349,72 +349,3 @@ If set `ENABLE_REVERSE_PROXY_FULL_NAME=true`, a user full name expected in `X-WE
349349
You can also limit the reverse proxy's IP address range with `REVERSE_PROXY_TRUSTED_PROXIES` which default value is `127.0.0.0/8,::1/128`. By `REVERSE_PROXY_LIMIT`, you can limit trusted proxies level.
350350

351351
Notice: Reverse Proxy Auth doesn't support the API. You still need an access token or basic auth to make API requests.
352-
353-
## SAML
354-
355-
### Configuring Gitea as a SAML 2.0 Service Provider
356-
357-
- Navigate to `Site Administration > Identity & Access > Authentication Sources`.
358-
- Click the `Add Authentication Source` button.
359-
- Select `SAML` as the authentication type.
360-
361-
#### Features Not Yet Supported
362-
363-
Currently, auto-registration is not supported for SAML. During the external account linking process the user will be prompted to set a username and email address or link to an existing account.
364-
365-
SAML group mapping is not supported.
366-
367-
#### Settings
368-
369-
- `Authentication Name` **(required)**
370-
371-
- The name of this authentication source (appears in the Gitea ACS and metadata URLs)
372-
373-
- `SAML NameID Format` **(required)**
374-
375-
- This specifies how Identity Provider (IdP) users are mapped to Gitea users. This option will be provider specific.
376-
377-
- `Icon URL` (optional)
378-
379-
- URL of an icon to display on the Sign-In page for this authentication source.
380-
381-
- `[Insecure] Skip Assertion Signature Validation` (optional)
382-
383-
- This option is not recommended and disables integrity verification of IdP SAML assertions.
384-
385-
- `Identity Provider Metadata URL` (optional if XML set)
386-
387-
- The URL of the IdP metadata endpoint.
388-
- This field must be set if `Identity Provider Metadata XML` is left blank.
389-
390-
- `Identity Provider Metadata XML` (optional if URL set)
391-
392-
- The XML returned by the IdP metadata endpoint.
393-
- This field must be set if `Identity Provider Metadata URL` is left blank.
394-
395-
- `Service Provider Certificate` (optional)
396-
397-
- X.509-formatted certificate (with `Service Provider Private Key`) used for signing SAML requests.
398-
- A certificate will be generated if this field is left blank.
399-
400-
- `Service Provider Private Key` (optional)
401-
402-
- DSA/RSA private key (with `Service Provider Certificate`) used for signing SAML requests.
403-
- A private key will be generated if this field is left blank.
404-
405-
- `Email Assertion Key` (optional)
406-
407-
- The SAML assertion key used for the IdP user's email (depends on provider configuration).
408-
409-
- `Name Assertion Key` (optional)
410-
411-
- The SAML assertion key used for the IdP user's nickname (depends on provider configuration).
412-
413-
- `Username Assertion Key` (optional)
414-
415-
- The SAML assertion key used for the IdP user's username (depends on provider configuration).
416-
417-
### Configuring a SAML 2.0 Identity Provider to use Gitea
418-
419-
- The service provider assertion consumer service url will look like: `http(s)://[mydomain]/user/saml/[Authentication Name]/acs`.
420-
- The service provider metadata url will look like: `http(s)://[mydomain]/user/saml/[Authentication Name]/metadata`.

go.mod

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ require (
7878
github.com/mholt/archiver/v3 v3.5.1
7979
github.com/microcosm-cc/bluemonday v1.0.26
8080
github.com/minio/minio-go/v7 v7.0.66
81-
github.com/minio/sha256-simd v1.0.1
8281
github.com/msteinert/pam v1.2.0
8382
github.com/nektos/act v0.2.52
8483
github.com/niklasfasching/go-org v1.7.0
@@ -91,8 +90,6 @@ require (
9190
github.com/quasoft/websspi v1.1.2
9291
github.com/redis/go-redis/v9 v9.4.0
9392
github.com/robfig/cron/v3 v3.0.1
94-
github.com/russellhaering/gosaml2 v0.9.1
95-
github.com/russellhaering/goxmldsig v1.3.0
9693
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1
9794
github.com/sassoftware/go-rpmutils v0.2.1-0.20240124161140-277b154961dd
9895
github.com/sergi/go-diff v1.3.1
@@ -145,7 +142,6 @@ require (
145142
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
146143
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
147144
github.com/aymerick/douceur v0.2.0 // indirect
148-
github.com/beevik/etree v1.1.0 // indirect
149145
github.com/beorn7/perks v1.0.1 // indirect
150146
github.com/bits-and-blooms/bitset v1.13.0 // indirect
151147
github.com/blevesearch/bleve_index_api v1.1.5 // indirect
@@ -219,7 +215,6 @@ require (
219215
github.com/imdario/mergo v0.3.16 // indirect
220216
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
221217
github.com/jessevdk/go-flags v1.5.0 // indirect
222-
github.com/jonboulle/clockwork v0.3.0 // indirect
223218
github.com/josharian/intern v1.0.0 // indirect
224219
github.com/kevinburke/ssh_config v1.2.0 // indirect
225220
github.com/klauspost/pgzip v1.2.6 // indirect
@@ -229,12 +224,12 @@ require (
229224
github.com/magiconair/properties v1.8.7 // indirect
230225
github.com/mailru/easyjson v0.7.7 // indirect
231226
github.com/markbates/going v1.0.3 // indirect
232-
github.com/mattermost/xml-roundtrip-validator v0.1.0 // indirect
233227
github.com/mattn/go-colorable v0.1.13 // indirect
234228
github.com/mattn/go-runewidth v0.0.15 // indirect
235229
github.com/mholt/acmez v1.2.0 // indirect
236230
github.com/miekg/dns v1.1.58 // indirect
237231
github.com/minio/md5-simd v1.1.2 // indirect
232+
github.com/minio/sha256-simd v1.0.1 // indirect
238233
github.com/mitchellh/copystructure v1.2.0 // indirect
239234
github.com/mitchellh/mapstructure v1.5.0 // indirect
240235
github.com/mitchellh/reflectwalk v1.0.2 // indirect

go.sum

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3d
130130
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw=
131131
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
132132
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
133-
github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs=
134-
github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A=
135133
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
136134
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
137135
github.com/bits-and-blooms/bitset v1.1.10/go.mod h1:w0XsmFg8qg6cmpTtJ0z3pKgjTDBMMnI/+I2syrE6XBE=
@@ -568,9 +566,6 @@ github.com/jhillyerd/enmime v1.1.0 h1:ubaIzg68VY7CMCe2YbHe6nkRvU9vujixTkNz3EBvZO
568566
github.com/jhillyerd/enmime v1.1.0/go.mod h1:FRFuUPCLh8PByQv+8xRcLO9QHqaqTqreYhopv5eyk4I=
569567
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
570568
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
571-
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
572-
github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
573-
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
574569
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
575570
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
576571
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
@@ -639,8 +634,6 @@ github.com/markbates/going v1.0.3 h1:mY45T5TvW+Xz5A6jY7lf4+NLg9D8+iuStIHyR7M8qsE
639634
github.com/markbates/going v1.0.3/go.mod h1:fQiT6v6yQar9UD6bd/D4Z5Afbk9J6BBVBtLiyY4gp2o=
640635
github.com/markbates/goth v1.78.0 h1:7VEIFDycJp9deyVv3YraGBPdD0ZYQW93Y3Aw1eVP3BY=
641636
github.com/markbates/goth v1.78.0/go.mod h1:X6xdNgpapSENS0O35iTBBcMHoJDQDfI9bJl+APCkYMc=
642-
github.com/mattermost/xml-roundtrip-validator v0.1.0 h1:RXbVD2UAl7A7nOTR4u7E3ILa4IbtvKBHw64LDsmu9hU=
643-
github.com/mattermost/xml-roundtrip-validator v0.1.0/go.mod h1:qccnGMcpgwcNaBnxqpJpWWUiPNr5H3O8eDgGV9gT5To=
644637
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
645638
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
646639
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
@@ -773,17 +766,12 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
773766
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
774767
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
775768
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
776-
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
777769
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
778770
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
779771
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
780772
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
781773
github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc=
782774
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
783-
github.com/russellhaering/gosaml2 v0.9.1 h1:H/whrl8NuSoxyW46Ww5lKPskm+5K+qYLw9afqJ/Zef0=
784-
github.com/russellhaering/gosaml2 v0.9.1/go.mod h1:ja+qgbayxm+0mxBRLMSUuX3COqy+sb0RRhIGun/W2kc=
785-
github.com/russellhaering/goxmldsig v1.3.0 h1:DllIWUgMy0cRUMfGiASiYEa35nsieyD3cigIwLonTPM=
786-
github.com/russellhaering/goxmldsig v1.3.0/go.mod h1:gM4MDENBQf7M+V824SGfyIUVFWydB7n0KkEubVJl+Tw=
787775
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
788776
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
789777
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

models/auth/oauth2.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"crypto/sha256"
99
"encoding/base32"
1010
"encoding/base64"
11-
"encoding/gob"
1211
"fmt"
1312
"net"
1413
"net/url"
@@ -82,10 +81,6 @@ func Init(ctx context.Context) error {
8281
builtinAllClientIDs = append(builtinAllClientIDs, clientID)
8382
}
8483

85-
// This is needed in order to encode and store the struct in the goth/gothic session
86-
// during the process of linking the external user.
87-
gob.Register(LinkAccountUser{})
88-
8984
var registeredApps []*OAuth2Application
9085
if err := db.GetEngine(ctx).In("client_id", builtinAllClientIDs).Find(&registeredApps); err != nil {
9186
return err
@@ -610,6 +605,21 @@ func (err ErrOAuthApplicationNotFound) Unwrap() error {
610605
return util.ErrNotExist
611606
}
612607

608+
// GetActiveOAuth2SourceByName returns a OAuth2 AuthSource based on the given name
609+
func GetActiveOAuth2SourceByName(ctx context.Context, name string) (*Source, error) {
610+
authSource := new(Source)
611+
has, err := db.GetEngine(ctx).Where("name = ? and type = ? and is_active = ?", name, OAuth2, true).Get(authSource)
612+
if err != nil {
613+
return nil, err
614+
}
615+
616+
if !has {
617+
return nil, fmt.Errorf("oauth2 source not found, name: %q", name)
618+
}
619+
620+
return authSource, nil
621+
}
622+
613623
func DeleteOAuth2RelictsByUserID(ctx context.Context, userID int64) error {
614624
deleteCond := builder.Select("id").From("oauth2_grant").Where(builder.Eq{"oauth2_grant.user_id": userID})
615625

0 commit comments

Comments
 (0)