- Allow all (read and write) - allow anyone to read data and/or call collection functions
-
Delegation (read and write) - using
@read,@calland@delegatedirectives - Code (write only) - write code to check users permissions in collection functions
- Encryption (read only) - data is public but encrypted, only authorized users can decrypt it
For read rules, the entire record is always returned. There is no way to define read rules for specific fields.
If you need to have some restricted data, create a separate collection and create a link between the collections.
Allow all
If you want to allow anyone to read data and/or call contract data, you can add one of the following directives at the top of your collection:@public- everyone can read and call any function@read- everyone can read@call- everyone can call any function
@public on collections
Allows anyone to read all records and call functions in the collection (it's the equivalent of adding @read and @call).
You can still further restrict write permissions by adding custom code to your collections functions.
@read on collections
Allows anyone to read all records in the collection (but calls to functions are still restricted).
@call on collections
Allows anyone to call functions that do not have a @call directive.
Delegation
Delegation allows you to create rules across multiple records, allowing for complex permissions to be defined.Delegation rules must always end in a PublicKey field. You must
authenticate the user with using a
signer function in order to use delegation.@read, @call and @delegate directives to control who can read, call and delegate data.
@read on fields
Allows anyone who can sign using the specified public key to read the record.
@call on functions
Allows anyone who can sign using the specified public key to call a given function.
@delegate + @read
Example of delegating read access to Response to a user with given publicKey:
Response → Form → User → publicKey:
@delegate + @call
Example of delegating call permission to Response to a user with given publicKey:
Response → Form → User → publicKey:
Code
If you need more granular control over who can write data and call functions in Polybase, you can allow anyone to call the collection functions, but then write code to check the user’s permissions in the collection functions.This can only be used to control call/write access to Polybase, not read access.
Encryption
You can make your data public (using the@public directive) but encrypted. This means that anyone can read the data, but only authorized
users can decrypt it.
For more information on encrypting data, see the Encryption guide.