Repository navigation
Conversation
Snowflake's temporary role grants preview lets GRANT ROLE ... TO USER carry FOR INTERVAL '<n> <MINUTES|HOURS|DAYS>' or UNTIL '<timestamp>', and reports expires_on in SHOW GRANTS and ACCOUNT_USAGE.GRANTS_TO_USERS. - _RoleGrant gains for_interval (config-only, like UserKeyPair's days_to_expiry, until, and has_expiration; intervals and timestamps are normalized to canonical forms so remote expires_on compares cleanly against config. - create_role_grant renders the clause; update_role_grant re-GRANTs with RESET EXPIRATION so an expiration is set to exactly the desired value, and a plain re-GRANT makes a grant permanent again. - ACCOUNT_USAGE.GRANTS_TO_USERS selects EXPIRES_ON, retrying without it on accounts where the preview column does not exist yet; SHOW GRANTS reads expires_on too. A grant whose expiration already passed is treated as gone, matching the access Snowflake actually gives. - parse_grant understands the new syntax; role_grants YAML accepts for_interval/until (user grants only). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> EOF )
|
@sgoley thanks for this. I reviewed the branch at A few things to tighten:
Smaller items:
|
Summary
Refs #107 — a first-draft implementation of temporary role grants for review.
Adds
for_intervalanduntiltoRoleGrant, covering the Snowflakepreview syntax:
_RoleGrantgainsfor_interval(config-only,fetchable: False— sameprecedent as
UserKeyPair.days_to_expiry),until, and a computedhas_expiration. Intervals and timestamps are normalized to canonicalforms so the remote
expires_oncompares cleanly against config.create_role_grantrendersFOR INTERVAL/UNTIL; the clauses arerejected on role-to-role grants, matching Snowflake's restriction.
update_role_grant(previouslyNotImplementedError) re-GRANTs withRESET EXPIRATIONso the expiration is set to exactly the desired value— required, since re-granting a timed clause onto a permanent grant
leaves it permanent otherwise. A plain re-GRANT (no clause) makes a
temporary grant permanent again.
ACCOUNT_USAGE.GRANTS_TO_USERSselectsEXPIRES_ON, retrying withoutthe column on accounts where the preview column does not exist yet
(
INVALID_COLUMN_ERR/INVALID_IDENTIFIER, the same pair usedelsewhere);
SHOW GRANTSreadsexpires_ontoo. A grant whoseexpiration has already passed is treated as gone.
parse_grantunderstands the new syntax, includingRESET EXPIRATION;role_grants:YAML acceptsfor_interval/untilon user grants.Notable semantics worth review:
untildrifts astime passes) and each apply re-arms the interval — the honest
representation of "lasts N hours from when applied". Documented in the
resource docstring and
docs/resources/role_grant.md.covered — integration tests would need an account on the preview.
Test plan
uv run pytest tests/— 2412 passedblack,ruff,codespell,mypycleanupdate paths (permanent/temporary transitions, reset), parser,
ACCOUNT_USAGE
EXPIRES_ONhandling + column-missing fallbackGenerated with Devin