Skip to content

refactor: smaller cleanup tasks for casl refactor - #2759

Merged
HayenNico merged 5 commits into
masterfrom
refactor-casl-factory-cleanup
Jun 26, 2026
Merged

HayenNico merged 5 commits into
masterfrom
refactor-casl-factory-cleanup

Conversation

@HayenNico

@HayenNico HayenNico commented May 26, 2026 •

Copy link
Copy Markdown
Member

Description

A few smaller changes part of PR #2748. This branch will serve as a base for the individual collection refactors.

Fixes

  • Fix faulty dataset API v4 test 2500-0400 with illegal query filter for count endpoint

Changes:

  • Rename Action.accessAny to Action.AccessAny
  • Sort Subjects in casl-ability-factory.ts, add GenericHistory as a valid term
  • Sort CaslAbilityFactory.endpointAccessors
  • Extract private type definitions in casl-ability.factory.ts into separate module (will enable moving abilities for individual subsystems into separate modules)

Tests included

  • Included for each change/fix?
  • Passing?

Documentation

  • swagger documentation updated (required for API changes)
  • official documentation updated

Summary by Sourcery

Align CASL action naming and subject configuration while cleaning up access control wiring and fixing a dataset count test filter.

Bug Fixes:

  • Correct the datasets v4 count test to use an empty filter when requesting the count endpoint.

Enhancements:

  • Rename the generic CASL access action to a consistently cased enum value and update all usage sites.
  • Include GenericHistory in CASL Subjects and sort both Subjects and endpoint accessor mappings for improved maintainability.

@HayenNico
HayenNico requested a review from a team as a code owner May 26, 2026 15:50

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@HayenNico HayenNico mentioned this pull request May 26, 2026
4 tasks done
@HayenNico HayenNico mentioned this pull request Jun 3, 2026
4 tasks done
@emigun

emigun commented Jun 25, 2026

Copy link
Copy Markdown
Member

LGTM! ⭐

@HayenNico HayenNico mentioned this pull request Jun 26, 2026
4 tasks done
@HayenNico
HayenNico merged commit 883f4b9 into master Jun 26, 2026
15 checks passed
@HayenNico
HayenNico deleted the refactor-casl-factory-cleanup branch June 26, 2026 09:56
nitrosx added a commit that referenced this pull request Aug 7, 2026
## Description
Subsection of PR #2748 for datasets. PR depends on #2759 to be merged
first.

This unifies the datasetEndpointAccess and datasetInstanceAccess
functions in CaslAbilityFactory, removes instance-level Action elements
and adjusts all affected controllers to accommodate the change. The
dataset-specific code is extracted into a separate module

## Fixes

* The endpoints /proposals/:id/datasets and /samples/:id/datasets would
not apply correct filters due to a mismatch between the used casl
ability and checked Action elements

## Changes:

* Replace CaslAbilityFactory.datasetsInstanceAccess and
CaslAbilityFactory.datasetsEndpointAccess with one function
CaslAbilityFactory.datasetAccess
* Code for CaslAbilityFactory.datasetAccess is factored out into new
module DatasetAbility
* Remove all instance-level dataset Action elements
* Adjust endpoint and instance auth logic in dataset controllers
* Remove unused readOwner checks, treat readPublic as always true
(datasets-access.service)
* Adjust auth logic in samples, proposals, users and origdatablocks
controllers where dataset abilities are used

## Tests included

- [x] Included for each change/fix?
- [x] Passing? <!-- Merge will not be approved unless tests pass -->

## Documentation
- [x] swagger documentation updated (required for API changes)
- [x] official documentation updated

### official documentation info
<!-- If you have updated the official documentation, please provide PR #
and URL of the updated pages -->

## Summary by Sourcery

Consolidate dataset authorization into a single CASL ability and align
controllers and access services with the simplified permission model.

Bug Fixes:
- Ensure /proposals/:id/datasets, /samples/:id/datasets, and other
dataset-related endpoints apply correct filters based on unified dataset
permissions for authenticated and unauthenticated users.

Enhancements:
- Replace separate dataset endpoint and instance access factories with a
single datasetAccess ability using unified actions and conditions.
- Simplify dataset-related controllers, V4 controllers, and access
services to rely on generic Dataset* actions instead of
owner/access/public-specific variants.
- Remove numerous instance-level dataset Action enum values in favor of
a smaller, clearer action set, adding AccessAny for elevated roles.
- Treat public dataset reads consistently by defaulting unauthenticated
access to published datasets and tightening v4 behavior to require
public endpoints for anonymous users.
- Update Swagger-guarded policies and related controllers (datasets,
samples, proposals, origdatablocks, users) to use the new datasetAccess
checks.

Tests:
- Adjust dataset controller specs to mock the new datasetAccess factory
method and keep authorization tests passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants