What you will be able to do
- Build an application role hierarchy in the setup script and grant app objects to it
- Declare global privileges such as EXECUTE TASK, CREATE WAREHOUSE and CREATE DATABASE in the manifest, and grant them as a consumer
- Configure IMPORTED PRIVILEGES grants and explain what IMPORTED PRIVILEGES ON SNOWFLAKE DB exposes
- Use references to give an app scoped access to named objects in the consumer account
- Choose between feature policies and app specifications as consumer-side governance controls
- Secure the provider-to-consumer boundary by choosing references, owner's rights or restricted caller's rights, and walk through the privilege-granting workflow end to end
Key concept
The app is the security principal — An installed Native App is a principal in its own right. Consumers grant privileges TO APPLICATION, and by default the app's own executables run with whatever privileges the app holds. Every privilege mechanism in this subdomain controls what that principal can do and who can reach it.
1.Application roles: exposing what the app owns
Inside the consumer account, everything the setup script creates belongs to the app. Consumers reach those objects through application roles. The provider creates the roles in the setup script, nests them into a hierarchy, and grants privileges on app objects to them. Unlike database roles, application roles can also be granted privileges on objects outside the installed app. The role itself, though, must always be created inside the app.
CREATE APPLICATION ROLE admin;
CREATE APPLICATION ROLE user;
GRANT APPLICATION ROLE user TO APPLICATION ROLE admin;
CREATE OR ALTER VERSIONED SCHEMA app_code;
GRANT USAGE ON SCHEMA app_code TO APPLICATION ROLE admin;
GRANT USAGE ON SCHEMA app_code TO APPLICATION ROLE user;At install time, the role that installs the app becomes its owner. Every application role defined in the setup script is automatically granted to that owning role. From there, the app owner can pass the access on to other account roles in the consumer account. So the provider decides the shape of the access (which roles exist and what each one can touch), and the consumer decides which of their people get each role. The framework gives you CREATE, ALTER, DROP, GRANT, REVOKE and SHOW commands for application roles.
Checkpoint 1 of 5· Check yourself
A consumer installs an app using a role called APP_INSTALLER. The setup script defines application roles admin and user. Who holds those application roles immediately after installation?
Application roles from the setup script go automatically to the role that owns the app instance, which is the role that installed it. That owner can then grant them to other account roles.
“Application roles defined in the setup script are automatically granted to the role owning the app instance.”Source: docs.snowflake.com
Sources1
2.Requesting global privileges through the manifest
Application roles cover objects the app owns. Some apps also need to act at the account level, for example creating a warehouse or running tasks. In that case the consumer has to grant the privilege. The provider works out which privileges the app needs and lists them under privileges in the manifest file. The consumer then reviews those requests after installation and grants them.
privileges:
- EXECUTE TASK:
description: "Privilege to run tasks within the consumer account"These are the global privileges a provider can request: BIND SERVICE ENDPOINT, CREATE COMPUTE POOL, CREATE DATABASE, CREATE WAREHOUSE, EXECUTE ALERT, EXECUTE TASK, EXECUTE MANAGED TASK, IMPORTED PRIVILEGES ON SNOWFLAKE DB, MANAGE WAREHOUSES and READ SESSION. The requests travel with the installed app. The consumer lists them with SHOW PRIVILEGES IN APPLICATION hello_snowflake_app; and grants each one with an ordinary GRANT whose grantee is the application, such as GRANT CREATE DATABASE ON ACCOUNT TO APPLICATION hello_snowflake_app;.
IMPORTED PRIVILEGES needs special care. When a consumer grants IMPORTED PRIVILEGES ON SNOWFLAKE DB, the app can see the usage and cost information for the consumer account, so providers should make sure consumers know this before they publish. The same grant syntax gives the app imported privileges on any other database the consumer chooses.
Checkpoint 2 of 5· Fill the gap
Complete the consumer's command that gives the app imported privileges on MYDATABASE.
GRANT IMPORTED PRIVILEGES ON DATABASE MYDATABASE TO ? hello_snowflake_app;The grantee is the app itself, so the clause is TO APPLICATION. Application roles are granted outward to consumers, not used as the target of consumer grants.
Source: docs.snowflake.comSources2
3.References: scoped access to named objects in the consumer account
Global privileges are too broad when an app only needs one particular consumer table. A plain object grant doesn't solve the problem either, because the app cannot determine the name of the schema and object in the consumer account. References solve it. The consumer names the object and binds it to a reference that the provider defined in the manifest. The app gets exactly the privileges the reference lists on that one object, and nothing else in the account.
references:
- consumer_table:
label: "Consumer table"
description: "A table in the consumer account that exists outside the APPLICATION object."
privileges:
- INSERT
- SELECT
object_type: TABLE
multi_valued: false
register_callback: config.register_single_reference| Object type | Privileges allowed |
|---|---|
| TABLE | SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES |
| VIEW | SELECT, REFERENCES |
| WAREHOUSE | MODIFY, MONITOR, USAGE, OPERATE |
| EXTERNAL ACCESS INTEGRATION | USAGE |
| SECRET | USAGE, READ |
Checkpoint 3 of 5· Put it in order
Put the reference workflow in order, from provider development to the app gaining access.
- 1.Provider defines the reference in the manifest file
- 2.Consumer creates the reference by calling SYSTEM$REFERENCE
- 3.Provider adds a callback stored procedure to the setup script
- 4.Consumer runs the callback stored procedure, passing the reference id
- 5.Consumer views the references the installed app requires
The provider defines the reference and its callback. After installing, the consumer views the requests, creates the reference with SYSTEM$REFERENCE and passes its id to the callback. Only then can the app access the object.
“After the consumer runs the callback stored procedure, the Snowflake Native App can access the requested object.”Source: docs.snowflake.com
Secure patterns across the provider and consumer accounts. The provider's code and the consumer's data live in different accounts, so each side controls only its own half of every access path. Pick the mechanism by what the app needs:
- Data or functions the app owns: owner's rights by default. The provider doesn't need to ask the consumer for anything. - Specific tables, views or functions in the consumer account: request references from the consumer. The consumer picks the exact object, so the app never needs to know or guess its name. - Queries that combine consumer and provider data: use references and owner's rights together. - Account-level operations such as creating databases or executing tasks: restricted caller's rights, which the consumer enables explicitly.
References are also a versioning contract. If a later version removes a reference definition that code still uses, consumers get an error when they call that code after upgrading. Snowflake recommends against removing a reference definition from the manifest in a new version. If you must remove one, update the code that uses it in the same release and tell consumers in the README. Across accounts, anything that leaves the consumer account, such as external endpoints or data sharing with other accounts, is not a reference. It goes through app specifications, which the consumer approves or declines.
The privilege-granting workflow. For global privileges, the sequence is fixed. The provider determines the privileges the app needs. The provider adds them to the manifest file. After installing, the consumer reviews the requested privileges and then grants them to the application. References follow the same shape (the provider declares, the consumer reviews and binds), with SYSTEM$REFERENCE and the callback in place of a plain GRANT. Because the app should request only the minimum privileges it needs, and must tell consumers what it requires before asking for grants, treat the manifest as the provider's disclosure and the consumer's review as the approval gate.
SHOW PRIVILEGES IN APPLICATION hello_snowflake_app;4.Consumer-side governance: feature policies and app specifications
With automated granting of privileges, an app can request EXECUTE TASK, EXECUTE MANAGED TASK, CREATE WAREHOUSE, CREATE COMPUTE POOL, BIND SERVICE ENDPOINT, CREATE DATABASE and CREATE EXTERNAL ACCESS INTEGRATION. Once the app is installed, the consumer can't revoke those privileges directly. Consumer administrators can still limit what the app creates, by using feature policies. A feature policy blocks object types, such as warehouses or compute pools, and it can target one app or every app in the account.
ALTER ACCOUNT
SET FEATURE POLICY feature_policy_db.sch.block_create_db_policy
FOR ALL APPLICATIONS;To scope a policy to one app, use CREATE APPLICATION ... WITH FEATURE POLICY or ALTER APPLICATION ... SET FEATURE POLICY. To check what applies, run SHOW FEATURE POLICIES ON APPLICATION. Apply policies carefully: if you block an object type the app needs for installation or upgrade, the app may stop working properly.
Feature policies can't block external access integrations. That kind of outbound access is governed by app specifications. With app specifications, consumers review and approve or decline requests for external endpoint connections, third-party authentication, data sharing with other Snowflake accounts, inter-app connections and restricted operations. Consumers can decline these requests or approve only part of one, so the app has to handle unapproved specifications gracefully. Providers can also register a specification_action lifecycle callback that reacts when a specification is approved or declined.
Checkpoint 4 of 5· Exam question
A provider is designing an application role structure following least-privilege principles for a Native App with distinct viewer, analyst, and administrator personas. Which practices are consistent with sound application role design? (Select all that apply)(Select 3)
Correct answers: A, B, E — Grant only the privileges each role's persona actually needs on the app's own objects, rather than granting broad privileges to every role; Build a hierarchy so the administrator role includes the analyst and viewer capabilities instead of duplicating grants across each role; Document, through role naming and structure, which application role a consumer should grant for a given persona
- A. Scoping each role's grants to only what its persona needs on the app's objects is the core of least-privilege role design and limits the blast radius of any single role.
- B. Nesting broader roles on top of narrower ones avoids duplicating privilege grants and keeps the hierarchy easy to reason about as personas expand.
- C. Application roles are typically granted to the consumer's account roles rather than to individual user accounts, so that access follows the consumer's existing role-based access model.
- D. Giving every role the same privileges collapses the persona distinctions entirely and defeats the purpose of building separate viewer, analyst, and administrator roles.
- E. Clear, descriptive role structure and naming helps consumers correctly map their own personas to the right application role during the granting workflow.
Checkpoint 5 of 5· Check yourself
An app was granted CREATE EXTERNAL ACCESS INTEGRATION through automated granting. The consumer wants to control which external endpoints it can reach. Which control applies?
Feature policies can't block external access integrations, and automatically granted privileges can't be revoked directly. Endpoints are approved or declined through app specifications.
“Instead, consumers can choose to approve or decline the endpoints for an app using app specifications.”Source: docs.snowflake.com
Exam traps
Each one states something that sounds right. Open it to see what is actually true.
1.A consumer who regrets an automatically granted privilege like CREATE WAREHOUSE can simply revoke it from the app.Why is that wrong?
Automatically granted privileges can't be revoked directly after installation. The consumer has to use a feature policy, at app level or for all applications, to block the object type. Blocking something the app needs can break installation or upgrade.
Covered in Consumer-side governance: feature policies and app specifications
2.IMPORTED PRIVILEGES ON SNOWFLAKE DB is a harmless metadata grant that needs no disclosure to consumers.Why is that wrong?
It lets the app see the consumer account's usage and cost information, and providers should make sure consumers know this.
Covered in Requesting global privileges through the manifest
3.A provider can safely drop an unused-looking reference definition from the manifest in a new version.Why is that wrong?
Code that still uses the removed reference fails for consumers after they upgrade. Update the dependent code in the same release and notify consumers.
Covered in References: scoped access to named objects in the consumer account
Sources
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“However, the application role itself must be created within the app.”
↩︎ Application roles: exposing what the app owns“However, the app owner can grant privileges to other account roles in the consumer account.”
↩︎ Application roles: exposing what the app owns“Application roles defined in the setup script are automatically granted to the role owning the app instance.”
↩︎ Checkpoint - 2.
“the consumer must grant the privileges to allow the application to do so.”
↩︎ Requesting global privileges through the manifest“When a provider specifies a privilege in the manifest file, the privilege requests are included as part of the installed Snowflake Native App.”
↩︎ Requesting global privileges through the manifest“Add the required privileges to the manifest file.”
↩︎ References: scoped access to named objects in the consumer account“Grant the global privileges on the application.”
↩︎ References: scoped access to named objects in the consumer account“Granting IMPORTED PRIVILEGES ON SNOWFLAKE DB allows the Snowflake Native App to see information about usage and costs associated with the consumer account.”
↩︎ Exam trap 2 - 3.
“the app cannot determine the name of the schema and object in the consumer account.”
↩︎ References: scoped access to named objects in the consumer account“Create the reference by calling the SYSTEM$REFERENCE system function.”
↩︎ References: scoped access to named objects in the consumer account“Snowflake recommends against removing a reference definition from the manifest file in a new version of an app.”
↩︎ References: scoped access to named objects in the consumer account“Snowflake recommends against removing a reference definition from the manifest file in a new version of an app.”
↩︎ Exam trap 3“After the consumer runs the callback stored procedure, the Snowflake Native App can access the requested object.”
↩︎ Checkpoint - 4.
“Queries that access a combination of consumer and provider data | Use references and owner’s rights together”
↩︎ References: scoped access to named objects in the consumer account“they run with the privileges granted to the owner of the executable, which is the app itself.”
↩︎ Key concept - 5.
“Apps must only request the minimum set of privileges possible.”
↩︎ References: scoped access to named objects in the consumer account - 6.
“consumer administrators can use feature policies to limit the objects an app can create in the consumer account.”
↩︎ Consumer-side governance: feature policies and app specifications“Blocking object types that an app requires for installation or upgrade may prevent the app from functioning properly.”
↩︎ Consumer-side governance: feature policies and app specifications“a consumer cannot directly revoke these privileges after the app is installed.”
↩︎ Exam trap 1“Instead, consumers can choose to approve or decline the endpoints for an app using app specifications.”
↩︎ Checkpoint - 7.
“When developing an app, you must account for situations where app specifications might not be approved.”
↩︎ Consumer-side governance: feature policies and app specifications