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.
Type of PR (feature, enhancement, bug fix, etc.)
Feature
Description
Introduces a new authentication primative that provides a flexible, unopinionated mechanism to disallow Reflexes from being run when the user does not have permission to do so.
Functionally, it works very similarly to using
throw :abort
in abefore
callback to halt a Reflex. Developers can usethrow :forbidden
and it will halt the Reflex in the same way:abort
does, but instead of triggering ahalted
life-cycle on the client, there is now aforbidden
life-cycle stage, with all corresponding callbacks and events.As with all Reflex types, any
payload
values defined before thethrow
statement are delivered to the client. The developer can optionally use thepayload
to deliver information about why the Reflex was prevented from running.This feature does not make any attempt to decide what constitutes an authentication violation; it is expected that this logic is best handled in plugins or the application itself.
Templates have been updated, and I took the opportunity to further simplify the client-side logging module.
Why should this be added
Action Cable Connections can persist longer than the current user session, which poses significant security complexity to over-the-wire applications. This is especially true given that modern use cases often see users logged in from multiple tabs and multiple devices simultaineously.
It is no longer enough to just refresh the page, as the user could logout on another tab and today, the current tab would continue running Reflexes as the logged out user. This is unacceptable.
I am preparing to release a new gem which will provide easy, Devise-like authentication checking. I would very much like an API surface to plug into to provide this functionality.
Checklist