Skip to content

Commit 6fbc2c7

Browse files
authored
Merge branch 'main' into fix-superfluous-writeHeader
2 parents b458457 + 05fb1f6 commit 6fbc2c7

File tree

11 files changed

+66
-10
lines changed

11 files changed

+66
-10
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ test-backend:
359359
@$(GO) test $(GOTESTFLAGS) -mod=vendor -tags='$(TEST_TAGS)' $(GO_PACKAGES)
360360

361361
.PHONY: test-frontend
362-
test-frontend:
362+
test-frontend: node_modules
363363
@NODE_OPTIONS="--experimental-vm-modules --no-warnings" npx jest --color
364364

365365
.PHONY: test-check

contrib/environment-to-ini/environment-to-ini.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ func runEnvironmentToIni(c *cli.Context) error {
110110
}
111111
cfg.NameMapper = ini.SnackCase
112112

113+
changed := false
114+
113115
prefix := c.String("prefix") + "__"
114116

115117
for _, kv := range os.Environ() {
@@ -143,15 +145,21 @@ func runEnvironmentToIni(c *cli.Context) error {
143145
continue
144146
}
145147
}
148+
oldValue := key.Value()
149+
if !changed && oldValue != value {
150+
changed = true
151+
}
146152
key.SetValue(value)
147153
}
148154
destination := c.String("out")
149155
if len(destination) == 0 {
150156
destination = setting.CustomConf
151157
}
152-
err = cfg.SaveTo(destination)
153-
if err != nil {
154-
return err
158+
if destination != setting.CustomConf || changed {
159+
err = cfg.SaveTo(destination)
160+
if err != nil {
161+
return err
162+
}
155163
}
156164
if c.Bool("clear") {
157165
for _, kv := range os.Environ() {

docs/content/doc/advanced/logging-documentation.en-us.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,8 @@ Gitea includes built-in log rotation, which should be enough for most deployment
437437

438438
- Disable built-in log rotation by setting `LOG_ROTATE` to `false` in your `app.ini`.
439439
- Install `logrotate`.
440-
- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details. In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10`, or run `gitea manager logging release-and-reopen` (with the appropriate environment). Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections.
441-
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
440+
- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details. In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10` to the `gitea` process itself, or run `gitea manager logging release-and-reopen` (with the appropriate environment). Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections.
441+
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
442+
- If you are using docker and are running from outside of the container you can use `docker exec -u $OS_USER $CONTAINER_NAME sh -c 'gitea manager logging release-and-reopen'` or `docker exec $CONTAINER_NAME sh -c '/bin/s6-svc -1 /etc/s6/gitea/'` or send `USR1` directly to the gitea process itself.
442443

443444
The next `logrotate` jobs will include your configurations, so no restart is needed. You can also immediately reload `logrotate` with `logrotate /etc/logrotate.conf --force`.

docs/content/doc/usage/reverse-proxies.en-us.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,24 @@ If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite a
222222
<?xml version="1.0" encoding="UTF-8"?>
223223
<configuration>
224224
<system.webServer>
225+
<security>
226+
<requestFiltering>
227+
<hiddenSegments>
228+
<clear />
229+
</hiddenSegments>
230+
<denyUrlSequences>
231+
<clear />
232+
</denyUrlSequences>
233+
<fileExtensions allowUnlisted="true">
234+
<clear />
235+
</fileExtensions>
236+
</requestFiltering>
237+
</security>
225238
<rewrite>
226-
<rules>
239+
<rules useOriginalURLEncoding="false">
227240
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
228241
<match url="(.*)" />
229-
<action type="Rewrite" url="http://127.0.0.1:3000/{R:1}" />
242+
<action type="Rewrite" url="http://127.0.0.1:3000{UNENCODED_URL}" />
230243
<serverVariables>
231244
<set name="HTTP_X_ORIGINAL_ACCEPT_ENCODING" value="HTTP_ACCEPT_ENCODING" />
232245
<set name="HTTP_ACCEPT_ENCODING" value="" />
@@ -255,6 +268,16 @@ If you wish to run Gitea with IIS. You will need to setup IIS with URL Rewrite a
255268
</outboundRules>
256269
</rewrite>
257270
<urlCompression doDynamicCompression="true" />
271+
<handlers>
272+
<clear />
273+
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
274+
</handlers>
275+
<!-- Map all extensions to the same MIME type, so all files can be
276+
downloaded. -->
277+
<staticContent>
278+
<clear />
279+
<mimeMap fileExtension="*" mimeType="application/octet-stream" />
280+
</staticContent>
258281
</system.webServer>
259282
</configuration>
260283
```

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export default {
22
setupFilesAfterEnv: ['jest-extended'],
33
testTimeout: 20000,
4+
rootDir: 'web_src',
45
testMatch: [
5-
'**/web_src/**/*.test.js',
6+
'<rootDir>/**/*.test.js',
67
],
78
transform: {},
89
verbose: false,

models/login_source.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"code.gitea.io/gitea/modules/setting"
2222
"code.gitea.io/gitea/modules/timeutil"
2323
"code.gitea.io/gitea/modules/util"
24+
gouuid "github.com/google/uuid"
2425
jsoniter "github.com/json-iterator/go"
2526

2627
"xorm.io/xorm"
@@ -116,6 +117,7 @@ func (cfg *SMTPConfig) ToDB() ([]byte, error) {
116117
// PAMConfig holds configuration for the PAM login source.
117118
type PAMConfig struct {
118119
ServiceName string // pam service (e.g. system-auth)
120+
EmailDomain string
119121
}
120122

121123
// FromDB fills up a PAMConfig from serialized format.
@@ -696,15 +698,26 @@ func LoginViaPAM(user *User, login, password string, sourceID int64, cfg *PAMCon
696698

697699
// Allow PAM sources with `@` in their name, like from Active Directory
698700
username := pamLogin
701+
email := pamLogin
699702
idx := strings.Index(pamLogin, "@")
700703
if idx > -1 {
701704
username = pamLogin[:idx]
702705
}
706+
if ValidateEmail(email) != nil {
707+
if cfg.EmailDomain != "" {
708+
email = fmt.Sprintf("%s@%s", username, cfg.EmailDomain)
709+
} else {
710+
email = fmt.Sprintf("%s@%s", username, setting.Service.NoReplyAddress)
711+
}
712+
if ValidateEmail(email) != nil {
713+
email = gouuid.New().String() + "@localhost"
714+
}
715+
}
703716

704717
user = &User{
705718
LowerName: strings.ToLower(username),
706719
Name: username,
707-
Email: pamLogin,
720+
Email: email,
708721
Passwd: password,
709722
LoginType: LoginPAM,
710723
LoginSource: sourceID,

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,7 @@ auths.allowed_domains_helper = Leave empty to allow all domains. Separate multip
23132313
auths.enable_tls = Enable TLS Encryption
23142314
auths.skip_tls_verify = Skip TLS Verify
23152315
auths.pam_service_name = PAM Service Name
2316+
auths.pam_email_domain = PAM Email Domain (optional)
23162317
auths.oauth2_provider = OAuth2 Provider
23172318
auths.oauth2_icon_url = Icon URL
23182319
auths.oauth2_clientID = Client ID (Key)

routers/admin/auths.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func NewAuthSourcePost(ctx *context.Context) {
240240
case models.LoginPAM:
241241
config = &models.PAMConfig{
242242
ServiceName: form.PAMServiceName,
243+
EmailDomain: form.PAMEmailDomain,
243244
}
244245
case models.LoginOAuth2:
245246
config = parseOAuth2Config(form)
@@ -347,6 +348,7 @@ func EditAuthSourcePost(ctx *context.Context) {
347348
case models.LoginPAM:
348349
config = &models.PAMConfig{
349350
ServiceName: form.PAMServiceName,
351+
EmailDomain: form.PAMEmailDomain,
350352
}
351353
case models.LoginOAuth2:
352354
config = parseOAuth2Config(form)

services/forms/auth_form.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type AuthenticationForm struct {
5151
TLS bool
5252
SkipVerify bool
5353
PAMServiceName string
54+
PAMEmailDomain string
5455
Oauth2Provider string
5556
Oauth2Key string
5657
Oauth2Secret string

templates/admin/auth/edit.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@
188188
<label for="pam_service_name">{{.i18n.Tr "admin.auths.pam_service_name"}}</label>
189189
<input id="pam_service_name" name="pam_service_name" value="{{$cfg.ServiceName}}" required>
190190
</div>
191+
<div class="field">
192+
<label for="pam_email_domain">{{.i18n.Tr "admin.auths.pam_email_domain"}}</label>
193+
<input id="pam_email_domain" name="pam_email_domain" value="{{$cfg.EmailDomain}}">
194+
</div>
191195
{{end}}
192196

193197
<!-- OAuth2 -->

templates/admin/auth/new.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
<div class="pam required field {{if not (eq .type 4)}}hide{{end}}">
3939
<label for="pam_service_name">{{.i18n.Tr "admin.auths.pam_service_name"}}</label>
4040
<input id="pam_service_name" name="pam_service_name" value="{{.pam_service_name}}" />
41+
<label for="pam_email_domain">{{.i18n.Tr "admin.auths.pam_email_domain"}}</label>
42+
<input id="pam_email_domain" name="pam_email_domain" value="{{.pam_email_domain}}">
4143
</div>
4244

4345
<!-- OAuth2 -->

0 commit comments

Comments
 (0)