On this page
You need:
- The Admin role in a Principal organization.
- Read-only credentials for GitLab, GitHub, Google Workspace or LDAP.
- Superuser (or master user) access on a test PostgreSQL server, plus
psql.
1. Sign in#
Enroll a second factor during sign-in if prompted: creating a connector and revealing another person’s credentials require one.
- Open your Principal address and click Continue with SSO.
- Sign in with your identity provider.
- Confirm your second factor with Verify code or Use security key, or click Use an authenticator app to enroll one.
You land on the dashboard with the action queue, Quick actions and Infrastructure. If you land on Your access, an administrator must change your role from User to Admin under Organizations.
2. Import your people#
- Open Connectors, click Create in the top bar and choose Create connector.
- Enter a Name such as Corporate GitLab and pick GitLab, GitHub, Google Workspace or LDAP.
- Open Connection and enter the address and credentials, for GitLab Base URL and Token (Supported providers).
- Open Test & discover and click Test connection & discover groups.
- Under Group filters (Groups for Google Workspace, Filters for LDAP), select one test group such as
acme/analytics. - Click Test connection & discover groups again.
- Click Create and confirm your second factor if prompted.
- Click Run first sync.
When sync finishes, Sync reports Sync completed with user and group counts. Open People → Groups to confirm your group appears with mode Managed. See Connectors for schedules and duplicates.
3. Add a target#
On your test PostgreSQL server, connect as a superuser (or master user) and create Principal’s role. Replace PASSWORD (from openssl rand -hex 24), APP_DB and the owner role APP_OWNER:
CREATE ROLE principal LOGIN PASSWORD 'PASSWORD' CREATEROLE;
GRANT pg_signal_backend TO principal;
GRANT CONNECT ON DATABASE APP_DB TO principal WITH GRANT OPTION;
GRANT APP_OWNER TO principal;Allow Principal to connect in pg_hba.conf or your firewall. See Prepare a target for other engines.
- Open Resources, click Create and choose Create target.
- Under Basics, enter a Display name such as warehouse-staging, pick PostgreSQL and leave Managed by Principal on.
- Open Connection, paste
postgres://principal:<password>@db.example.com:5432/app?sslmode=requireinto Connection string and click Apply. - Click Run test and wait for the checks to pass.
- Click Create target.
Discovery runs automatically. When it finishes, the header shows Scanned just now · Up to date, Databases lists your schemas and tables, and existing roles appear as Unmanaged in Roles. See Add a target and Target details.
4. Grant access#
Create a template for warehouse-staging:
- Open Rules & templates, click Create and choose Create template.
- Enter Name warehouse-read-only.
- Choose One server and pick warehouse-staging in Server.
- Open Databases, choose Select and tick your test database, for example
app. - Open Permissions and pick Read-only.
- Click Create.
Attach the template to your group:
- On the warehouse-read-only page, click Give access.
- Under People, tick your test group, for example analytics.
- Confirm Permissions and Targets are pre-filled.
- Click Create and apply.
Principal applies the rule in the background, creating a login role and grants for each member:
CREATE ROLE "anna_lee" WITH LOGIN PASSWORD '<generated>';
GRANT CONNECT ON DATABASE "app" TO "anna_lee";
GRANT USAGE ON SCHEMA "public" TO "anna_lee";
GRANT SELECT ON ALL TABLES IN SCHEMA "public" TO "anna_lee";
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA "public" TO "anna_lee";When apply finishes, the rule shows Applied and History lists the change count. If it shows Failed, check Needs attention and Apply a rule.
5. Verify the result#
- Open Resources → warehouse-staging and check Roles for each group member with Ownership set to Principal-created.
- Ask a group member to open Your access and click Reveal, or click Credentials on their row under Roles and click Reveal.
- Connect with
psqlusing the revealed role and password:bashpsql "postgres://[email protected]:5432/app?sslmode=require" - Run a
SELECTon a table inpublicto confirm read access. - Run an
INSERTorDELETEon that table and confirm PostgreSQL returnspermission denied. - Open Drift and click Check all targets.
Out of sync has no rows for your rule, or shows Everyone has exactly what the rules give. Connector syncs add roles for new members and remove them when members leave. To test out-of-band changes, see Drift.
Next steps#
- Rules and templates: template versions, object masks and the one-rule-per-target model.
- Bring an existing database under management: observe a database and adopt roles in place.
- Give temporary access: time-boxed access that expires automatically.
- API quick start: automate rules and drift checks.
- Security policy: require two-factor authentication and set session and reveal limits.