Reference: Creating a self-hosted database to store recovery keys
To use a self-hosted database to store recovery keys for endpoints with encryption management policy enforcements, you must create a database and service account in your database management system that meets the following requirements:
-
An empty PostgreSQL or Microsoft SQL database with the required collation and encoding
-
A service account with sufficient permissions
-
The Tanium Server where Enforce is installed must be able to communicate with the database server
-
(PostgreSQL) PEM (Privacy Enhanced Mail) or SSL certificates (CRT) to encrypt the connection to the database
Complete the setup in this order:
-
Create an empty database (this task is typically handled by a database administrator)
-
Create and configure the service account with the appropriate permissions
-
Configure the database connection in the encryption settings in the Enforce workbench
After this connection is configured, the Enforce service runs migrations on the database to automatically create all necessary tables and schema objects.
-
Encrypt stored passwords (Enforce handles this automatically)
-
Use Windows Authentication for Microsoft SQL when possible
-
Use domain group membership for SQL server level login
-
Restrict network access to the database server
-
Regularly rotate credentials
Step 1: Create the database
PostgreSQL
Run the following commands as a user with database administrator privileges:
-- Create the database
CREATE DATABASE <database_name>
OWNER <service_account>
ENCODING 'UTF8'
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8'
TEMPLATE template0;
-- Connect to the new database
\c <database_name>
Alternately, you can run this command from a command line: createdb -O <service_account> -E UTF8 <database_name>.
Microsoft SQL
Run the following commands as a user with database administrator privileges (typically sa or a member of the sysadmin role):
-- Create the database
CREATE DATABASE <database_name>
COLLATE SQL_Latin1_General_CP1_CI_AS;
-- Switch to the new database
USE <database_name>;
GO
Step 2: Configure the required permissions for the database service account
This service account is used to connect from Enforce to the database. The service account must have permissions to perform the following operations:
-
Create and modify tables (for schema migrations)
-
Insert, update, delete, and select data (for storing/retrieving keys)
-
Manage sequences/identity columns
-
Execute stored procedures/functions
PostgreSQL
For a self-hosted PostgreSQL database, the service account needs permissions configured in one of the following ways:
Option 1: Simplified permissions
This option provides more permissions to the service account than might be needed to use it with Enforce, but this method is simpler to set up and maintain.
- Database-Level Permissions
-
CODE
-- Connect to the database GRANT CONNECT ON DATABASE <database_name> TO <service_account>; -- Grant all privileges on the database (recommended for simplicity)GRANT ALL PRIVILEGES ON DATABASE <database_name> TO <service_account>; - Schema-Level Permissions
-
CODE
-- Full access to the public schema GRANT ALL ON SCHEMA public TO <service_account>; -- Allow creating new objects GRANT CREATE ON SCHEMA public TO <service_account>; - Object-Level Permissions
-
CODE
-- Full access to all tables (for both migrations and operations) GRANT ALL ON ALL TABLES IN SCHEMA public TO <service_account>; -- Full access to all sequences (for auto-increment columns) GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO <service_account>; -- Execute access to all functions GRANT ALL ON ALL FUNCTIONS IN SCHEMA public TO <service_account>; -- Set default privileges for future objects ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO <service_account>; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO <service_account>; ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON FUNCTIONS TO <service_account>;
Option 2: More restrictive permissions
This option provides only the specific permissions to the service account that are needed to use it with Enforce, but this method is more complex to set up and maintain.
-- Database
GRANT CONNECT ON DATABASE <database_name> TO <service_account>;
-- Schema
GRANT USAGE, CREATE ON SCHEMA public TO <service_account>;
-- Tables (DDL + DML)
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO <service_account>;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO <service_account>;
-- Sequences
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO <service_account>;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO <service_account>;
-- Functions
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA public TO <service_account>;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
GRANT EXECUTE ON FUNCTIONS TO <service_account>;
-- DDL permissions (for migrations)
-- The account needs to be able to create/alter/drop tables
-- This typically requires ownership or superuser, so using a role:
CREATE ROLE enforce_admin;
GRANT ALL ON SCHEMA public TO enforce_admin;
GRANT enforce_admin TO <service_account>;
Microsoft SQL
For a self-hosted Microsoft SQL database, the service account needs permissions configured in one of the following ways:
Option 1: Simplified permissions (Database Owner SA Auth)
USE <database_name>;
GO
-- Create login (if not using Windows Authentication)
CREATE LOGIN <service_account> WITH PASSWORD = '<password>';
GO
-- Create user in database
CREATE USER <service_account> FOR LOGIN <service_account>;
GO
-- Grant db_owner role (allows everything)
ALTER ROLE db_owner ADD MEMBER <service_account>;
GO
Option 2: Best practice - Windows Authentication (Domain Account)
This method is typically the easiest to manage after it is configured. If necessary, you can use the more restrictive specific settings with Windows Authentication, which is described in the preceding section.
-- Create the SQL Server Login for user or group (if using Windows Authentication)
-- Domain security group membership is recommended best practice
-- be sure to add the service account user to security group if leveraging an AD group
CREATE LOGIN <service_account or group> FROM WINDOWS;
GO
USE <database_name>;
GO
-- Create user for domain account
CREATE USER [DOMAIN\service_account] FOR LOGIN [DOMAIN\service_account];
GO
-- Grant db_owner or specific permissions
ALTER ROLE db_owner ADD MEMBER [DOMAIN\service_account];
GO
Option 3: More restrictive specific permissions (SA Auth)
-- First, create the login at server level
CREATE LOGIN <service_account> WITH PASSWORD = '<password>';
GO
-- Switch to the database
USE <database_name>;
GO
-- Create database user
CREATE USER <service_account> FOR LOGIN <service_account>;
GO
-- CHOOSE ONE APPROACH BELOW (ROLES or EXPLICIT GRANTS, not both):
______________________________________
-- APPROACH 1: Use built-in roles for simpler management (RECOMMENDED)
ALTER ROLE db_ddladmin ADD MEMBER <service_account>; -- DDL operations (create/alter tables)
ALTER ROLE db_datareader ADD MEMBER <service_account>; -- SELECT
ALTER ROLE db_datawriter ADD MEMBER <service_account>; -- INSERT, UPDATE, DELETE
GO
_____________________________________
-- APPROACH 2: Grant specific permissions individually (more granular control)
-- If using this approach, COMMENT OUT the ALTER ROLE statements above
-- Uncomment the following lines:
-- DDL Permissions (for migrations - allows creating and modifying database objects)
-- GRANT CREATE TABLE TO <service_account>;
-- GRANT CREATE VIEW TO <service_account>;
-- GRANT CREATE FUNCTION TO <service_account>;
-- GRANT CREATE PROCEDURE TO <service_account>;
-- GRANT ALTER ON SCHEMA::dbo TO <service_account>;
-- GO
-- DML Permissions (for operations - allows reading and writing data)
-- GRANT SELECT ON SCHEMA::dbo TO <service_account>;
-- GRANT INSERT ON SCHEMA::dbo TO <service_account>;
-- GRANT UPDATE ON SCHEMA::dbo TO <service_account>;
-- GRANT DELETE ON SCHEMA::dbo TO <service_account>;
-- GRANT EXECUTE ON SCHEMA::dbo TO <service_account>;
-- GO
-- Additional permissions needed for full functionality
-- GRANT REFERENCES ON SCHEMA::dbo TO <service_account>; -- For foreign keys
-- GRANT VIEW DEFINITION ON SCHEMA::dbo TO <service_account>; -- View object definitions
-- GO
-- Set default permissions for objects created in the future
-- GRANT CONTROL ON SCHEMA::dbo TO <service_account>; -- Allows altering tables after creation
-- GO
Step 3: Configure the database connection in Enforce
Configure Enforce to connect to the database that you configured in the preceding sections.
-
From the Main menu, go to to open the Enforce Overview page. Click Settings
.
-
On the Endpoint Encryption tab, click Configure Database.
-
Select Self-Hosted, select the appropriate Database Server Type (PostgreSQL or Microsoft SQL), and provide the details for the database and service account:
- PostgreSQL
-
-
Host name: Specify the name of your PostgreSQL server where you created the database and service account.
-
Port: Specify the port for your database management server (default is 5432)
-
User name: Specify the user name for the service_account that you configured.
-
Password: Specify the password for the service account that you configured.
-
Database Name: Specify the name of the empty database that you created.
-
Postgres Server CRT File: Provide the SSL certificate required for encrypted connections (PEM or CRT format).
-
- Microsoft SQL
-
-
Host name: Specify the name of your Microsoft SQL server where you created the database and service account.
-
Port: Specify the port for your database management server (default is 1433)
-
User name: Specify the user name for the service_account that you configured.
-
Password: Specify the password for the service account that you configured.
-
Domain: If you are using Windows/NTLM Authentication (Domain Account), specify the domain for the account.
-
Database Name: Specify the name of the empty database that you created.
-