Data platformStacks integrationDatabricks03 — Identity & run_as

03 — Identity & run_as

Runtime biết ai đang chạy code gì bằng header/context/token nào, và run_as được handle ở đâu.

Câu hỏi

Databricks Runtime biết ai đang chạy code bằng cách nào?

Và với run_as, runtime authorize theo người bấm nút, owner cluster, service principal, hay một principal context đã được control plane đóng gói?

Vì sao câu này quan trọng

Trong open-source stack, identity rất dễ bị rơi mất qua từng hop:

User login UI
  -> service account gọi engine
  -> engine dùng cluster credential
  -> storage thấy IAM role chung

Nếu runtime không giữ được principal đúng, authZ/audit/lineage đều mơ hồ. Với interactive notebook còn khó hơn vì command chạy nhiều lần, async, có thể qua job/scheduler/run_as.

Breakdown

1. Identity đi từ control plane xuống data plane bằng gì?

Cần trả lời:

  • Header nào mang user/workspace/account/metastore context?
  • UserContext.fromHeaders đọc gì?
  • Driver tự xác thực user hay trust proxy/control plane?
  • Boundary nào là trust boundary thật?

2. Làm sao biết ai đang chạy code gì?

Cần trả lời:

  • Command context chứa user id, notebook id, command id, cluster id không?
  • Query history có nối query với user/principal không?
  • Structured logs có đủ request/command/user correlation không?
  • current_user() lấy từ đâu?

3. run_as được handle ra sao?

Cần trả lời:

  • Driver có impersonate user giữa chừng không?
  • Cluster/job được provision dưới principal nào?
  • authorizingPrincipal khác authenticatingPrincipal thế nào?
  • Principal context snapshot token dùng khi nào?
  • Token đó giới hạn audience tới UC/lineage/login thế nào?

Evidence trong snapshot

  • Reverse docs:
    • /Users/chimeyrock/ChimeyRock/databricks/reverse/docs/16-authn-danh-tinh.md
    • /Users/chimeyrock/ChimeyRock/databricks/reverse/docs/21-run-as-va-principal-context.md
  • Artifact/class/proto:
    • com.databricks.UserContext
    • UserContext.fromHeaders
    • requiredHeaderKeys
    • CommandContext
    • CommandContextPy4JWhitelist
    • InlineUserInfoExpressions
    • PrincipalContext
    • authorizingPrincipal
    • authenticatingPrincipal
    • AuthenticationMethod.API_PCTX_SNAPSHOT_TOKEN
    • AuthenticationMethod.API_PCTX_DP_AUTH_TOKEN
    • TokenAuthorizationDestination
    • clusterUsageTags.* trong common/conf/deploy.conf

Câu trả lời tạm thời

Driver không phải nơi tự quyết identity. Identity được control plane/proxy xác thực rồi truyền xuống data plane qua header/context/token. Với run_as, Databricks tách principal dùng để authorize khỏi actor thật sự authenticate. Data plane nhận PrincipalContext hoặc snapshot token đã đóng gói, rồi dùng context đó cho UC/API/storage decisions.

Còn thiếu / cần verify

  • Snapshot hiện là interactive single-user, không phải job cluster có run_as khác owner.
  • Cần một log/job snapshot khác để thấy API_PCTX_SNAPSHOT_TOKEN trong runtime event thật.
  • Cần nối query history với principal cụ thể bằng output log/proto, không chỉ class names.

On this page