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
Add SQL Server permissions documentation to README
Document the minimal SQL Server permissions required to run the library,
covering three scenarios:
- Minimal runtime permissions (pre-installed schema with AutoInstallSchema=false)
- Service Broker permissions for real-time notifications
- Schema installation permissions (AutoInstallSchema=true)
Addresses #11
Agent-Logs-Url: https://github.com/IntelliTect/IntelliTect.AspNetCore.SignalR.SqlServer/sessions/e6792205-855a-410a-858c-2f32e3296108
Co-authored-by: ascott18 <5017521+ascott18@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,54 @@ ALTER DATABASE [DatabaseName] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE
32
32
33
33
You can also set `AutoEnableServiceBroker = true` when configuring in your `Startup.cs`, but this requires that the application have permissions to do so and has the same caveats that there can be no other active database sessions.
34
34
35
+
## SQL Server Permissions
36
+
37
+
By default, the library will automatically create its required schema and tables on startup (`AutoInstallSchema = true`). If you allow this, the SQL login used by your application will need elevated permissions to perform DDL operations. Alternatively, you can pre-install the schema using the [`install.sql`](./src/IntelliTect.AspNetCore.SignalR.SqlServer/Internal/SqlServer/install.sql) script and then configure `AutoInstallSchema = false` to run with minimal permissions.
38
+
39
+
### Minimal Runtime Permissions (Recommended for Production)
40
+
41
+
If you pre-install the database schema and set `AutoInstallSchema = false`, the application only needs the following permissions. Replace `SignalR` with your configured schema name and `YourHubName` with your hub's table name. Repeat for each table index from `0` to `TableCount - 1` (e.g. with the default `TableCount = 1`, you would have `Messages_YourHubName_0` and `Messages_YourHubName_0_Id`):
42
+
43
+
```sql
44
+
-- Permissions on message tables (repeat for each table index from 0 to TableCount - 1):
45
+
GRANTSELECT, INSERT, DELETEON [SignalR].[Messages_YourHubName_0] TO [YourUser];
46
+
GRANTSELECT, UPDATEON [SignalR].[Messages_YourHubName_0_Id] TO [YourUser];
47
+
```
48
+
49
+
If Service Broker is enabled and you want to use it for real-time notifications (instead of falling back to polling), additional permissions are required:
50
+
51
+
```sql
52
+
-- Required for SqlDependency to subscribe to query notifications:
53
+
GRANT SUBSCRIBE QUERY NOTIFICATIONS TO [YourUser];
54
+
55
+
-- Required for SqlDependency to create its temporary Service Broker objects:
56
+
GRANT CREATE PROCEDURE TO [YourUser];
57
+
GRANT CREATE QUEUE TO [YourUser];
58
+
GRANT CREATE SERVICE TO [YourUser];
59
+
GRANTREFERENCESON CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification] TO [YourUser];
60
+
61
+
-- Required for receiving Service Broker error notifications:
62
+
GRANT RECEIVE ON QueryNotificationErrorsQueue TO [YourUser];
63
+
```
64
+
65
+
### Schema Installation Permissions
66
+
67
+
If using the default `AutoInstallSchema = true`, the login needs permissions to create the schema and tables. The simplest but broadest approach is to grant the `db_ddladmin` and `db_datawriter` database roles. For more restricted access, grant only the specific permissions needed:
68
+
69
+
```sql
70
+
GRANT CREATE SCHEMA TO [YourUser];
71
+
GRANT CREATE TABLE TO [YourUser];
72
+
GRANT ALTER ON SCHEMA::[SignalR] TO [YourUser];
73
+
GRANT INSERT ON SCHEMA::[SignalR] TO [YourUser];
74
+
GRANTSELECTON SCHEMA::[SignalR] TO [YourUser];
75
+
```
76
+
77
+
If also using `AutoEnableServiceBroker = true`, the login needs `ALTER` permission on the database:
78
+
79
+
```sql
80
+
GRANT ALTER ON DATABASE::[YourDatabase] TO [YourUser];
81
+
```
82
+
35
83
## Usage
36
84
37
85
1. Install the `IntelliTect.AspNetCore.SignalR.SqlServer` NuGet package.
0 commit comments