GSSAPI/SSPI authentication (gssauth)
Using Windows Active Directory services to authenticate users in a Firebird database.
Firebird already supported Windows trusted authentication on Windows. That ability was implemented in the Win_SSPI plugin for client and server. It uses the Windows SSPI API and the NTLM security provider and works on Windows only.
Windows Active Directory is widely supported by modern Linux systems, so its services can also authenticate users on Linux.
Firebird implements that support in the gssauth security plugin. As the name implies, it uses the GSS API to talk to Active Directory. It is available on both Windows and Linux, for both the Firebird client and the Firebird server. In most cases it can replace Win_SSPI, but that is not required — both plugins can run on the same Firebird server.
Installation
Some preparation is required to use Active Directory. A Windows host that runs the Firebird server must be a member of a Windows domain. A Linux host that runs the Firebird server must be joined to Active Directory. A domain user account is required to run the Firebird service on Windows. Service Principal Names (SPNs) must be assigned to that domain account so a Firebird client can authenticate the Firebird server via Active Directory. Below is a brief guide for preparing Windows and Linux servers from the Firebird side.
Firebird server on Windows host
-
Create a domain account to run the Firebird service. Set these properties:
- User cannot change password
- Password never expires
-
Install Firebird and run it under that domain account. Use
instsvcwith-login, or change the “Log on as” property of an already installed service. -
Add two Service Principal Names for that account. The service name is
FirebirdSQL. One SPN must use the short host name; the other must use the FQDN. If the Firebird service was created withinstsvc, it also registers those two SPNs. Otherwise use the Windowssetspnutility:
setspn -U -S FirebirdSQL/hostname account
setspn -U -S FirebirdSQL/hostname.domain account
For example, if the domain is example.com, the host is winfb, and the account is fbsvc:
setspn -U -S FirebirdSQL/winfb fbsvc
setspn -U -S FirebirdSQL/winfb.example.com fbsvc
- Add
gssauthtofirebird.conf(AuthServer):
AuthServer = Srp256, gssauth
-
Set (or check) file-system permissions for the domain account:
- Read access:
firebird.confand other.conffiles - Full access: folders with databases;
security5.fdb;firebird.logand other.logfiles
- Read access:
-
Add a firewall rule for Firebird.
Firebird server on Linux host
-
Create a domain account on a Windows host. Set these properties:
- User cannot change password
- Password never expires
-
Add two Service Principal Names for that account. The service name is
FirebirdSQL. One SPN must use the short host name; the other must use the FQDN. Use the Windowssetspnutility:
setspn -U -S FirebirdSQL/hostname account
setspn -U -S FirebirdSQL/hostname.domain account
For example, if the domain is example.com, the host is linuxfb, and the account is fbsvc:
setspn -U -S FirebirdSQL/linuxfb fbsvc
setspn -U -S FirebirdSQL/linuxfb.example.com fbsvc
- Create a Kerberos key table file for the Linux server with the Windows
ktpassutility:
ktpass
/out firebird.keytab
/princ FirebirdSQL/[email protected]
/mapuser [email protected]
/pass <password of fbsvc account>
-setpass
/ptype KRB5_NT_PRINCIPAL
/crypto all
Notes:
- The
/princargument is case-sensitive; it must match what the Linux host that will run Firebird sees. -setpassis used so the account password is not changed./cryptocan be changed to avoid legacy encryption algorithms.- Full documentation for
ktpass: Microsoft ktpass.
-
Make sure
libgssapi_krb5.sois installed. -
Install Firebird.
-
Stop the Firebird service.
-
Add
gssauthtofirebird.conf(AuthServer):
AuthServer = Srp256, gssauth
-
Copy
firebird.keytabfrom the Windows host to/opt/firebird(or the folder wherefirebird.conflives on your distro). Set owner tofirebird:firebirdand permissions so only the user and group can read it. -
Start the Firebird service.
Note: use the KRB5_TRACE environment variable to set a Kerberos trace file name for troubleshooting.
Usage
On Windows, the gssauth plugin is built into fbclient.dll, so no special client deployment is needed. On Linux, gssauth is a separate libgssauth.so module and must be deployed with the other binaries when necessary.
The Firebird server must include gssauth in the AuthServer plugin list. The Firebird client includes gssauth in AuthClient by default.
Firebird tools such as isql, gbak, and others now support the -trusted command-line switch on Linux, as they have on Windows for a long time.
Create a mapping in the user database or the security database to map domain users to Firebird users. Note: gssauth reports only full names of users and groups (including the domain prefix), while Win_SSPI reports two forms for every group (with and without domain) — account for that when creating mappings. Also, on Linux, domain user/group names can appear in a slightly different form than in Active Directory (lower case, no domain prefix, and so on). Check the exact representation with Linux commands such as id and groups.
Mapping examples
Map every user as is:
CREATE GLOBAL MAPPING GSS_USERS
USING PLUGIN GSSAUTH
FROM ANY USER
TO USER;
Map domain admins as RDB$ADMIN on a Linux server:
CREATE GLOBAL MAPPING GSS_ADMINS
USING PLUGIN GSSAUTH
FROM GROUP 'domain admins'
TO ROLE RDB$ADMIN;
Map domain admins as RDB$ADMIN on a Windows server:
CREATE GLOBAL MAPPING GSS_ADMINS
USING PLUGIN GSSAUTH
FROM GROUP 'EXAMPLE\Domain Admins'
TO ROLE RDB$ADMIN;