-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support Authentication in Realtime Subscriptions (#8815)
This PR implements validator directives on subscriptions like `@requireAuth` so one may enabled authentication on a Subscription just like one does for Queries and Mutation in RedwoodJS's GraphQL. It also: * enables any validator directive on Subscriptions (but not transformer ones) * checks that subscriptions have the `@skipAuth` or `@requireAuth` directive (as do queries and mutations) * updates the subscription templates to include `@requireAuth` For authorization (that it is I can Subscribe to newMessage -- authn -- but not listen to changes to room 227 -- authz -- one can do something like where you check for a user and the room and raise if no access rights: ```ts const newMessage = { newMessage: { subscribe: ( _, { roomId }, { pubSub, currentUser, }: { pubSub: NewMessageChannelType; currentUser: Record<string, any> } ) => { if (currentUser?.id === '1234' && roomId === '227') { throw new ForbiddenError('no can do') } logger.debug({ roomId }, 'newMessage subscription') return pubSub.subscribe('newMessage', roomId) }, ... ``` TODO: * docs * docs for directives and how Subscriptions cannot have transformer directives * see maybe if Subs can transformer directives -- otherwise see if need to warn better
- Loading branch information
1 parent
589e87a
commit a471d26
Showing
10 changed files
with
51 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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