Skip to content

Commit 68ed7a8

Browse files
committed
Merge branch 'master' of git://github.com/go-gitea/gitea
2 parents 0c393fb + 7c6f2e2 commit 68ed7a8

File tree

494 files changed

+52125
-42756
lines changed

Some content is hidden

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

494 files changed

+52125
-42756
lines changed

cmd/web.go

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ package cmd
66

77
import (
88
"fmt"
9-
"net"
109
"net/http"
11-
"net/http/fcgi"
1210
_ "net/http/pprof" // Used for debugging if enabled and a web server is running
1311
"os"
1412
"strings"
@@ -60,7 +58,7 @@ func runHTTPRedirector() {
6058
http.Redirect(w, r, target, http.StatusTemporaryRedirect)
6159
})
6260

63-
var err = runHTTP(source, context2.ClearHandler(handler))
61+
var err = runHTTP("tcp", source, context2.ClearHandler(handler))
6462

6563
if err != nil {
6664
log.Fatal("Failed to start port redirection: %v", err)
@@ -77,12 +75,12 @@ func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler)
7775
go func() {
7876
log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect)
7977
// all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here)
80-
var err = runHTTP(setting.HTTPAddr+":"+setting.PortToRedirect, certManager.HTTPHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)))
78+
var err = runHTTP("tcp", setting.HTTPAddr+":"+setting.PortToRedirect, certManager.HTTPHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)))
8179
if err != nil {
8280
log.Fatal("Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err)
8381
}
8482
}()
85-
return runHTTPSWithTLSConfig(listenAddr, certManager.TLSConfig(), context2.ClearHandler(m))
83+
return runHTTPSWithTLSConfig("tcp", listenAddr, certManager.TLSConfig(), context2.ClearHandler(m))
8684
}
8785

8886
func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) {
@@ -171,7 +169,7 @@ func runWeb(ctx *cli.Context) error {
171169
switch setting.Protocol {
172170
case setting.HTTP:
173171
NoHTTPRedirector()
174-
err = runHTTP(listenAddr, context2.ClearHandler(m))
172+
err = runHTTP("tcp", listenAddr, context2.ClearHandler(m))
175173
case setting.HTTPS:
176174
if setting.EnableLetsEncrypt {
177175
err = runLetsEncrypt(listenAddr, setting.Domain, setting.LetsEncryptDirectory, setting.LetsEncryptEmail, context2.ClearHandler(m))
@@ -182,43 +180,13 @@ func runWeb(ctx *cli.Context) error {
182180
} else {
183181
NoHTTPRedirector()
184182
}
185-
err = runHTTPS(listenAddr, setting.CertFile, setting.KeyFile, context2.ClearHandler(m))
183+
err = runHTTPS("tcp", listenAddr, setting.CertFile, setting.KeyFile, context2.ClearHandler(m))
186184
case setting.FCGI:
187185
NoHTTPRedirector()
188-
// FCGI listeners are provided as stdin - this is orthogonal to the LISTEN_FDS approach
189-
// in graceful and systemD
190-
NoMainListener()
191-
var listener net.Listener
192-
listener, err = net.Listen("tcp", listenAddr)
193-
if err != nil {
194-
log.Fatal("Failed to bind %s: %v", listenAddr, err)
195-
}
196-
defer func() {
197-
if err := listener.Close(); err != nil {
198-
log.Fatal("Failed to stop server: %v", err)
199-
}
200-
}()
201-
err = fcgi.Serve(listener, context2.ClearHandler(m))
186+
err = runFCGI(listenAddr, context2.ClearHandler(m))
202187
case setting.UnixSocket:
203-
// This could potentially be inherited using LISTEN_FDS but currently
204-
// these cannot be inherited
205188
NoHTTPRedirector()
206-
NoMainListener()
207-
if err := os.Remove(listenAddr); err != nil && !os.IsNotExist(err) {
208-
log.Fatal("Failed to remove unix socket directory %s: %v", listenAddr, err)
209-
}
210-
var listener *net.UnixListener
211-
listener, err = net.ListenUnix("unix", &net.UnixAddr{Name: listenAddr, Net: "unix"})
212-
if err != nil {
213-
break // Handle error after switch
214-
}
215-
216-
// FIXME: add proper implementation of signal capture on all protocols
217-
// execute this on SIGTERM or SIGINT: listener.Close()
218-
if err = os.Chmod(listenAddr, os.FileMode(setting.UnixSocketPermission)); err != nil {
219-
log.Fatal("Failed to set permission of unix socket: %v", err)
220-
}
221-
err = http.Serve(listener, context2.ClearHandler(m))
189+
err = runHTTP("unix", listenAddr, context2.ClearHandler(m))
222190
default:
223191
log.Fatal("Invalid protocol: %s", setting.Protocol)
224192
}
@@ -229,6 +197,7 @@ func runWeb(ctx *cli.Context) error {
229197
log.Info("HTTP Listener: %s Closed", listenAddr)
230198
graceful.Manager.WaitForServers()
231199
graceful.Manager.WaitForTerminate()
200+
log.Info("PID: %d Gitea Web Finished", os.Getpid())
232201
log.Close()
233202
return nil
234203
}

cmd/web_graceful.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@ package cmd
66

77
import (
88
"crypto/tls"
9+
"net"
910
"net/http"
11+
"net/http/fcgi"
1012

1113
"code.gitea.io/gitea/modules/graceful"
14+
"code.gitea.io/gitea/modules/log"
1215
)
1316

14-
func runHTTP(listenAddr string, m http.Handler) error {
15-
return graceful.HTTPListenAndServe("tcp", listenAddr, m)
17+
func runHTTP(network, listenAddr string, m http.Handler) error {
18+
return graceful.HTTPListenAndServe(network, listenAddr, m)
1619
}
1720

18-
func runHTTPS(listenAddr, certFile, keyFile string, m http.Handler) error {
19-
return graceful.HTTPListenAndServeTLS("tcp", listenAddr, certFile, keyFile, m)
21+
func runHTTPS(network, listenAddr, certFile, keyFile string, m http.Handler) error {
22+
return graceful.HTTPListenAndServeTLS(network, listenAddr, certFile, keyFile, m)
2023
}
2124

22-
func runHTTPSWithTLSConfig(listenAddr string, tlsConfig *tls.Config, m http.Handler) error {
23-
return graceful.HTTPListenAndServeTLSConfig("tcp", listenAddr, tlsConfig, m)
25+
func runHTTPSWithTLSConfig(network, listenAddr string, tlsConfig *tls.Config, m http.Handler) error {
26+
return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, tlsConfig, m)
2427
}
2528

2629
// NoHTTPRedirector tells our cleanup routine that we will not be using a fallback http redirector
@@ -33,3 +36,17 @@ func NoHTTPRedirector() {
3336
func NoMainListener() {
3437
graceful.Manager.InformCleanup()
3538
}
39+
40+
func runFCGI(listenAddr string, m http.Handler) error {
41+
// This needs to handle stdin as fcgi point
42+
fcgiServer := graceful.NewServer("tcp", listenAddr)
43+
44+
err := fcgiServer.ListenAndServe(func(listener net.Listener) error {
45+
return fcgi.Serve(listener, m)
46+
})
47+
if err != nil {
48+
log.Fatal("Failed to start FCGI main server: %v", err)
49+
}
50+
log.Info("FCGI Listener: %s Closed", listenAddr)
51+
return err
52+
}

docker/root/etc/s6/gitea/finish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
exit 0
2+
s6-svscanctl -t /etc/s6/

docs/content/doc/features/authentication.en-us.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,42 @@ configure this, set the fields below:
216216

217217
- Log in to Gitea as an Administrator and click on "Authentication" under Admin Panel.
218218
Then click `Add New Source` and fill in the details, changing all where appropriate.
219+
220+
## SPNEGO with SSPI (Kerberos/NTLM, for Windows only)
221+
222+
Gitea supports SPNEGO single sign-on authentication (the scheme defined by RFC4559) for the web part of the server via the Security Support Provider Interface (SSPI) built in Windows. SSPI works only in Windows environments - when both the server and the clients are running Windows.
223+
224+
Before activating SSPI single sign-on authentication (SSO) you have to prepare your environment:
225+
226+
- Create a separate user account in active directory, under which the `gitea.exe` process will be running (eg. `user` under domain `domain.local`):
227+
228+
- Create a service principal name for the host where `gitea.exe` is running with class `HTTP`:
229+
- Start `Command Prompt` or `PowerShell` as a priviledged domain user (eg. Domain Administrator)
230+
- Run the command below, replacing `host.domain.local` with the fully qualified domain name (FQDN) of the server where the web application will be running, and `domain\user` with the name of the account created in the previous step:
231+
```
232+
setspn -A HTTP/host.domain.local domain\user
233+
```
234+
235+
- Sign in (*sign out if you were already signed in*) with the user created
236+
237+
- Make sure that `ROOT_URL` in the `[server]` section of `custom/conf/app.ini` is the fully qualified domain name of the server where the web application will be running - the same you used when creating the service principal name (eg. `host.domain.local`)
238+
239+
- Start the web server (`gitea.exe web`)
240+
241+
- Enable SSPI authentication by adding an `SPNEGO with SSPI` authentication source in `Site Administration -> Authentication Sources`
242+
243+
- Sign in to a client computer in the same domain with any domain user (client computer, different from the server running `gitea.exe`)
244+
245+
- If you are using Chrome, Edge or Internet Explorer, add the URL of the web app to the Local intranet sites (`Internet Options -> Security -> Local intranet -> Sites`)
246+
247+
- Start Chrome, Edge or Internet Explorer and navigate to the FQDN URL of gitea (eg. `http://host.domain.local:3000`)
248+
249+
- Click the `Sign In` button on the dashboard and choose SSPI to be automatically logged in with the same user that is currently logged on to the computer
250+
251+
- If it does not work, make sure that:
252+
- You are not running the web browser on the same server where gitea is running. You should be running the web browser on a domain joined computer (client) that is different from the server. If both the client and server are runnning on the same computer NTLM will be prefered over Kerberos.
253+
- There is only one `HTTP/...` SPN for the host
254+
- The SPN contains only the hostname, without the port
255+
- You have added the URL of the web app to the `Local intranet zone`
256+
- The clocks of the server and client should not differ with more than 5 minutes (depends on group policy)
257+
- `Integrated Windows Authentication` should be enabled in Internet Explorer (under `Advanced settings`)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
date: "2019-11-28:00:00+02:00"
3+
title: "The .gitea Directory"
4+
slug: "gitea-directory"
5+
weight: 40
6+
toc: true
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "features"
11+
name: "The .gitea Directory"
12+
weight: 50
13+
identifier: "gitea-directory"
14+
---
15+
16+
# The .gitea directory
17+
Gitea repositories can include a `.gitea` directory at their base which will store settings/configurations for certain features.
18+
19+
## Templates
20+
Gitea includes template repositories, and one feature implemented with them is auto-expansion of specific variables within your template files.
21+
To tell Gitea which files to expand, you must include a `template` file inside the `.gitea` directory of the template repository.
22+
Gitea uses [gobwas/glob](https://github.com/gobwas/glob) for its glob syntax. It closely resembles a traditional `.gitignore`, however there may be slight differences.
23+
24+
### Example `.gitea/template` file
25+
All paths are relative to the base of the repository
26+
```gitignore
27+
# All .go files, anywhere in the repository
28+
**.go
29+
30+
# All text files in the text directory
31+
text/*.txt
32+
33+
# A specific file
34+
a/b/c/d.json
35+
36+
# Batch files in both upper or lower case can be matched
37+
**.[bB][aA][tT]
38+
```
39+
**NOTE:** The `template` file will be removed from the `.gitea` directory when a repository is generated from the template.
40+
41+
### Variable Expansion
42+
In any file matched by the above globs, certain variables will be expanded.
43+
All variables must be of the form `$VAR` or `${VAR}`. To escape an expansion, use a double `$$`, such as `$$VAR` or `$${VAR}`
44+
45+
| Variable | Expands To |
46+
|----------------------|-----------------------------------------------------|
47+
| REPO_NAME | The name of the generated repository |
48+
| TEMPLATE_NAME | The name of the template repository |
49+
| REPO_DESCRIPTION | The description of the generated repository |
50+
| TEMPLATE_DESCRIPTION | The description of the template repository |
51+
| REPO_LINK | The URL to the generated repository |
52+
| TEMPLATE_LINK | The URL to the template repository |
53+
| REPO_HTTPS_URL | The HTTP(S) clone link for the generated repository |
54+
| TEMPLATE_HTTPS_URL | The HTTP(S) clone link for the template repository |
55+
| REPO_SSH_URL | The SSH clone link for the generated repository |
56+
| TEMPLATE_SSH_URL | The SSH clone link for the template repository |

go.mod

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.13
44

55
require (
66
cloud.google.com/go v0.45.0 // indirect
7+
gitea.com/lunny/levelqueue v0.1.0
78
gitea.com/macaron/binding v0.0.0-20190822013154-a5f53841ed2b
89
gitea.com/macaron/cache v0.0.0-20190822004001-a6e7fee4ee76
910
gitea.com/macaron/captcha v0.0.0-20190822015246-daa973478bae
@@ -16,29 +17,28 @@ require (
1617
gitea.com/macaron/session v0.0.0-20190821211443-122c47c5f705
1718
gitea.com/macaron/toolbox v0.0.0-20190822013122-05ff0fc766b7
1819
github.com/PuerkitoBio/goquery v1.5.0
19-
github.com/RoaringBitmap/roaring v0.4.7 // indirect
20+
github.com/RoaringBitmap/roaring v0.4.21 // indirect
2021
github.com/bgentry/speakeasy v0.1.0 // indirect
21-
github.com/blevesearch/bleve v0.0.0-20190214220507-05d86ea8f6e3
22+
github.com/blevesearch/bleve v0.8.1
2223
github.com/blevesearch/blevex v0.0.0-20180227211930-4b158bb555a3 // indirect
23-
github.com/blevesearch/go-porterstemmer v0.0.0-20141230013033-23a2c8e5cf1f // indirect
24-
github.com/blevesearch/segment v0.0.0-20160105220820-db70c57796cc // indirect
24+
github.com/blevesearch/go-porterstemmer v1.0.2 // indirect
25+
github.com/blevesearch/segment v0.0.0-20160915185041-762005e7a34f // indirect
2526
github.com/boombuler/barcode v0.0.0-20161226211916-fe0f26ff6d26 // indirect
26-
github.com/couchbase/vellum v0.0.0-20190111184608-e91b68ff3efe // indirect
27+
github.com/couchbase/vellum v0.0.0-20190829182332-ef2e028c01fd // indirect
2728
github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d // indirect
2829
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect
2930
github.com/cznic/strutil v0.0.0-20181122101858-275e90344537 // indirect
3031
github.com/denisenkom/go-mssqldb v0.0.0-20190924004331-208c0a498538
3132
github.com/dgrijalva/jwt-go v3.2.0+incompatible
3233
github.com/editorconfig/editorconfig-core-go/v2 v2.1.1
3334
github.com/emirpasic/gods v1.12.0
34-
github.com/etcd-io/bbolt v1.3.2 // indirect
35+
github.com/etcd-io/bbolt v1.3.3 // indirect
3536
github.com/ethantkoenig/rupture v0.0.0-20180203182544-0a76f03a811a
3637
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 // indirect
3738
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
3839
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect
3940
github.com/gliderlabs/ssh v0.2.2
40-
github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd // indirect
41-
github.com/glycerine/goconvey v0.0.0-20190315024820-982ee783a72e // indirect
41+
github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a // indirect
4242
github.com/go-openapi/jsonreference v0.19.3 // indirect
4343
github.com/go-openapi/runtime v0.19.5 // indirect
4444
github.com/go-redis/redis v6.15.2+incompatible
@@ -60,24 +60,22 @@ require (
6060
github.com/lafriks/xormstore v1.3.2
6161
github.com/lib/pq v1.2.0
6262
github.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96
63-
github.com/lunny/levelqueue v0.0.0-20190217115915-02b525a4418e
6463
github.com/mailru/easyjson v0.7.0 // indirect
6564
github.com/markbates/goth v1.56.0
6665
github.com/mattn/go-isatty v0.0.7
6766
github.com/mattn/go-oci8 v0.0.0-20190320171441-14ba190cf52d // indirect
6867
github.com/mattn/go-sqlite3 v1.11.0
6968
github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75
7069
github.com/microcosm-cc/bluemonday v0.0.0-20161012083705-f77f16ffc87a
71-
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae // indirect
7270
github.com/msteinert/pam v0.0.0-20151204160544-02ccfbfaf0cc
7371
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5
7472
github.com/niklasfasching/go-org v0.1.8
7573
github.com/oliamb/cutter v0.2.2
76-
github.com/philhofer/fwd v1.0.0 // indirect
7774
github.com/pkg/errors v0.8.1
7875
github.com/pquerna/otp v0.0.0-20160912161815-54653902c20e
7976
github.com/prometheus/client_golang v1.1.0
8077
github.com/prometheus/procfs v0.0.4 // indirect
78+
github.com/quasoft/websspi v1.0.0
8179
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001 // indirect
8280
github.com/russross/blackfriday/v2 v2.0.1
8381
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
@@ -89,19 +87,17 @@ require (
8987
github.com/steveyen/gtreap v0.0.0-20150807155958-0abe01ef9be2 // indirect
9088
github.com/stretchr/testify v1.4.0
9189
github.com/tecbot/gorocksdb v0.0.0-20181010114359-8752a9433481 // indirect
92-
github.com/tinylib/msgp v0.0.0-20180516164116-c8cf64dff200 // indirect
9390
github.com/tstranex/u2f v1.0.0
9491
github.com/unknwon/cae v0.0.0-20190822084630-55a0b64484a1
9592
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e
9693
github.com/unknwon/i18n v0.0.0-20190805065654-5c6446a380b6
9794
github.com/unknwon/paginater v0.0.0-20151104151617-7748a72e0141
9895
github.com/urfave/cli v1.20.0
99-
github.com/willf/bitset v0.0.0-20180426185212-8ce1146b8621 // indirect
10096
github.com/yohcop/openid-go v0.0.0-20160914080427-2c050d2dae53
10197
golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f
10298
golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9
10399
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
104-
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b
100+
golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2
105101
golang.org/x/text v0.3.2
106102
golang.org/x/tools v0.0.0-20190910221609-7f5965fd7709 // indirect
107103
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect

0 commit comments

Comments
 (0)