Skip to content

Commit 4347179

Browse files
committed
Add single sign-on support via SSPI on Windows
1 parent 46a12f1 commit 4347179

File tree

172 files changed

+6012
-1272
lines changed

Some content is hidden

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

172 files changed

+6012
-1272
lines changed

custom/conf/app.ini.sample

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,19 @@ SHOW_REGISTRATION_BUTTON = true
440440
; When adding a repo to a team or creating a new repo all team members will watch the
441441
; repo automatically if enabled
442442
AUTO_WATCH_NEW_REPOS = true
443+
; Enable SPNEGO authentication via the built-in SSPI module in Windows.
444+
; To use SSPI authentication you need to create suitable service principal name (SPN)
445+
; for the user running gitea (see https://github.com/quasoft/websspi for more details)
446+
ENABLE_SSPI = false
447+
; Allow SSPI auth method to automatically create new users on the go
448+
SSPI_AUTO_CREATE_USERS = true
449+
; Allow SSPI auth method to automatically activate new users
450+
SSPI_AUTO_ACTIVATE_USERS = true
451+
; The character to use to replace the separators of down-level logon names (eg. the \
452+
; in "DOMAIN\user") and user principal names (eg. the @ in "user@example.org")
453+
SSPI_SEPARATOR_REPLACEMENT = _
454+
; Default language for users automatically created by SSPI auth method
455+
SSPI_DEFAULT_LANG = en-us
443456

444457
[webhook]
445458
; Hook task queue length, increase if webhook shooting starts hanging

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
253253
- `AUTO_WATCH_NEW_REPOS`: **true**: Enable this to let all organisation users watch new repos when they are created
254254
- `DEFAULT_ORG_VISIBILITY`: **public**: Set default visibility mode for organisations, either "public", "limited" or "private".
255255
- `DEFAULT_ORG_MEMBER_VISIBLE`: **false** True will make the membership of the users visible when added to the organisation.
256+
- `ENABLE_SSPI`: **false**: Allow authentication via SSPI implementation of SPNEGO (Windows only. To use SSPI authentication you need to create suitable service principal name (SPN) for the user running gitea (see https://github.com/quasoft/websspi for more details).
257+
- `SSPI_AUTO_CREATE_USERS`: **true**: Allow SSPI auth method to automatically create new users on the go.
258+
- `SSPI_AUTO_ACTIVATE_USERS`: **true**: Allow SSPI auth method to automatically activate new users.
259+
- `SSPI_SEPARATOR_REPLACEMENT`: **_**: The character to use to replace the separators of down-level logon names (eg. the \ in "DOMAIN\user") and user principal names (eg. the @ in "user@example.org").
260+
- `SSPI_DEFAULT_LANG`: **en-us**: Default language for users automatically created by SSPI auth method.
256261

257262
## Webhook (`webhook`)
258263

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,40 @@ 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+
## SSPI (Kerberos SPNEGO, 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+
- Enable SSPI authentication by changing the `ENABLE_SSPI` value in `custom/conf/app.ini` to `true`
238+
239+
- Start the web server (`gitea.exe web`)
240+
241+
- Sign in to a client computer in the same domain with any domain user
242+
243+
- 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`)
244+
245+
- Start Chrome, Edge or Internet Explorer and navigate to FQDN URL of gitea (eg. `http://host.domain.local:3000`)
246+
247+
- Click the `Sign In` button on the dashboard and you should be automatically logged in with the same user that is currently logged on to the computer
248+
249+
- If it does not work, make sure that:
250+
- 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
251+
- There is only one `HTTP/...` SPN for the host
252+
- The SPN contains only the hostname, without the port
253+
- You have added the URL of the web app to the `Local intranet zone`
254+
- The clocks of the server and client should not differ with more than 5 minutes (depends on group policy)
255+
- `Integrated Windows Authentication` should be enabled in Internet Explorer (under `Advanced settings`)

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ require (
8484
github.com/pquerna/otp v0.0.0-20160912161815-54653902c20e
8585
github.com/prometheus/client_golang v1.1.0
8686
github.com/prometheus/procfs v0.0.4 // indirect
87+
github.com/quasoft/websspi v1.0.0
8788
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001 // indirect
8889
github.com/russross/blackfriday v0.0.0-20180428102519-11635eb403ff
8990
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
@@ -107,7 +108,7 @@ require (
107108
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad
108109
golang.org/x/net v0.0.0-20190909003024-a7b16738d86b
109110
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
110-
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b
111+
golang.org/x/sys v0.0.0-20191010194322-b09406accb47
111112
golang.org/x/text v0.3.2
112113
golang.org/x/tools v0.0.0-20190910221609-7f5965fd7709 // indirect
113114
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ github.com/prometheus/procfs v0.0.4 h1:w8DjqFMJDjuVwdZBQoOozr4MVWOnwF7RcL/7uxBjY
497497
github.com/prometheus/procfs v0.0.4/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
498498
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
499499
github.com/prometheus/tsdb v0.10.0/go.mod h1:oi49uRhEe9dPUTlS3JRZOwJuVi6tmh10QSgwXEyGCt4=
500+
github.com/quasoft/websspi v1.0.0 h1:5nDgdM5xSur9s+B5w2xQ5kxf5nUGqgFgU4W0aDLZ8Mw=
501+
github.com/quasoft/websspi v1.0.0/go.mod h1:HmVdl939dQ0WIXZhyik+ARdI03M6bQzaSEKcgpFmewk=
500502
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
501503
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001 h1:YDeskXpkNDhPdWN3REluVa46HQOVuVkjkd2sWnrABNQ=
502504
github.com/remyoudompheng/bigfft v0.0.0-20190321074620-2f0d2b0e0001/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
@@ -702,8 +704,8 @@ golang.org/x/sys v0.0.0-20190730183949-1393eb018365/go.mod h1:h1NjWce9XRLGQEsW7w
702704
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3 h1:4y9KwBHBgBNwDbtu44R5o1fdOCQUEXhbk/P4A9WmJq0=
703705
golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
704706
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
705-
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b h1:3S2h5FadpNr0zUUCVZjlKIEYF+KaX/OBplTGo89CYHI=
706-
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
707+
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
708+
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
707709
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
708710
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
709711
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=

0 commit comments

Comments
 (0)