-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V15: Notification Hub #17776
Open
nikolajlauridsen
wants to merge
29
commits into
v15/dev
Choose a base branch
from
v15/feature/notification-hub
base: v15/dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
V15: Notification Hub #17776
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We don't need it, but seems like a thing that a server event router should be able to do.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Creates a SignalR hub that relays server events to the backoffice frontend.
Terminology
Details
Each event consists of:
These default events are
The events come from a single hub using a single method
notify
. Upon connecting, the user is authorized to receive certain events. This means that users with onlyDocumentTreeAccess
will only see document events, and so on.Additionally, it's also possible to notify a specific user. This still goes through the
notify
method and notifies all the users' connections. It is used to notify a specific user that they've been updated.Events are routed using the "group" concept in SignalR, every event source is its own group. An
IEventSourceAuthorizer
is then used to authorize a user (using a ClaimsPrincipal) for one or more event sources (groups), if a user is approved it's added to the group. This means that an authorizer is required for each event source for the routing to be used. If authorization is not required theIServerEventRouter.BroadcastEventAsync
method can instead be used, this sends the event to all connected users.If a user is updated, the authorization is re-run ensuring that any permission changes are reflected in the event routing.
This means to extend this you must:
IEventSourceAuthorizer
EventSourceAuthorizerCollection
IServerEventRouter.RouteEventAsync
, this can be done from anywhere, but a notification handler is an ideal placeIf you want to authorize using a standard .Net Core policy you can use the
EventSourcePolicyAuthorizer
abstract class, and specify which event sources should be authorized using which policy.Note that the event source authorized by the
IEventSourceAuthorizer
must be the same as the one yourServeEvent
for the event to be routed anywhereExample of adding event authorizer
Testing
YOUR-ACCESS-TOKEN-HERE
with that token in thewwwroot/js/event.js
fileNote: The auth token is short lived, so it may expire