Docs
Live demo

Prepare a target

Create Principal's service account on a database or Kubernetes cluster before adding the target.

On this page

Need: target admin access, Principal’s source address and a supported version of the target. Replace UPPERCASE values. Generate a safe password:

bash
openssl rand -hex 24

Then enter the account in Add a target and test it. See Targets.

PostgreSQL#

Run as superuser or managed-DB master user (RDS, Cloud SQL, Azure):

sql
CREATE ROLE principal LOGIN PASSWORD 'PASSWORD' CREATEROLE;
GRANT pg_signal_backend TO principal;
-- Per database:
GRANT CONNECT ON DATABASE APP_DB TO principal WITH GRANT OPTION;
-- Per object owner or migration role:
GRANT APP_OWNER TO principal;
Line Purpose
CREATEROLE
Creates roles, sets passwords.
pg_signal_backend
Ends sessions after revoke.
CONNECT ON DATABASE
Grants CONNECT on covered DBs.
GRANT APP_OWNER
Grants/revokes on owned objects (CREATEROLE alone cannot).

Or grant exact privileges WITH GRANT OPTION (GRANT SELECT ON ALL TABLES IN SCHEMA billing TO principal WITH GRANT OPTION). Test checks CREATEROLE only, preview/apply check grant rights, pg_signal_backend is unchecked. Allow Principal in pg_hba.conf or firewall.

MySQL / MariaDB#

Run as root or *.* GRANT OPTION user (MariaDB 10.5.2+). Replace % with Principal’s host to restrict access:

sql
CREATE USER 'principal'@'%' IDENTIFIED BY 'PASSWORD';
GRANT SELECT ON mysql.* TO 'principal'@'%';
GRANT CREATE USER, SHOW DATABASES, PROCESS, CONNECTION ADMIN
  ON *.* TO 'principal'@'%' WITH GRANT OPTION;
-- Per database with rule privileges:
GRANT SELECT, INSERT, UPDATE, DELETE
  ON APP_DB.* TO 'principal'@'%' WITH GRANT OPTION;
Privilege Purpose
SELECT on mysql.*
Reads grant tables.
CREATE USER
Manages accounts and passwords.
GRANT OPTION on *.*
Grants/revokes privileges.
SHOW DATABASES
Lists DBs to compute revokes.
PROCESS
Lists open sessions.
CONNECTION ADMIN
Ends sessions after revoke (SUPER < 10.5.2).

First three SQL lines are checked on MariaDB (missing grants show GRANT + Check again). Also grant all rule privileges WITH GRANT OPTION (or GRANT ALL PRIVILEGES ON *.* TO 'principal'@'%' WITH GRANT OPTION), else apply fails with Access denied.

lower_case_table_names 0 or 1 supported. With 1, use lowercase names (mixed case shows Apply is blocked: This server keeps database and table names in lower case (lower_case_table_names = 1).). Value 2 shows Apply is blocked: This access preview supports lower_case_table_names = 0 or 1.

ClickHouse#

Requires 24.10+, SQL storage (local_directory, not users.xml), no replicated access storage. Run as an access_management user.

Single server:

sql
CREATE USER principal IDENTIFIED WITH sha256_password BY 'PASSWORD';
GRANT ACCESS MANAGEMENT ON *.* TO principal WITH GRANT OPTION;
GRANT SHOW, SELECT, INSERT, ALTER, CREATE, DROP, TRUNCATE, OPTIMIZE, dictGet
  ON *.* TO principal WITH GRANT OPTION;

Cluster (match form cluster name):

sql
CREATE USER principal ON CLUSTER CLUSTER_NAME
  IDENTIFIED WITH sha256_password BY 'PASSWORD';
GRANT ON CLUSTER CLUSTER_NAME REMOTE ON *.* TO principal;
GRANT ON CLUSTER CLUSTER_NAME CLUSTER ON *.* TO principal WITH GRANT OPTION;
GRANT ON CLUSTER CLUSTER_NAME ACCESS MANAGEMENT
  ON *.* TO principal WITH GRANT OPTION;
GRANT ON CLUSTER CLUSTER_NAME
  SHOW, SELECT, INSERT, ALTER, CREATE, DROP, TRUNCATE, OPTIMIZE, dictGet
  ON *.* TO principal WITH GRANT OPTION;
Privilege Purpose
ACCESS MANAGEMENT
Manages users, roles, grants.
CLUSTER
ON CLUSTER DDL (cluster only). WITH GRANT OPTION needed for rules granting CLUSTER.
REMOTE
Reads all replicas (cluster only).
SHOW…dictGet WITH GRANT OPTION
Covers all grantable ClickHouse privileges.

Test checks all replicas.

MongoDB#

Requires 7.0+ with authorization on. Run in mongosh as user admin:

javascript
db.getSiblingDB("admin").createUser({
  user: "principal",
  pwd: "PASSWORD",
  roles: [
    { role: "userAdminAnyDatabase", db: "admin" },
    { role: "readAnyDatabase", db: "admin" },
    { role: "clusterMonitor", db: "admin" },
  ],
})
Role Purpose
userAdminAnyDatabase
Manages users, roles, grants across DBs.
readAnyDatabase
Lists DBs/collections for Resources and masks (sales_*).
clusterMonitor
Checks authorization state (optional).

Use authSource=admin (mongodb://principal:[email protected]:27017/?authSource=admin). Atlas blocks createUser (observe-only).

Kubernetes#

Run as cluster admin to create ServiceAccount principal (cluster-admin) and principal-kubeconfig.yaml:

bash
kubectl -n kube-system create serviceaccount principal
kubectl create clusterrolebinding principal \
  --clusterrole=cluster-admin \
  --serviceaccount=kube-system:principal

kubectl apply -f - <<'EOF'
apiVersion: v1
kind: Secret
metadata:
  name: principal-token
  namespace: kube-system
  annotations:
    kubernetes.io/service-account.name: principal
type: kubernetes.io/service-account-token
EOF
until kubectl -n kube-system get secret principal-token \
  -o jsonpath='{.data.token}' | grep -q .; do sleep 1; done

SERVER=$(kubectl config view --minify \
  -o jsonpath='{.clusters[0].cluster.server}')
CA=$(kubectl -n kube-system get secret principal-token \
  -o jsonpath='{.data.ca\.crt}')
TOKEN=$(kubectl -n kube-system get secret principal-token \
  -o jsonpath='{.data.token}' | base64 -d)
cat > principal-kubeconfig.yaml <<EOF
apiVersion: v1
kind: Config
clusters:
- name: target
  cluster:
    server: ${SERVER}
    certificate-authority-data: ${CA}
users:
- name: principal
  user:
    token: ${TOKEN}
contexts:
- name: principal
  context:
    cluster: target
    user: principal
current-context: principal
EOF

Paste principal-kubeconfig.yaml into the target form, then delete it. Use an SSH tunnel for private API servers. Principal needs cluster-admin for arbitrary RBAC and SSO gate setup, and only alters labeled RBAC objects (Targets).

kubectl sign-in through Principal

Configure the API server for Principal Dex tokens using preferred_username and groups (no prefixes). Use per-person rules only with one connector, and group rules with multiple connectors.

↑ ↓ to moveEnter to openEsc to close