Skip to content

nhi: sync programmatic access tokens as STATIC_SECRET resources (Phase-1 class-B)#126

Open
c1-squire-dev[bot] wants to merge 2 commits into
mainfrom
pquerna/IGA-1922/nhi-sync-programmatic-access-tokens
Open

nhi: sync programmatic access tokens as STATIC_SECRET resources (Phase-1 class-B)#126
c1-squire-dev[bot] wants to merge 2 commits into
mainfrom
pquerna/IGA-1922/nhi-sync-programmatic-access-tokens

Conversation

@c1-squire-dev

@c1-squire-dev c1-squire-dev Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🔗 Preview: C1

Summary

Implements the class-B follow-on from the snowbricks grounding report: sync Snowflake Programmatic Access Tokens (PATs) as programmatic_access_token resources (TRAIT_SECRET, CREDENTIAL_TYPE_STATIC_SECRET).

  • Enumeration path: per-user fan-out via SHOW USER PROGRAMMATIC ACCESS TOKENS FOR USER "<name>" over the already-synced user list (same Statements API path as SHOW SECRETS / DESCRIBE USER). [[D-318] ref: https://docs.snowflake.com/en/sql-reference/sql/show-user-programmatic-access-tokens]
  • Account-wide alternative: SNOWFLAKE.ACCOUNT_USAGE.CREDENTIALS view also contains PATs account-wide [[D-318] ref: https://docs.snowflake.com/en/sql-reference/account-usage/credentials] but has up to 2-hour latency; per-user fan-out preferred for freshness.
  • Token value: never returned by Snowflake (confirmed in docs). Only metadata is enumerable.

What's new

File Change
pkg/snowflake/pat.go ProgrammaticAccessToken struct + ListProgrammaticAccessTokens client method
pkg/connector/pat.go patBuilder — per-user fan-out syncer following the rsa.go exemplar
pkg/connector/pat_test.go Unit tests for resource building, nil/wrong-parent guard
pkg/connector/resource_types.go New programmatic_access_token resource type
pkg/connector/connector.go Register newPATBuilder inside the SyncSecrets gate (mirrors #124 pattern)
pkg/connector/users.go Add ChildResourceType annotation for programmatic_access_token when syncSecrets

Pattern reference

Follows the rsa.go/secrets.go exemplars from #124:

  • TRAIT_SECRET + CREDENTIAL_TYPE_STATIC_SECRET per RFC §2.3 (PAT = opaque bearer token, same class as Databricks PAT)
  • WithSecretDetail("snowflake.pat") per §2.8 convention
  • WithSecretIdentityID(userResourceID) back-ref to the owning user
  • WithSecretCreatedAt / WithSecretExpiresAt where non-zero
  • No V1Identifier set (precedent baton-temporalcloud#82 r3380796810)
  • Gated behind --sync-secrets flag
  • Emits positively or not at all; UNSPECIFIED on unknown/absent values

Privileges required

The connector role must hold MODIFY on each user object (or USERADMIN / SECURITYADMIN which satisfy this transitively). A 422 Unprocessable Entity response is silently skipped per the existing rsa.go pattern.

Test plan

  • go vet ./pkg/... — clean
  • go test ./pkg/... — all tests pass (5 new, existing suite unchanged)
  • go build ./... — clean

Built with pqprime (bd pqprime-16u) · NHI Phase-1 class-B Snowflake PAT syncer


Exposed endpoints

🏰 Squire environment: silver-quail-73054
Task: 51f1fd08-2c0b-4c22-92cc-b60ed69f18eb

Add programmatic_access_token resource type (TRAIT_SECRET,
CREDENTIAL_TYPE_STATIC_SECRET, detail "snowflake.pat") synced per user
via SHOW USER PROGRAMMATIC ACCESS TOKENS FOR USER.

Enumeration path: per-user fan-out over already-synced users calling
SHOW USER PROGRAMMATIC ACCESS TOKENS FOR USER <name> through the
Statements API (same mechanism as SHOW SECRETS / DESCRIBE USER).
The token value is never returned by Snowflake — only metadata.

Gated behind the existing --sync-secrets flag, consistent with
rsa_public_key and secret (#124). Users gain a second ChildResourceType
annotation for programmatic_access_token when SyncSecrets is true.

Doc refs (D-318):
- https://docs.snowflake.com/en/sql-reference/sql/show-user-programmatic-access-tokens
- https://docs.snowflake.com/en/sql-reference/account-usage/credentials

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
@c1-squire-dev
c1-squire-dev Bot requested a review from a team June 10, 2026 17:51
@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown

IGA-1922

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Connector PR Review: nhi: sync programmatic access tokens as STATIC_SECRET resources (Phase-1 class-B)

Blocking Issues: 0 | Suggestions: 0 | Threads Resolved: 0
Review mode: incremental since 3431f75
View review run

Review Summary

The new commits regenerate baton_capabilities.json and add the Programmatic Access Tokens row to docs/connector.mdx, addressing the previous review finding about missing documentation for the new resource type. No new issues found in the incremental changes, and a full-diff security and correctness scan of the PAT syncer implementation confirms it follows established patterns (SQL identifier escaping, nil-safe response cleanup, graceful 422 handling, proper parent type validation).

Security Issues

None found.

Correctness Issues

None found.

Suggestions

None.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

…es table

New programmatic_access_token resource type (TRAIT_SECRET, CAPABILITY_SYNC)
added in the NHI commit now appears in capabilities output. Commit the
regenerated artifact and add a matching row to the connector docs table.

Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant