a week ago
When deploying Databricks Apps for multiple business teams, how do you decide between user authorization and app authorization?
Consider a document review application.
Finance users can access financial records.
Operations users can access operational records.
Both teams use the same Databricks App.
With app authorization, the application accesses resources using its service principal permissions. With user authorization, supported requests can be evaluated using the individual user identity.
For an application handling sensitive data, I would prefer enforcing access at the data layer rather than relying only on UI-level filtering.
I am interested in how teams handle:
Unity Catalog permissions
User-specific data access
Application service principal permissions
Audit logging
Performance and operational complexity
For production Databricks Apps, which authorization model have you found more practical, and what influenced your decision?
a week ago
Hi @tajamulkhan,
In production I'd use both models in the same app, split by what each call does.
User authorization for anything that reads business data. The app gets the signed-in user's token in the x-forwarded-access-token header, and Unity Catalog applies that user's own grants, row filters and column masks. Finance and operations can share one app, and each team only gets the rows it is allowed to see, with no filtering in the app. When an admin changes a policy, the app picks it up without a redeploy.
App authorization for everything else: the app's own logging, shared configuration and background work that has no user session. That runs as the app's service principal.
What made me land there:
This is the user authorization example from the docs, with the fail-closed check added:
from databricks import sql
from databricks.sdk.core import Config
from flask import abort, request
cfg = Config()
def query_as_user(query):
token = request.headers.get("x-forwarded-access-token")
if not token:
abort(401) # never fall back to the app's service principal
with sql.connect(
server_hostname=cfg.host,
http_path="<your-warehouse-http-path>",
access_token=token,
) as conn:
with conn.cursor() as cursor:
cursor.execute(query)
return cursor.fetchall()The extra work with user authorization is mostly the consent step and getting the scopes right. In return, the permissions stay in Unity Catalog and you don't keep a second copy of them in the app.
If a working example helps, my open-source Unity Catalog browser is a small Databricks App (React and FastAPI) built on user authorization: github.com/surangatj/databricks-uc-browser
a week ago
Hi @tajamulkhan,
In production I'd use both models in the same app, split by what each call does.
User authorization for anything that reads business data. The app gets the signed-in user's token in the x-forwarded-access-token header, and Unity Catalog applies that user's own grants, row filters and column masks. Finance and operations can share one app, and each team only gets the rows it is allowed to see, with no filtering in the app. When an admin changes a policy, the app picks it up without a redeploy.
App authorization for everything else: the app's own logging, shared configuration and background work that has no user session. That runs as the app's service principal.
What made me land there:
This is the user authorization example from the docs, with the fail-closed check added:
from databricks import sql
from databricks.sdk.core import Config
from flask import abort, request
cfg = Config()
def query_as_user(query):
token = request.headers.get("x-forwarded-access-token")
if not token:
abort(401) # never fall back to the app's service principal
with sql.connect(
server_hostname=cfg.host,
http_path="<your-warehouse-http-path>",
access_token=token,
) as conn:
with conn.cursor() as cursor:
cursor.execute(query)
return cursor.fetchall()The extra work with user authorization is mostly the consent step and getting the scopes right. In return, the permissions stay in Unity Catalog and you don't keep a second copy of them in the app.
If a working example helps, my open-source Unity Catalog browser is a small Databricks App (React and FastAPI) built on user authorization: github.com/surangatj/databricks-uc-browser
Friday
I think it mainly depends on what the app needs to access and whose permissions should control that access. User authorization makes more sense when the app needs to access data on behalf of the person using it, since it respects individual permissions and provides better user-level access control. App authorization is usually a better fit for background tasks or shared services that need to access specific resources independently of an individual user.
I'd lean toward user authorization for interactive apps where data access should reflect each user's permissions. For internal tools or automated workflows, app authorization can be simpler to manage. The important thing is to follow the principle of least privilege rather than granting broader access than the app actually needs.
Tuesday
One more difference worth adding, since audit logging was on your list: what the audit log shows.
With user authorization, system.access.audit records the signed-in user in user_identity.email and the app in identity_metadata.acting_resource, so you can see who did what through which app. With app authorization, every call is logged as the app's service principal and acting_resource stays empty, so the end user isn't in the platform audit log at all. If you go that way, log the user yourself from the request headers (for example X-Forwarded-Email).
This query, adapted from the one in the Apps monitoring docs, lists what each app did on behalf of which user in the last 30 days:
SELECT event_date,
identity_metadata.acting_resource AS app_id,
user_identity.email AS user_email,
service_name,
action_name,
COUNT(*) AS event_count
FROM system.access.audit
WHERE event_date >= current_date() - 30
AND identity_metadata.acting_resource IS NOT NULL
GROUP BY ALL
ORDER BY event_date DESC