Repository navigation
Releases: coorasse/cancancan
Releases · coorasse/cancancan
Release list
3.7.0
The one below is a list of all the PRs merged. For a more detailed update, read the blog post about this release.
- Merge the
ControllerResourceLoader,ControllerResourceBuilder,ControllerResourceFinder,ControllerResourceNameFinderandControllerResourceSanitizermodules intoCanCan::ControllerResource, and call the params method of the controller only once per request: it was called once more for every attribute set by the conditions of the ability. WARNING: the five modules no longer exist; override their methods in a subclass ofCanCan::ControllerResourceinstead. (@coorasse) - Expand the actions again after
alias_action,clear_aliased_actionsandmerge:can?kept using the aliases expanded by a previous check, soclear_aliased_actionsdid not removecan :readfromcan?(:index, Model). (@coorasse) - Raise an error when an action is aliased to
:manage, which granted every action, or to itself, which looped forever. (@coorasse) - Do not include the primary key in
permitted_attributesfor a rule without attributes, remove every attribute with acannotrule without attributes, including those that are not columns, and accept a hash subject instead of raising aTypeError. WARNING:permitted_attributesno longer returns:id, and with a composite primary key none of its columns are returned. (@coorasse) - Convert a String resource name to a symbol in
load_and_authorize_resourceand theskip_*methods:load_and_authorize_resource 'article'treated the resource as a parent and authorized:showon the class instead of the action on the record. (@coorasse) - #927: Look up the unauthorized message of a String action through its aliases:
authorize!('index', post)did not use the message defined forread. (@coorasse) - #913: Match a symbol in a condition with the string that has the same name in
can?, asaccessible_byalready did:cannot :read, Post, state: :drafton a string column no longer allowscan?(:read, draft). WARNING: acanrule with a symbol now also allows records whose string attribute has the same name. (@bruno-costanzo) - #905: Match String actions like Symbol actions:
can?('destroy', user)ignoredcannot :destroy, Userwhencan :managewas defined, andskip_authorize_resource except: 'destroy'also skipped the authorization ofdestroy. WARNING: a String action now goes through the aliases like a Symbol action, socan?('show', order)andauthorize!(action_name, order)are allowed bycan :read, Orderand may grant access that 3.6 denied. A rule defined with a String action now matches the same Symbol action,permissionsreturns symbols, and a block rule without a subject receives the action as a symbol. (@bruno-costanzo) - #848: Do not deny
can?(:index, parent => Model)because of acannotrule with conditions on the model, ascan?(:index, Model)already did:load_and_authorize_resourcefailed on theindexof a nested resource. (@coorasse) - #861, #846, #690: Give the conditions of
accessible_bythe table aliases that Active Record gives to the joined associations, and build them with the model of each table. A rule with ahas_many :throughassociation, or with an association without conditions, used the alias of another table: the query failed or returned the wrong records. On an aliased table, a model was not converted to its foreign key and the values were not cast with the attribute types of the model. (@coorasse) - #911: Load the resource when the id is only whitespace: a request like
/books/%20ran the action with anilresource, authorized only against the class, instead of raisingActiveRecord::RecordNotFound. (@bruno-costanzo) - #833: Match
nilin an array of enum values incan?, asaccessible_byalready did:can :read, Post, status: [nil, :published]now allows a post without a status. (@jtagle2, @coorasse) - #910: Accept a subclass of
CanCan::ModelAdapters::Strategies::Baseasaccessible_by_strategy, so the SQL generated byaccessible_bycan be customized with your own strategy. (@cb341, @coorasse) - #909: Make
can?andaccessible_byconsistent forcannotrules and single table inheritance: acannotrule on a subclass keeps its precedence inaccessible_by, records with NULL in a column of acannotcondition are no longer excluded, rules on subclasses of subclasses reach the base class, and a class check passes when the class or any of its subclasses is allowed. WARNING:accessible_byreturns more records when acannotrule has conditions on a nullable column, andcan?on an STI base class no longer fails because a subclass is forbidden. (@coorasse, @0llirocks, @kevinluo201) - #880: Fix
accessible_bywith rules on STI subclasses: a rule on a subclass without conditions no longer discards the rules defined before it, and rules with the same conditions on different subjects are no longer compressed into one. (@takayamaki, @sjoulbak) - #890: Support an Active Record relation as the value of a condition in
can?: the selected column, or the primary key, is checked with a query, asaccessible_byalready did. (@olistik) - #908: Join consecutive
canrules in a flat chain of ORs in the SQL conditions, so that many rules on the same model no longer overflow the parser of SQLite. (@coorasse) - #907: Make
with_accessible_by_strategythread safe: the strategy chosen in the block no longer leaks into concurrent requests. (@NikosVlagoidis, @coorasse) - #906: Keep the conditions of an association when a rule is a scope:
group.posts.accessible_by(ability)returned the posts of every group matched by the scope. WARNING:accessible_bycalled on an association now returns fewer records when the scope of a rule constrains the same column as the association. Only the conditions dropped bymergeare applied again, so a condition on a subquery likewhere(category: Category.where(...))is not turned intoIS NULL, and the conditions of a default scope removed byunscopein the rule stay removed. (@coorasse) - #694: Document that
cannotsupports the:allsubject. (@jaredbeck) - #852: Add
changelog_urito the gemspec, so rubygems.org links to the changelog. (@mark-young-atg) - #842: Add
disallowed_attributesto retrieve the attributes forbidden bycannotrules. (@mswiszcz) - #904: Assign the parent of a singleton resource through the inverse of the association when the resource has no setter named after the
throughoption. (@coorasse) - #878: Support
through_associationtogether withsingletonwhen loading a resource. (@cgunther) - #786: Fix the table aliases generated by
accessible_bywhen the same association is joined more than twice: the WHERE clause referenced an alias that was never joined. (@daveallie) - #902: Do not change the rules of the ability in
accessible_by: a rule shared by several models kept the conditions normalized for the first queried model. (@bruno-costanzo) - #901: Keep the scope of a
has_many :throughassociation inaccessible_by: the association was rewritten into its through and source associations and its scope was dropped, soaccessible_byreturned records thatcan?denies. WARNING:accessible_byreturns fewer records for a rule on ahas_many :throughassociation with a scope. (@bruno-costanzo) - Remove the VitePress documentation website: the documentation lives in the
docsfolder as plain...
3.6.2
- #898: Do not share
cancan_skipperbetween controller subclasses:skip_authorize_resourceandskip_load_resourcein a subclass no longer apply to the superclass or sibling controllers. (@bruno-costanzo) - #894: Use
lease_connectioninstead of the deprecatedconnectionon Rails 7.2+. (@benaitcheson)
3.6.1
3.5.0
3.4.0
3.3.0
3.2.0
3.1.0
3.0.0
2.0.0
Check the CHANGELOG for the list of changes: https://github.com/CanCanCommunity/cancancan/blob/develop/CHANGELOG.rdoc