You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: serverless/sql-databases/how-to/use-row-level-security.mdx
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ This requires setting up different [IAM permissions sets](/identity-and-access-m
48
48
CREATE POLICY pets_keeper ON pets TO role_readwrite USING (keeper =current_user);
49
49
```
50
50
51
-
5. (Optional) Check that you can see all the data with your current connection:
51
+
5. (Optional) Run the command below to check that you can see all the data with your current connection:
52
52
```sql
53
53
SELECT*FROM pets;
54
54
```
@@ -63,27 +63,30 @@ This requires setting up different [IAM permissions sets](/identity-and-access-m
63
63
64
64
## Create an IAM application with Row Level Security enabled
65
65
66
-
1. Create a new [IAM application](https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-application/) or use an existing one.
66
+
1. Create a new [IAM application](/identity-and-access-management/iam/how-to/create-application/) or use an existing one.
67
67
68
-
2.Add **ServerlessSQLDatabaseDataReadWrite** permission set to this application by creating a new [IAM policy](https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-policy/)
68
+
2.Create a new [IAM policy](/identity-and-access-management/iam/how-to/create-policy/), and add the **ServerlessSQLDatabaseDataReadWrite** permission set to the application you just created.
69
69
70
-
<Messagetype="tip">
71
-
You need to provide **ServerlessSQLDatabaseDataReadWrite** permission set and not **ServerlessSQLDatabaseReadWrite** permission set. Indeed, all connections to your database performed with **ServerlessSQLDatabaseDataReadWrite**permissions will use `role_readwrite` in PostgreSQL, whereas all connections performed with **ServerlessSQLDatabaseReadWrite** or **ServerlessSQLDatabaseFullAccess** will use `role_admin` in PostgreSQL.
70
+
<Messagetype="note">
71
+
You must provide **ServerlessSQLDatabaseDataReadWrite** permission set and not **ServerlessSQLDatabaseReadWrite** permission set. Indeed, all connections to your database performed with the former permissions set will use `role_readwrite` in PostgreSQL, whereas all connections performed with the latter or **ServerlessSQLDatabaseFullAccess** will use `role_admin` in PostgreSQL.
72
72
</Message>
73
73
74
-
3. Create an [API Key](https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/) for this application and connect to your Serverless SQL Database with this application.
74
+
3. Create an [API Key](/identity-and-access-management/iam/how-to/create-api-keys/) for this application and connect to your Serverless SQL Database with this application.
4.List the `pets` this application has access to with:
79
+
4.Run the follwoing command to list the `pets` this application has access to with:
80
80
```sql
81
81
SELECT*FROM pets;
82
82
```
83
-
You should only see pets with a `keeper` column value of `role_readwrite`.
83
+
Only the pets with a `keeper` column value of `role_readwrite`.
84
84
85
85
Your new application can now only access a specific subset of rows based on its permissions.
86
86
87
87
<Messagetype="tip">
88
-
Note that row level security and policies can be created or deleted by a table owner. In this example, you can check table owner with the following command `select * from pg_tables where tablename = 'pets';`.
88
+
Row level security and policies can be created or deleted by a table owner. In this example, you can check table owner with the following command:
0 commit comments