Proposal: Support Single single-on with SPNEGO and SSPI (Kerberos) on Windows #8462
Labels
type/feature
Completely new functionality. Can only be merged if feature freeze is not active.
Milestone
Motivation
When using Gitea on premises in a Windows environment (with Active Directory), it would be very convenient to be able to use single sign-on authentication via Kerberos. Currently Gitea supports LDAP authentication to Active Directory (https://docs.gitea.io/en-us/authentication/), but LDAP is not single sign-on.
Short overview of proposal
The proposal is to support Single single-on authentication with Kerberos by implementing the protocol defined by RFC4559 (SPNEGO-based HTTP Authentication in Microsoft Windows) to exchange authentication data between the web browser and HTTP server, and the Security Support Provider Interface (SSPI) to perform the authentication.
Use cases
When installing Gitea:
Enable SSPI authentication (Windows only)
could be added to theServer and Third-Party Service Settings
section:That option could be disabled by default.
When opening the home page:
Register
orSign In
buttons) authentication is performed and the user is automatically signed in with the Kerberos credentials he is currently using in the operating system.When SSPI authentication is enabled, but the user needs to temporary use another authentication method (eg. to login as local user with administrative rights):
Disable Single Sign-On
appears only if SSPI authentication has been enabled in configuration):The user finished his work as local user and wants to use single-sign on again (to login as the user currently signed in the operating system):
Disable Single Sign-On
button, then both the anonymous dashboard and the user menu will contain a optionEnable Single Sign-On
, which restores SSPI authentication:Configuration
The
[service]
section of theapp.ini
could contain the following additional options:Those additional configuration values could be displayed in the
Service configuration
section of/admin/config
page:Design
Why SSPI and not a cross-platform kerberos library?
SSPI is chosen for verification because in Windows only environments (where both the client and server run Windows) it works without keytab files, which simplifies setup and improves security by not forcing you to store the user password in a keytab file.
How will this new authentication method be integrated into Gitea codebase?
The SignedInUser function of the
auth
module (https://github.com/go-gitea/gitea/blob/master/modules/auth/auth.go) is already doing authentication at the middleware level for:X-WEBAUTH-USER
header:gitea/modules/auth/auth.go
Line 134 in 46a12f1
Authorization
header:gitea/modules/auth/auth.go
Line 172 in 46a12f1
Authorization
header or with thetoken
andaccess_token
query params:gitea/modules/auth/auth.go
Line 44 in 46a12f1
gitea/modules/auth/auth.go
Line 189 in 46a12f1
SSPI authentication could be added to the same SignedInUser function, but that would increase the compexity of the file.
A better approach could be to introduce something like a plugin pattern for Single single sign-on authentication methods. A separate subpackage
modules/auth/sso
could be created with a common interface:Specific implementations of that interface could be:
basic.go
oauth2.go
reverseproxy.go
sspi_windows.go
Basic, OAuth and Reverse proxy authentication will be moved from the
modules/auth/auth.go
file to those "plugin" implementations.A new plugin implementing the interface will be introduced for SSPI authentication.
Authentication plugins would be used at the middleware level - inside the same SignedInUser function:
Does it introduce new dependencies?
Yes, one additional direct dependency will be needed - github.com/quasoft/websspi (shameless plug, I am the author of this module).
Does SSPI require any complex setup in the AD environment?
No, the only configuration that is strictly required is to create a suitable Service Principal Name for the domain account that will be running the
gitea.exe
process.That is usually achieved by running the following command with a priviledged user:
setspn -A HTTP/host.domain.local domain\user
There are some gotchas the user might crash into while setting it up, which will be described in the
Authentication
section of the documentation:The text was updated successfully, but these errors were encountered: