Skip to content

Sign-in and authorization

By default, the server has no sign-in, and every client can do everything. To turn sign-in on:

[auth]
enabled = true
signing_key_file = "/etc/uc/signing-key.pem"
admin_principals = ["alice@example.com"]

[[auth.users]]
email = "alice@example.com"
name = "Alice"

Then each API request needs the token of an active user. The client sends it in the Authorization: Bearer <token> header or in the UC_TOKEN cookie. The server checks the user's privileges. The web UI, its sign-in, /docs, /healthz and /version need no token.

To set up sign-in:

  1. Make a signing key.
  2. Name the first users and admins.
  3. Add your identity providers.
  4. Optional: set up sign-in to the web UI.
  5. Grant privileges.

Settings lists every key of [auth] and [[auth.issuers]].

The signing key

The server signs its own tokens with an RSA key. To make a key file:

(umask 077 && uc-server keygen > signing-key.pem)

Set signing_key_file to this file, and keep the file secret.

Without signing_key_file, the server uses a key that it makes in memory at each start. Use this only for a local development server or for tests in CI: all sign-ins end when the server stops, and replicas refuse each other's tokens.

A new signing key

The file can hold several keys, newest first. The first key signs new tokens. Each key still checks the tokens that it signed. Personal access tokens do not use the key.

To change the key and keep the sign-ins:

  1. Put a new key first in the file, and restart the server:

    (umask 077 && { uc-server keygen; cat signing-key.pem; } > new.pem) && mv new.pem signing-key.pem
    
  2. Wait for access_token_timeout (default 24h), until the old key's tokens have expired. Remove the old key from the file, and restart the server again.

A server refuses the tokens of a key that is not in its file. So with several servers that share sign-ins, do step 1 in two rounds: put the new key last in the file and restart each server, then move it first and restart each server again.

To end all sign-ins at once, replace the file with a file that has only a new key.

The first users

At each start, the server makes the users of [[auth.users]] and admin_principals that are missing. It grants the missing privileges of [[auth.users]] on the metastore: CREATE CATALOG, CREATE STORAGE CREDENTIAL, CREATE EXTERNAL LOCATION or READ METADATA. It never changes or deletes a user that exists. The users of admin_principals are admins. A user that was deleted through SCIM stays deleted: the server logs a warning at each start, until an admin creates the user again or the entry leaves the settings.

[[auth.users]]
email = "bob@example.com"
name = "Bob"
privileges = ["CREATE CATALOG"]

With an identity provider, the first admin signs in and adds the other users. Before that, or without a provider, use uc-server token. It prints a token of the server's own admin user, valid for one hour. Run it where the server runs, with the server's settings and signing_key_file:

export UC_CLI_TOKEN=$(uc-server token)
uc user create --name Bob --email bob@example.com

Users and groups

  • A user's email is its name in grants and as an owner: its primary email, else its first. A user without an email, such as an application (Who a token names), uses its userName.
  • When a user's email changes, its grants, owned objects and tokens move to the new email. A server token that the user got before the change stays valid. admin_principals and Cedar policies still name the old email: the server logs a warning for each of them. create_users makes no user with the old email at sign-in.
  • A privilege granted to a group applies to each member. A group's name is its name in grants. It cannot be the email or the userName of a user, in any case, and a user cannot take the name of a group. A grant to a name goes to the group with that name, else to the user with that email, else to the user with that userName.
  • To stop a user from signing in, disable it. When you delete a user, the server deletes it with its grants, tokens and group memberships. The objects that it owned have no owner then, so a later user with the same email does not get them. An admin can give them a new owner. A deleted group also leaves its objects without an owner.
  • create_users does not make a deleted user again at sign-in. To let the user in again, make it by hand or from your identity provider.
  • admin is the name of the server's own user. No other user can have it as userName or email, and no group can have it as name. The server's own user cannot be renamed, disabled or deleted.
  • Emails, userName values and group names are unique in any case. The external ids of users are unique as they are written: Ab1 and ab1 are two ids.
  • Only admins can add, change or delete users and groups.

Manage users by hand

Use uc, the Python client, or the "Users" and "Groups" pages of the web UI:

uc user create --name Bob --email bob@example.com
uc group create --name analysts

Add members to a group on its page in the web UI. To let users in without adding them first, set create_users = true on the provider's block: the server then makes each user at their first sign-in.

Sync users from your identity provider (SCIM)

SCIM is the standard API that identity providers use to copy their users and groups to other services. The server has the SCIM 2.0 API (RFC 7643 and RFC 7644), so a provider such as Entra ID, Okta or authentik can make, change, disable and delete its users and groups in the server. In the provider's provisioning settings, enter:

  • URL: https://uc.example.com/api/1.0/unity-control/scim2. Entra ID calls it the tenant URL.
  • Token: a personal access token of an admin. Entra ID calls it the secret token.

The server keeps each user's userName, name, display name, emails, pictures, state and external id as the provider sends them, and leaves out the other attributes, such as title. A provider finds its users again by userName, so the server never changes it. A token of a provider whose issuer has no * can name a user by its userName too, such as an Entra UPN that differs from the user's email.

A PUT needs the userName of the user or the displayName of the group. It keeps each other attribute that its body leaves out, so a provider that sends only a part of a user or group does not clear the rest. To clear an attribute, send it as null or as an empty list. A PUT with "active": null does not change active. Each error of the SCIM API has the SCIM error format and only its attributes, also a timeout and a rate limit.

The URLs in SCIM answers start with auth.public_url when it is set. Without it, they start with the URL that the provider called.

Use one way to get groups from a provider: SCIM or groups_claim (Groups). A group that SCIM makes has the provider's name, such as Writers, while groups_claim reads the groups of a token as entra:Writers.

Tokens

A client signs in with one of these tokens:

  • A provider's token, on each request. The client sends the token of your identity provider with each request, and the server checks it each time. The provider's block needs direct = true. Use this for service principals, managed identities, service accounts, CI jobs and engines such as pyiceberg. The Python client and uc find this identity in the environment themselves.
  • A server token, from the exchange. The client sends a token of your identity provider to /api/1.0/unity-control/auth/tokens and gets a token of the server back. Then it sends the server's token with each request. uc auth login signs in this way. A block with direct = true accepts its tokens both ways. A block without it accepts them only at the exchange.
  • A personal access token. A signed-in user makes one for scripts: uc token create --name ci. It does not expire, unless you set --expires_at.
  • OAuth client credentials. The client sends a personal access token as its client secret, and the token's id as its client id, to /api/2.1/unity-catalog/oauth/token.

Identity providers

An identity provider signs your users and applications in, such as Microsoft Entra, Google or Keycloak. Add one [[auth.issuers]] block for each provider:

[[auth.issuers]]
name = "entra"
issuer = "https://login.microsoftonline.com/<tenant>/v2.0"
audiences = ["<the API app's client id>", "https://uc.example.com"]
direct = true
principal_claims = ["preferred_username", "oid"]
client_claims = ["azp", "appid"]
groups_claim = "roles"
create_users = true
display_name = "{app_displayname}"

A token is a set of signed fields, called claims. The block tells the server which tokens to accept, and how to read their claims:

Key What it does
name A short name for the provider. It is the prefix of the users that it names without an email, such as entra:7f3e….
kind oidc (default) for an OpenID Connect provider, or aws for AWS.
issuer The provider's iss claim, exactly as its tokens write it. * matches one part of a host name, such as https://*.dev.example.com.
audiences The aud values to accept. Use the server's URL, and any other value that the provider puts in aud. ["*"] accepts every value, but not with direct.
direct Accept the tokens on each request, not only at the exchange.
principal_claims The claims that name the user. The first claim that the token has wins.
client_claims The claims that hold an application's client id.
groups_claim The claim that lists the user's groups (Groups).
create_users Make a missing user at its first request.
display_name The display name of a new user, with claims in braces.

Clients read the blocks at GET /.well-known/oauth-protected-resource (RFC 9728), so they know which audience to ask the provider for. The Python client and uc use the audience that UC_AUDIENCE names, else the audience that is the server's URL as they call it. They use no other audience, so a server cannot make a client's identity sign for another service.

Several blocks can have the same issuer with different audiences. A token goes to the first block that has its issuer and its audience.

Who a token names

The server finds one user for each token. The user's principal is its name in grants, owners, admin_principals and Cedar's User::"…": an email, or <name>:<value>.

The examples use the Entra block above: name = "entra", principal_claims = ["preferred_username", "oid"], client_claims = ["azp", "appid"] and create_users = true. The server tries three steps, in order.

1. A name claim. The server takes the first claim of principal_claims that the token has:

The token has User Why
"preferred_username": "alice@example.com" alice@example.com An email names the user with that email, in any case: Alice@Example.com is the same user.
"preferred_username": "alice@example.com", and SCIM made the user with that userName and the email alice.smith@example.com alice.smith@example.com No user has the email, so the user with it as userName.
"oid": "7f3e…", and no preferred_username entra:7f3e… Any other value gets the block's name as a prefix.
"oid": "7f3e…", and the user entra:7f3e… got the email etl@example.com later etl@example.com entra:7f3e… is still the userName of the user.
"preferred_username": "alice@example.com", "email_verified": false nobody The provider has not verified the email.
"preferred_username": "alice@example.com", at an issuer with * nobody At an issuer with *, an email needs "email_verified": true.
  • Use only claims that the provider sets. If users can set a claim themselves, a user can set it to the email of another user.
  • Anyone can make an issuer that * matches, such as a new Entra tenant, and give its users any email. Entra does not send email_verified, so a block for many Entra tenants needs principal_claims = ["oid"].

2. An application. When step 1 finds no user and the token is an application's own, the server looks for the user whose externalId is <name>:<client id>. A token of an ETL job's service principal:

{ "idtyp": "app", "oid": "9a1b…", "azp": "c0ffee…", "app_displayname": "ETL" }

No user is named entra:9a1b…. The token has idtyp = app, so the server looks for the user whose externalId is entra:c0ffee…: azp is the first of client_claims. To give the job a name of your choice, make its user ahead of time, with uc or external_id in [[auth.users]]:

uc user create --name ETL --email etl@example.com --external_id entra:c0ffee…

The token then names etl@example.com. An application's own token is an Entra access token with idtyp = app, a token whose sub is its client id (RFC 9068), or an AWS identity. A person's token never matches here: it holds the client id of a tool that many people share, such as az.

3. A new user. When no user is found, create_users = true makes one:

  • Alice's token makes alice@example.com.
  • The ETL token makes entra:9a1b…, with the externalId entra:c0ffee… and the display name ETL (from display_name = "{app_displayname}").

Without create_users, the server refuses the request with "User not allowed". It also refuses a user that an admin deleted (Users and groups).

A disabled user names nobody. No token can name the server's own admin user.

The web UI's sign-in (oidc_issuer) finds users in the same way, with the block of that issuer when there is one. So with create_users, the first sign-in makes the user.

Groups

To take the user's groups from the provider's tokens:

  1. Set groups_claim to the claim that lists the groups.
  2. Make each group in the server, named <name>:<value>: uc group create --name entra:Writers.
  3. Grant privileges to the group.

A user whose token lists Writers then gets the privileges of entra:Writers, in addition to the user's groups in the server. Values without a group in the server do not count. The prefix keeps each provider to its own groups.

  • Entra: use roles. Entra's groups claim holds object ids, but app roles that you assign to Entra groups arrive as names.
  • An issuer with *: groups_claim is not allowed, because each issuer that it matches, such as each tenant, would name the same groups.

Providers

Use the block at the top of Identity providers. In Entra, on the app registration of the server (the API app):

  1. Set the Application ID URI to the server's URL, such as https://uc.example.com. Its domain must be verified in the tenant. Clients then ask for the scope https://uc.example.com/.default.
  2. In the manifest, set accessTokenAcceptedVersion to 2. A v2 access token has the API app's client id as its aud, so audiences lists it.
  3. Add the optional claim idtyp to access tokens, so the server can tell applications from people.
  4. For groups, make app roles and assign them to Entra groups (Groups).

Then Alice's token names alice@example.com, and an application's token names the user whose externalId is entra:<client id> (Who a token names).

To take v1 tokens instead of step 2, add a block with issuer = "https://sts.windows.net/<tenant id>/", principal_claims = ["upn", "oid"] and client_claims = ["appid"].

[[auth.issuers]]
name = "google"
issuer = "https://accounts.google.com"
audiences = ["https://uc.example.com"]
direct = true
create_users = true
  • Google's access tokens have no claims that the server can read. So clients send an ID token, with the server's URL as its audience. The Python client and uc do this for a service account, the Google Cloud CLI, and a Google machine or pod.
  • The default principal_claims (email, then sub) fit Google: the service account etl@my-project.iam.gserviceaccount.com is the user with that email.

Any OpenID Connect provider works, such as Keycloak, Okta or FerrisKey:

[[auth.issuers]]
name = "keycloak"
issuer = "https://keycloak.example.com/realms/main"
audiences = ["<client id>"]
  • issuer is the issuer of the provider's <issuer>/.well-known/openid-configuration. The server reads that document and the provider's keys, so it must reach them.
  • Without direct, the block takes tokens only at the exchange: users sign in with uc auth login, whose OAuth client is <client id>.
[[auth.issuers]]
name = "github"
issuer = "https://token.actions.githubusercontent.com"
audiences = ["https://uc.example.com"]
direct = true
principal_claims = ["sub"]

A job asks GitHub for a token with the server's URL as its audience, and gives it to the client in UC_TOKEN:

permissions:
  id-token: write
steps:
  - run: |
      token=$(curl -sH "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
        "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://uc.example.com" | jq -r .value)
      echo "UC_TOKEN=$token" >> "$GITHUB_ENV"

The token's sub names the repository and the branch: a job of octo-org/etl on main is the user github:repo:octo-org/etl:ref:refs/heads/main. Any repository can ask GitHub for a token with your audience, so leave create_users off, and make the users of your own jobs ahead of time:

uc user create --name "etl CI" --email github:repo:octo-org/etl:ref:refs/heads/main
[[auth.issuers]]
name = "k8s"
issuer = "https://oidc.eks.eu-west-1.amazonaws.com/id/<cluster id>"
audiences = ["https://uc.example.com"]
direct = true
create_users = true
  • issuer is the cluster's issuer, as kubectl get --raw /.well-known/openid-configuration shows. The server must reach it.
  • Give the pod a token for the server, and point UC_TOKEN_FILE at it:

    spec:
      serviceAccountName: etl
      containers:
        - name: etl
          env:
            - name: UC_TOKEN_FILE
              value: /var/run/secrets/uc/token
          volumeMounts:
            - name: uc-token
              mountPath: /var/run/secrets/uc
      volumes:
        - name: uc-token
          projected:
            sources:
              - serviceAccountToken:
                  audience: https://uc.example.com
                  path: token
    
  • The token names the pod's service account: etl in the namespace data is the user k8s:system:serviceaccount:data:etl.

AWS roles and IAM users have no tokens. They sign a request instead:

[[auth.issuers]]
name = "aws"
kind = "aws"
audiences = ["https://uc.example.com"]
accounts = ["123456789012"]

See AWS.

How the server checks a token

  • It checks the signature with the provider's keys, and the issuer, audience and times, with 60 seconds of clock skew. A token without exp is refused.
  • It fetches a provider's keys once an hour, and never more than once a minute. When the provider does not answer, or its answer is not a key set or has no key that the server can use, it keeps the keys it has, for one day at most. A key set with no keys at all withdraws them. So does an answer that there is no such provider: an HTTP 4xx other than 407, 408 and 429, or a discovery document that is not the provider's. The server starts the fetch five minutes before the hour ends, so requests do not wait for it. When the keys are older than one hour, a request waits for the new keys, so a key that the provider withdrew is refused. Only while the provider does not answer, a request uses the kept keys at once.
  • For an issuer with *, it fetches keys for the new issuers of each client until 20 of them answered that they have none in a minute, and for at most 200 new issuers in a minute. A new issuer that does not answer, or answers with HTTP 5xx, is not one of the 20, so issuers that were down for a short time do not stop the client's other new issuers. A new issuer whose host name has no address is one of the 20; one whose name could not be looked up is not. It fetches for 20 new issuers of a client at a time; the others wait, for 4 seconds at most. For all clients together, it fetches for at most 400 new issuers of one issuer in a minute. At most 200 of them are for clients that have a new issuer in that minute that did not answer with keys. The rest stays free for the first new issuer of each client, and for its next one after each that had keys. So tokens with made-up issuers cannot make it call out for each one, and the made-up issuers of a few clients do not stop the new issuers of the others. While such tokens arrive, a new issuer can get HTTP 500 until the next minute. A client is an address: see Behind a proxy.
  • It accepts a key whose alg is ES512, as it does a key without alg. It does not use encryption keys ("use": "enc").
  • It keeps a token from a direct block until the token expires, for at most five minutes. A busy client then costs one check per token, not one per request. A user disabled in the server can still make requests for that time.

AWS

AWS roles and IAM users have no token that the server can check. So the client signs an sts:GetCallerIdentity request and sends it as the bearer token. The server sends it on to AWS STS, which checks the signature and returns the caller's ARN. The credentials never leave the client. Vault and the EKS authenticator use the same method.

[[auth.issuers]]
name = "aws"
kind = "aws"
audiences = ["https://uc.example.com"]
accounts = ["123456789012"]
create_users = true
  • audiences holds the server id: the server's URL as clients call it. List each URL that clients use. The client signs the server id into the request, so the server refuses a request that was signed for another server. A client signs only the URL that it calls, or the server id that UC_AUDIENCE names, so another server cannot make it sign for this one.
  • accounts holds the AWS accounts to accept. It is required, because STS answers for every account.
  • issuer is optional: an STS endpoint, such as a VPC endpoint. The default is AWS's global and regional endpoints. The server sends signed requests to no other host.
  • Users are named by their ARN. An assumed role is aws:arn:aws:iam::<account>:role/<name>, so all sessions of a role are one user. The role's path is not part of the name. An IAM user is aws:arn:aws:iam::<account>:user/<name>.
  • A user made ahead of time is the role when its externalId is <name>:<the role's ARN>, such as aws:arn:aws:iam::123456789012:role/etl.

A signed request is valid for 15 minutes. The server keeps the caller for five minutes, as it does for tokens. AWS identities are accepted on each request. They have no token exchange and no groups. When STS limits the server's requests, or a proxy on the way answers in its place, the server answers with HTTP 500, not "Invalid access token".

The server sends at most 20 requests to STS at a time. After 100 refused requests of one client in a minute, it sends none of that client until the next minute. So requests with made-up signatures cannot make it call STS for each one. That client gets HTTP 500 for new callers until then. The other clients are not affected, nor are the callers that the server keeps. A client is an address: see Behind a proxy.

After 10 refused requests of one client with one access key in a minute, the server refuses the next requests with that key without a request to STS, and does not count them for the 100. So one job whose credentials expired does not stop the other callers behind its address.

After 100 requests of one client in a row that STS did not answer, the server sends one request of that client at a time. The first answer of STS ends this, so the client is served again as soon as STS is. So does a minute without a request of that client. A request that ends before STS answers, such as one that timed out, counts as not answered.

A client that had a refused request in the current minute, or an unanswered one since the last answer of STS, shares 10 of the 20 requests at a time with the other such clients. So does each request of a client that waits or runs next to another request of that client. The other 10 stay free for one request at a time of each client that had none.

The server sends the headers that the request signs to STS, except those of the connection, such as Host. Of the headers that the request does not sign, it sends X-Amz-Security-Token, and a Content-Type that it writes itself. The request must sign X-Amz-Date. STS can answer in XML or in JSON.

Behind a proxy

The limits on new issuers and on requests to STS count for each client, and so does server.rate_limit_per_sec. A client is the address of the connection; all addresses of one IPv6 /64 network are one client. Behind a proxy, such as an ingress, each connection comes from the proxy, so all callers are one client: one caller that reaches a limit then stops the others.

Set trusted_proxies to the addresses of the proxies:

[auth]
trusted_proxies = ["10.42.3.17", "10.42.5.4"]

On a connection from one of them, the client is the last address in X-Forwarded-For that is not a proxy's. Each proxy must add the address of its client to this header. If one does not, a caller can write the header itself and choose its address.

Warning

Each address in trusted_proxies can name any client. If you set a network that holds more than the proxies, such as the pod network 10.42.0.0/16, each workload in it can connect to the server, write X-Forwarded-For itself, and so use up the limits of another client or have no limit of its own. When the proxies have no fixed addresses, set their network and let only the proxies connect to the server, such as with a network policy.

When trusted_proxies does not name a proxy that is in front of the server, the server writes one warning to its log: a request with X-Forwarded-For came from an address that is no trusted proxy.

This setting does not change context.source_ip in Cedar policies, nor forward_trusted_proxies.

Sign in to the web UI

auth.mode sets how users sign in to the web UI: none (the default), oidc or forward. A user can sign in when their email names an active user of the server.

OpenID Connect

[auth]
mode = "oidc"
public_url = "https://uc.example.com"
oidc_issuer = "https://accounts.google.com"
oidc_client_id = "<client id>"
oidc_client_secret = "<client secret>"   # none for a public client
  • In the provider, allow the redirect URI https://uc.example.com/auth/callback.
  • "Log out" ends only the sign-in to the web UI. With oidc_end_session = true, it also ends the provider's session.

An auth proxy

An auth proxy, such as oauth2-proxy, Authelia or Envoy Gateway, signs users in and sends the user's name in a header:

[auth]
mode = "forward"
forward_trusted_proxies = ["10.42.0.0/16"]
forward_logout_url = "https://auth.example.com/logout"

The server reads the email from Remote-Email, else the user from Remote-User. It reads these headers only on connections from forward_trusted_proxies. The first of these headers that has a value names the user. If it has more than one value, in several lines or with a , between, it names nobody: the proxy must replace the client's value, not add to it. A value that is not UTF-8 names nobody either.

Some proxies name users with a ,, such as the subject of a client certificate (CN=alice,OU=eng). With forward_names_with_commas = true, a value with a , is one name. Set it only when the proxy replaces the client's header.

Envoy Gateway

Envoy Gateway 1.2 or later can be the auth proxy. It needs two policies:

  • A SecurityPolicy on the web UI's route signs users in with OpenID Connect. Its JWT provider reads the ID token from its cookie, and puts the token's email in Remote-Email.
  • A ClientTrafficPolicy on the Gateway removes Remote-Email and Remote-User from each client request. Envoy does not replace a header that the client sends, so without this policy a client could name any user.
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: SecurityPolicy
metadata:
  name: uc-web-ui
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: HTTPRoute
      name: uc-web-ui              # the route of the web UI's host only
  oidc:
    provider:
      issuer: https://accounts.google.com
    clientID: <client id>
    clientSecret:
      name: uc-oidc                # a Secret with the key client-secret
    redirectURL: https://uc.example.com/oauth2/callback
    logoutPath: /logout
    cookieNames:
      idToken: uc-id-token
  jwt:
    providers:
      - name: id-token
        issuer: https://accounts.google.com
        audiences: ["<client id>"]
        remoteJWKS:
          uri: https://www.googleapis.com/oauth2/v3/certs
        extractFrom:
          cookies: [uc-id-token]
        claimToHeaders:
          - header: Remote-Email
            claim: email
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
metadata:
  name: uc
spec:
  targetRefs:
    - group: gateway.networking.k8s.io
      kind: Gateway
      name: <gateway>
  headers:
    earlyRequestHeaders:
      remove: [Remote-Email, Remote-User]
[auth]
mode = "forward"
forward_trusted_proxies = ["10.42.0.0/16"]           # the addresses of the Envoy pods
forward_logout_url = "https://uc.example.com/logout"  # the policy's logoutPath

Give the SecurityPolicy only the web UI's route, for example on a host of its own. uc, the Python client and other API clients send the server's tokens. OpenID Connect would send their requests to the provider's sign-in page.

Privileges

A securable is an object that privileges apply to, such as a catalog, schema or table.

  • The user who makes a securable owns it, and can grant privileges on it.
  • A privilege on a catalog or schema applies to everything in it.
  • To read a table, a user needs USE CATALOG on its catalog, USE SCHEMA on its schema, and SELECT on the table. MODIFY alone does not read a table or its metadata.
  • Admins read everything, make catalogs, credentials and external locations, manage users, and grant any privilege.
  • External tables and volumes, and the credentials of a path, need an external location that covers the path. This applies to admins too.
Privilege Lets the user Granted on
CREATE CATALOG Make catalogs. Metastore
USE CATALOG Use a catalog and what it holds. Catalog
CREATE SCHEMA Make schemas. Catalog
USE SCHEMA Use a schema and what it holds. Catalog, schema
CREATE TABLE, CREATE VOLUME, CREATE FUNCTION, CREATE MODEL Make these in a schema. Catalog, schema
SELECT, MODIFY Read a table, change its data. Catalog, schema, table
READ VOLUME, WRITE VOLUME Read the files of a volume; with both, write them. Catalog, schema, volume
EXECUTE Run a function; read a registered model. Catalog, schema, function, registered model
CREATE MODEL VERSION Add versions to a registered model. Catalog, schema, registered model
CREATE STORAGE CREDENTIAL Make storage credentials. Metastore
CREATE EXTERNAL LOCATION Make external locations with a credential. Metastore, credential
READ FILES, WRITE FILES Read and write files under an external location. External location, credential
CREATE EXTERNAL TABLE Make tables under an external location. External location, credential
CREATE EXTERNAL VOLUME Make volumes under an external location. External location
CREATE MANAGED STORAGE Use a path under an external location as a storage root. External location
MANAGE Do what the owner does to the object: change it, delete it and change its grants. All but the metastore
READ METADATA Read the object, what it holds and their grants. All
BROWSE See that the object and what it holds exist. Catalog, external location

The server refuses a grant on an object that does not take the privilege.

MANAGE, READ METADATA and BROWSE give no access to data: no credentials and no table loads through the Delta or Iceberg APIs. Iceberg load table gives the metadata to a user with READ METADATA, and credentials only to a user who can read the table.

  • A new name through MANAGE also needs the privilege to make the object: CREATE CATALOG for a catalog, CREATE SCHEMA for a schema, CREATE TABLE, CREATE VOLUME or CREATE MODEL for what a schema holds.
  • A user with CREATE MODEL VERSION adds a version and uploads its files. Only the user who made a version can finalize it. Read credentials need a finalized version.
  • A user with only BROWSE gets an object when the request has include_browse=true. The answer then has browse_only: true and the discovery fields: a table without its storage location, properties and view definition, a function without its body, an external location without its credential. Lists with include_browse=true can hold both kinds of object. Search (GET /search) also finds the objects of a catalog with BROWSE.
uc permission create --securable_type table --name main.default.events \
  --principal bob@example.com --privilege SELECT
uc permission get --securable_type table --name main.default.events

Cedar policies

Cedar is a policy language. With auth.engine = "cedar", Cedar checks the privileges. Its default policy allows what the grants allow. To add your own rules, list your policy files in auth.cedar_policies:

[auth]
enabled = true
engine = "cedar"
cedar_policies = ["/etc/uc/policies.cedar"]
// Only owners and admins change the tables of this catalog.
forbid (
  principal,
  action == Action::"MODIFY",
  resource in Catalog::"<catalog id>"
);

Give each policy an @id("…") that no other policy in the files has. granted is the id of the default policy. When two policies have the same @id, the server does not start, and names the file.

For each check, the server asks Cedar: can this principal do this action on this resource?

Part Cedar Example
Principal User::"<email>": the signed-in user User::"alice@example.com"
Action Action::"<privilege>", with the spaces of the privilege Action::"USE CATALOG"
Resource <type>::"<id>": the securable of the check, by its id, such as the catalog for USE CATALOG and the table for SELECT Catalog::"6f1e…"

The actions are the privileges of the table in Privileges. The resources, and where to find their ids:

Resource Id Shown by
Metastore::"<id>" metastore_id uc metastore get
Catalog::"<id>" id uc catalog get
Schema::"<id>" schema_id uc schema get
Table::"<id>" table_id uc table get
Volume::"<id>" volume_id uc volume get
Function::"<id>" function_id uc function get
RegisteredModel::"<id>" id uc registered_model get
ExternalLocation::"<id>" id uc external_location get
Credential::"<id>" id uc credential get

An id stays the same when you rename the securable. A securable that you drop and make again gets a new id.

  • Parents: a table, volume, function or model is in its schema, a schema is in its catalog, and a catalog is in the metastore. So resource in Catalog::"<id>" matches everything in the catalog. External locations and credentials have no parent.
  • Resource attributes:
    • owner: the owner's email, when the resource has an owner.
    • granted_privileges: the actions granted on the resource or on a parent, to the user or to a group of the user.
  • Groups are not Cedar entities, so a policy cannot say principal in Group::"…". Their grants are in granted_privileges.
  • Context: how and from where the request came.

    Attribute Type Value
    context.auth_method String jwt (a provider's token), aws-sigv4, trusted-headers (an auth proxy), server-token, or personal-access-token
    context.provider String The name of the [[auth.issuers]] block, forward behind an auth proxy, or internal for the server's tokens
    context.groups Set<String> The groups that the token names (groups_claim), as <name>:<value>
    context.source_ip ipaddr The address of the connection, when known
    context.request_time datetime When the request came

    Some requests have no address, so test for source_ip with has:

    // Writes only from the office network.
    forbid (principal, action == Action::"MODIFY", resource)
    unless { context has source_ip && context.source_ip.isInRange(ip("10.0.0.0/8")) };
    
  • Errors deny. A policy that fails, such as one that reads resource.owner of a resource without an owner, denies the request. Test optional attributes with has first.

  • Owners and admins: Cedar decides only whether a user holds a privilege. The checks for an owner or an admin do not ask Cedar, so a forbid does not stop them.

Open Policy Agent

Open Policy Agent (OPA) is a policy server. With auth.engine = "opa", the server asks OPA about each privilege that a request needs, OWNER and the admin included. The policy is in OPA, written in Rego, and OPA can load it again while it runs. The server's rules stay: they say which privileges each request needs, and OPA says whether the user has each one.

[auth]
enabled = true
engine = "opa"
opa_url = "http://opa:8181/v1/data/uc/authz"
opa_timeout = "5s"

opa_url is the URL of the policy's package in OPA's data API: /v1/data/ and the package path. It must be http or https, without a user name, password or fragment. The server does not send the user's token to OPA. Keep others away from OPA: see Protect OPA.

  • Only OPA decides. Grants, the owner of an object and auth.admin_principals give nothing. The admin is the user that OPA gives OWNER on the metastore, so give the server's own user admin a rule too. auth.admin_principals with OPA stops the server at start.
  • Grants stay. uc permission still stores grants, and objects still get an owner. They count again when you change the engine back.
  • One question per privilege. Reading a table asks about USE_CATALOG, USE_SCHEMA and SELECT, and about OWNER, MANAGE and READ_METADATA where the rules allow those instead. The server stops asking when the answer is clear. It asks each question once per request, and keeps no answer for the next request. A list asks about each item.
  • Failures are 503. When OPA cannot be reached, answers with an error, takes longer than opa_timeout, or answers without a boolean result.allow, the request fails with 503 UNAVAILABLE, also for lists. The server does not fall back to the grants.
  • Users and admins in SCIM. The server does not delete or deactivate a user that OPA gives OWNER on the metastore, nor the owner of the metastore.

What OPA gets

For each question, the server posts the question as input:

{
  "input": {
    "principal": {
      "id": "<user id>",
      "email": "alice@example.com",
      "external_id": "entra:<object id>",
      "groups": ["entra:analysts"]
    },
    "privilege": "SELECT",
    "resource": {
      "id": "<table id>",
      "type": "TABLE",
      "name": "orders",
      "owner": "bob@example.com",
      "parents": [
        { "id": "<schema id>", "type": "SCHEMA", "name": "sales" },
        { "id": "<catalog id>", "type": "CATALOG", "name": "main" }
      ]
    },
    "context": {
      "auth_method": "jwt",
      "provider": "entra",
      "groups": ["entra:analysts"],
      "source_ip": "10.1.2.3",
      "request_time": "2026-11-14T09:30:00Z"
    }
  }
}
Field Value
principal.id The user's id, as SCIM shows it.
principal.email The user's principal: an email, or <name>:<value> for an application.
principal.external_id The user's externalId, when it has one.
principal.groups The groups that the user's token names (groups_claim), not the server's own groups.
privilege The privilege with _ for spaces, such as USE_CATALOG, or OWNER.
resource.type METASTORE, CATALOG, SCHEMA, TABLE, VOLUME, FUNCTION, REGISTERED_MODEL, EXTERNAL_LOCATION or CREDENTIAL. An uncommitted staging table is a TABLE.
resource.name The object's own name, such as orders of main.sales.orders. The metastore has none.
resource.owner The object's owner in the server, when it has one.
resource.parents For a table, volume, function or model, its schema and catalog; for a schema, its catalog. Others have none.
context How and from where the request came, as for Cedar. Text, not Cedar types.

id, email, external_id, privilege, type, name and parents are what upstream's Java server sends, so a policy written for it works here. groups, owner and context are added. The server sends no grants and no cloud credentials. A caller that no user matches gets no for each question, and OPA is not asked.

OPA must answer with a boolean result.allow:

{ "result": { "allow": true } }

Try a policy

This policy allows everything to the server's own user admin, and to others the grants in OPA's own data. With owner, it also keeps the owners of the server:

package uc.authz

import rego.v1

default allow := false

allow if input.principal.email == "admin"

allow if {
    input.privilege == "OWNER"
    input.resource.owner == input.principal.email
}

allow if {
    some grant in data.grants
    grant.principal == input.principal.email
    grant.privilege == input.privilege
    grant.type == input.resource.type
    grant.id == input.resource.id
}

Start OPA with it, and give alice the privileges to read the schema main.sales:

opa run --server --addr 127.0.0.1:8181 uc.rego
curl -X PUT http://127.0.0.1:8181/v1/data/grants -H 'Content-Type: application/json' -d '[
  {"principal": "alice@example.com", "privilege": "USE_CATALOG", "type": "CATALOG", "id": "<catalog id>"},
  {"principal": "alice@example.com", "privilege": "USE_SCHEMA", "type": "SCHEMA", "id": "<schema id>"}
]'

uc catalog get and uc schema get show the ids.

Protect OPA

OPA has no sign-in by default. Whoever can reach its port can read the policy, and change it or its data through OPA's REST API (PUT /v1/policies, PUT /v1/data). That person can then make themselves the admin of the catalog. Do one of these two things:

  • Run OPA next to the server, where nothing else can reach it. OPA's security guide recommends this.
  • Make OPA take tokens, when it runs as a service of its own.

OPA next to the server

Run OPA as a second container in the server's pod (a sidecar), and let it listen on localhost only. Only the containers of the pod reach it, so it needs no token. With the Helm chart:

auth:
  enabled: true
  opa:
    url: http://localhost:8181/v1/data/uc/authz

server:
  deployment:
    extraContainers:
      - name: opa
        image: openpolicyagent/opa:1.22.4-static
        # The ConfigMap's hidden folders hold the same files again.
        args: [run, --server, --addr, "localhost:8181", "--ignore=.*", /policies]
        securityContext:
          readOnlyRootFilesystem: true
          allowPrivilegeEscalation: false
          capabilities: {drop: [ALL]}
        volumeMounts:
          - {name: opa-policies, mountPath: /policies, readOnly: true}
    extraVolumes:
      - name: opa-policies
        configMap:
          name: uc-opa-policies

Put the policy and its data in the ConfigMap:

kubectl create configmap uc-opa-policies --from-file=uc.rego --from-file=data.json

Each pod has its own OPA, which reads the files when it starts. Data that you PUT into one OPA reaches only that one. To change policies and data without a restart, let each OPA download them as a bundle.

OPA that takes tokens

Start OPA with --authentication=token --authorization=basic. OPA then asks its own policy, system.authz, about each request to it, with the request's bearer token as input.identity. This policy lets the catalog server only ask for decisions of uc.authz, and lets an admin token do everything. Health checks need no token:

package system.authz

default allow := false

allow if {
    input.identity == opa.runtime().env.OPA_CATALOG_TOKEN
    input.method == "POST"
    input.path == ["v1", "data", "uc", "authz"]
}

allow if input.identity == opa.runtime().env.OPA_ADMIN_TOKEN

allow if input.path == ["health"]

OPA reads the tokens from its environment. Make a token for the server, and start OPA with TLS:

openssl rand -hex 32 > opa-token
OPA_CATALOG_TOKEN=$(cat opa-token) OPA_ADMIN_TOKEN=<admin token> \
  opa run --server --addr :8181 --tls-cert-file cert.pem --tls-private-key-file key.pem \
  --authentication=token --authorization=basic system-authz.rego uc.rego

Give the server the token file:

[auth]
enabled = true
engine = "opa"
opa_url = "https://opa.example.com:8181/v1/data/uc/authz"
opa_token_file = "/etc/uc/opa/token"

The server reads the file when it starts, without the spaces and line ends around the token. It sends Authorization: Bearer <token> with each question. With the Helm chart, put the token in a secret, under the key token:

kubectl create secret generic uc-opa-token --from-file=token=opa-token
auth:
  enabled: true
  opa:
    url: https://opa.example.com:8181/v1/data/uc/authz
    tokenSecretName: uc-opa-token
  • Use https. Over http, the token goes unencrypted, and the server logs a warning when it starts. Use http only when the network to OPA encrypts the traffic itself, such as a service mesh.
  • A refused token is 503. When OPA refuses the token, each request that asks OPA fails with 503 UNAVAILABLE: "OPA answered HTTP 401: it refused the server's token".
  • Change the token in three steps. Let system.authz take the old and the new token. Then change the file or secret, and restart the servers. Then remove the old token from the policy.
  • No client certificates. OPA can also check client certificates (--authentication=tls), but the server cannot send one.