Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Applies to: ✅Microsoft Fabric✅Azure Data Explorer✅Azure Monitor✅Microsoft Sentinel
A instrução restrict limita o conjunto de entidades de tabela/exibição que são visíveis para instruções de consulta que a seguem. Por exemplo, em um banco de dados que inclui duas tabelas (A, B), o aplicativo pode impedir que o restante da consulta acesse B e apenas "veja" uma forma limitada de tabela A usando uma exibição.
O cenário principal da instrução restrict é para aplicativos de camada intermediária que aceitam consultas de usuários e desejam aplicar um mecanismo de segurança em nível de linha sobre essas consultas.
The middle-tier application can prefix the user's query with a logical model, a set of let statements to define views that restrict the user's access to data, for example ( T | where UserId == "..."). Como a última instrução sendo adicionada, ela restringe o acesso do usuário apenas ao modelo lógico.
Note
A instrução restrict pode ser usada para restringir o acesso a entidades em outro banco de dados ou cluster (não há suporte para curingas em nomes de cluster).
Syntax
restrict
access
to
(
EntitySpecifiers)
Learn more about syntax conventions.
Parameters
| Name | Tipo | Required | Description |
|---|---|---|---|
| EntitySpecifiers | string |
✔️ | Um ou mais especificadores de entidade separados por vírgula. Os valores possíveis são: - Um identificador definido por uma instrução let como uma exibição tabular - Uma referência de tabela ou função, semelhante a uma usada por uma instrução union - Um padrão definido por uma declaração de padrão |
Note
- Todas as tabelas, exibições tabulares ou padrões que não são especificados pela instrução restrict tornam-se "invisíveis" para o restante da consulta.
- Let, set e tabular statements are strung together/separated by a semicolon, otherwise they are't consider part of the same query.
Examples
Os exemplos nesta seção mostram como usar a sintaxe para ajudá-lo a começar.
The examples in this article use publicly available tables in the help cluster, such as the
StormEventstable in the Samples database.
The examples in this article use publicly available tables, such as the
Weathertable in the Weather analytics sample gallery. Talvez seja necessário modificar o nome da tabela na consulta de exemplo para corresponder à tabela em seu workspace.
Let statement
The example uses a let statement appearing before restrict statement.
// Limit access to 'Test' let statement only
let Test = () { print x=1 };
restrict access to (Test);
Tabelas ou funções
The example uses references to tables or functions that are defined in the database metadata.
// Assuming the database that the query uses has table Table1 and Func1 defined in the metadata,
// and other database 'DB2' has Table2 defined in the metadata
restrict access to (database().Table1, database().Func1, database('DB2').Table2);
Patterns
The example uses wildcard patterns that can match multiples of let statements or tables/functions.
let Test1 = () { print x=1 };
let Test2 = () { print y=1 };
restrict access to (*);
// Now access is restricted to Test1, Test2 and no tables/functions are accessible.
// Assuming the database that the query uses has table Table1 and Func1 defined in the metadata.
// Assuming that database 'DB2' has table Table2 and Func2 defined in the metadata
restrict access to (database().*);
// Now access is restricted to all tables/functions of the current database ('DB2' is not accessible).
// Assuming the database that the query uses has table Table1 and Func1 defined in the metadata.
// Assuming that database 'DB2' has table Table2 and Func2 defined in the metadata
restrict access to (database('DB2').*);
// Now access is restricted to all tables/functions of the database 'DB2'
Impedir que o usuário consulte outros dados do usuário
O exemplo mostra como um aplicativo de camada intermediária pode anexar a consulta de um usuário com um modelo lógico que impede o usuário de consultar os dados de qualquer outro usuário.
// Assume the database has a single table, UserData,
// with a column called UserID and other columns that hold
// per-user private information.
//
// The middle-tier application generates the following statements.
// Note that "username@domain.com" is something the middle-tier application
// derives per-user as it authenticates the user.
let RestrictedData = view () { Data | where UserID == "username@domain.com" };
restrict access to (RestrictedData);
// The rest of the query is something that the user types.
// This part can only reference RestrictedData; attempting to reference Data
// will fail.
RestrictedData | summarize MonthlySalary=sum(Salary) by Year, Month
// Restricting access to Table1 in the current database (database() called without parameters)
restrict access to (database().Table1);
Table1 | count
// Restricting access to Table1 in the current database and Table2 in database 'DB2'
restrict access to (database().Table1, database('DB2').Table2);
union
(Table1),
(database('DB2').Table2))
| count
// Restricting access to Test statement only
let Test = () { range x from 1 to 10 step 1 };
restrict access to (Test);
Test
// Assume that there is a table called Table1, Table2 in the database
let View1 = view () { Table1 | project Column1 };
let View2 = view () { Table2 | project Column1, Column2 };
restrict access to (View1, View2);
// When those statements appear before the command - the next works
let View1 = view () { Table1 | project Column1 };
let View2 = view () { Table2 | project Column1, Column2 };
restrict access to (View1, View2);
View1 | count
// When those statements appear before the command - the next access is not allowed
let View1 = view () { Table1 | project Column1 };
let View2 = view () { Table2 | project Column1, Column2 };
restrict access to (View1, View2);
Table1 | count