Skip to content

Commit d4ccec8

Browse files
committed
move down
1 parent 9c342d3 commit d4ccec8

1 file changed

Lines changed: 55 additions & 55 deletions

File tree

README.md

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -32,61 +32,6 @@ ALTER DATABASE [DatabaseName] SET ENABLE_BROKER WITH ROLLBACK IMMEDIATE
3232

3333
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.
3434

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-
GRANT SELECT, INSERT, DELETE ON [SignalR].[Messages_YourHubName_0] TO [YourUser];
46-
GRANT SELECT, UPDATE ON [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), the `SqlDependency` mechanism requires additional permissions to create and manage its temporary Service Broker objects. The simplest approach is to grant the `db_owner` role:
50-
51-
``` sql
52-
EXEC sp_addrolemember 'db_owner', 'YourUser';
53-
```
54-
55-
If `db_owner` is too broad, the following individual permissions are required at a minimum, though `SqlDependency` may still require `db_owner` in some environments:
56-
57-
``` sql
58-
-- Required for SqlDependency to subscribe to query notifications:
59-
GRANT SUBSCRIBE QUERY NOTIFICATIONS TO [YourUser];
60-
61-
-- Required for SqlDependency to create and manage its temporary Service Broker objects in the dbo schema:
62-
GRANT CREATE PROCEDURE TO [YourUser];
63-
GRANT CREATE QUEUE TO [YourUser];
64-
GRANT CREATE SERVICE TO [YourUser];
65-
GRANT CONTROL ON SCHEMA::dbo TO [YourUser];
66-
GRANT REFERENCES ON CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification] TO [YourUser];
67-
68-
-- Required for receiving Service Broker error notifications:
69-
GRANT RECEIVE ON QueryNotificationErrorsQueue TO [YourUser];
70-
```
71-
72-
### Schema Installation Permissions
73-
74-
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:
75-
76-
``` sql
77-
GRANT CREATE SCHEMA TO [YourUser];
78-
GRANT CREATE TABLE TO [YourUser];
79-
GRANT ALTER ON SCHEMA::[SignalR] TO [YourUser];
80-
GRANT INSERT ON SCHEMA::[SignalR] TO [YourUser];
81-
GRANT SELECT ON SCHEMA::[SignalR] TO [YourUser];
82-
```
83-
84-
If also using `AutoEnableServiceBroker = true`, the login needs `ALTER` permission on the database:
85-
86-
``` sql
87-
GRANT ALTER ON DATABASE::[YourDatabase] TO [YourUser];
88-
```
89-
9035
## Usage
9136

9237
1. Install the `IntelliTect.AspNetCore.SignalR.SqlServer` NuGet package.
@@ -212,6 +157,61 @@ The results of some ad-hoc performance testing yielded that you can expect about
212157

213158
Do note that a broadcast message is considered a single message. Any call to `SendAsync` within a hub is a single message.
214159

160+
## SQL Server Permissions
161+
162+
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.
163+
164+
### Minimal Runtime Permissions (Recommended for Production)
165+
166+
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`):
167+
168+
``` sql
169+
-- Permissions on message tables (repeat for each table index from 0 to TableCount - 1):
170+
GRANT SELECT, INSERT, DELETE ON [SignalR].[Messages_YourHubName_0] TO [YourUser];
171+
GRANT SELECT, UPDATE ON [SignalR].[Messages_YourHubName_0_Id] TO [YourUser];
172+
```
173+
174+
If Service Broker is enabled and you want to use it for real-time notifications (instead of falling back to polling), the `SqlDependency` mechanism requires additional permissions to create and manage its temporary Service Broker objects. The simplest approach is to grant the `db_owner` role:
175+
176+
``` sql
177+
EXEC sp_addrolemember 'db_owner', 'YourUser';
178+
```
179+
180+
If `db_owner` is too broad, the following individual permissions are required at a minimum, though `SqlDependency` may still require `db_owner` in some environments:
181+
182+
``` sql
183+
-- Required for SqlDependency to subscribe to query notifications:
184+
GRANT SUBSCRIBE QUERY NOTIFICATIONS TO [YourUser];
185+
186+
-- Required for SqlDependency to create and manage its temporary Service Broker objects in the dbo schema:
187+
GRANT CREATE PROCEDURE TO [YourUser];
188+
GRANT CREATE QUEUE TO [YourUser];
189+
GRANT CREATE SERVICE TO [YourUser];
190+
GRANT CONTROL ON SCHEMA::dbo TO [YourUser];
191+
GRANT REFERENCES ON CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification] TO [YourUser];
192+
193+
-- Required for receiving Service Broker error notifications:
194+
GRANT RECEIVE ON QueryNotificationErrorsQueue TO [YourUser];
195+
```
196+
197+
### Schema Installation Permissions
198+
199+
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:
200+
201+
``` sql
202+
GRANT CREATE SCHEMA TO [YourUser];
203+
GRANT CREATE TABLE TO [YourUser];
204+
GRANT ALTER ON SCHEMA::[SignalR] TO [YourUser];
205+
GRANT INSERT ON SCHEMA::[SignalR] TO [YourUser];
206+
GRANT SELECT ON SCHEMA::[SignalR] TO [YourUser];
207+
```
208+
209+
If also using `AutoEnableServiceBroker = true`, the login needs `ALTER` permission on the database:
210+
211+
``` sql
212+
GRANT ALTER ON DATABASE::[YourDatabase] TO [YourUser];
213+
```
214+
215215
## License
216216

217217
[Apache 2.0](./LICENSE.txt).

0 commit comments

Comments
 (0)