How to use these examples
- Copy the queries for the capabilities you need. At minimum, Validate Credentials and List Accounts.
- Adapt table names, columns, and status logic to your environment. The engine-account queries work as-is against system catalogs. Application-database queries always need adapting to your schema.
- Strip comments and flatten each query to a single line before pasting. Lumos does not support comments in SQL queries. On macOS, this flattens your clipboard:
Sample Application Database
A complete worked example of governing a custom application through the Database connector, using a sample schema in Microsoft SQL Server. It demonstrates the read and write capabilities except List Updated Accounts and Update Account. In production, your application has its own schema and column names, which you model the same way.Schema
The sample models identity data the way most applications do: an accounts table, a resources table, an entitlements table, a join table for assignments, and an activity log.pip install pyodbc faker tqdm and run it with your server, database, and credentials.
Sample data generator script (lumos_generator.py)
Sample data generator script (lumos_generator.py)
lumos_generator.py
Verify the setup
Verify the setup
Run these queries to confirm the tables, account distribution and entitlement associations.
Sample connection string
Sample read capabilities
Validate CredentialsSample write capabilities
Create Account (the SELECT goes in the Create Account Return ID field)Microsoft SQL Server
Discovers server logins and per-database users with their role memberships, across all databases on the instance via dynamic SQL.SQL Server connection string
SQL Server List Accounts
Unions server principals (logins) with each database’s principals, identifying accounts asname@server or name@database:
EXEC(@SQL); with SET @SQL = 'SELECT TOP 1 * FROM (' + @SQL + ') AS AllResults;'; EXEC(@SQL);
SQL Server List Entitlements
Server roles plus each database’s roles:SQL Server Find Entitlement Associations
Server role memberships plus each database’s role memberships:SQL Server List Resources
Using stored procedures
Stored procedures work as long as the final result has the correct column labels. For reads, extract the procedure’s results into a table variable, then SELECT from it with the right aliases:Oracle DB
Discovers Oracle accounts and granted roles from the DBA views.Oracle connection string
Using the SID:Oracle List Accounts
WHERE ROWNUM = 1 appended.
Oracle List Entitlements
Oracle Find Entitlement Associations
Oracle versions older than 12.2 limit identifiers to 30 characters. Useinteg_specific_entitlement_idandinteg_specific_resource_idas the field names in that case.
Oracle List Resources
Oracle write capabilities
Oracle account writes are DDL, so identifiers take the! suffix (unquoted), while string literals don’t:
Create Account
TempPass123 is a placeholder. Replace it with a password that meets your Oracle password policy. Lumos needs the new account’s ID back from Create Account, so also fill in the Create Account Return ID query.
Update Account
PostgreSQL
Discovers roles frompg_catalog, mapping login capability and validity to account status.
PostgreSQL connection string
PostgreSQL List Accounts
LIMIT 1.
PostgreSQL List Entitlements
PostgreSQL Find Entitlement Associations
PostgreSQL List Resources
MySQL
Discovers users frommysql.user, plus privileges and roles from information_schema and mysql.role_edges.
MySQL connection string
MySQL List Accounts
LIMIT 1.
MySQL List Entitlements
Schema privileges, roles, and global privileges as three unioned entitlement sets:MySQL Find Entitlement Associations
MySQL List Resources
MongoDB
Uses the JDBC driver’s shell-syntax queries against theadmin database’s system.users and system.roles collections.
MongoDB connection string
MongoDB Validate Credentials
MongoDB List Accounts
MongoDB List Entitlements
MongoDB Find Entitlement Associations
MongoDB List Resources
Snowflake
Discovers users, roles, role inheritance, and effective database, warehouse, and schema access from theSNOWFLAKE.ACCOUNT_USAGE views. Note that a dedicated Snowflake connector also exists in the Integration Library. Use these queries when you want the query-driven JDBC approach instead.
Snowflake connection string
Snowflake List Accounts
Rich account listing with MFA, warehouse, and lock state surfaced as custom attributes:WHERE DELETED_ON IS NULL LIMIT 1.
Snowflake List Entitlements
Roles, role-to-role inheritance, and database, warehouse, and schema access grants as five unioned sets:Snowflake Find Entitlement Associations
Direct role grants, role inheritance, and effective database, warehouse, and schema access through assigned roles:Snowflake List Resources
Snowflake Get Last Activity
Databricks
Discovers grantees and their catalog, schema, and table privileges from Unity Catalog’ssystem.information_schema. A dedicated Databricks connector exists in the Integration Library, and Databricks can also connect via Universal REST. Use these queries for the SQL-warehouse approach.
Databricks connection string
Databricks Validate Credentials
Databricks List Accounts
Derives the account list from grantees across all privilege tables:Databricks List Entitlements
Catalog, schema, and table privileges as three unioned entitlement sets:Databricks Find Entitlement Associations
Databricks List Resources
Databricks Get Last Activity
Compatible engines without a dedicated example
Many databases are wire-compatible with an example above. Use the matching example and change only the connection string:- Azure SQL Database and Azure SQL Managed Instance: use the Microsoft SQL Server queries. Authenticate with a SQL login (username and password). Microsoft Entra ID authentication is not supported.
- Amazon RDS and Aurora: use the queries for the underlying engine (MySQL or PostgreSQL). IAM database authentication is not supported, so create a native database user.
- MariaDB: use the MySQL queries.
- Amazon Redshift and CockroachDB: PostgreSQL-derived. Start from the PostgreSQL queries and verify the catalog views, since system tables differ in places.
- Google Cloud SQL and AlloyDB: use the queries for the underlying engine.