Skip to content
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

Rules logic and cloud events standard #168

Merged
merged 40 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f6e7819
First draft for cloud event
rubenvdlinde Jan 9, 2025
5e6fe2f
Add the listener
rubenvdlinde Jan 9, 2025
be5d333
Add rules to open connector
rubenvdlinde Jan 11, 2025
d754763
Setting the frontend code
rubenvdlinde Jan 11, 2025
2e0fabd
More frontend work
rubenvdlinde Jan 11, 2025
7dbcef9
First bit of testing on rules
rubenvdlinde Jan 12, 2025
9f448e5
Basic frontend crud testing
rubenvdlinde Jan 12, 2025
30d4364
Lets try to add dropdowns
rubenvdlinde Jan 12, 2025
60405f9
Console error fix
rubenvdlinde Jan 12, 2025
ee597f3
Fixes from testing
rubenvdlinde Jan 12, 2025
9aaae36
Still getting the model to behave
rubenvdlinde Jan 12, 2025
f4c47ce
Last modal fixes
rubenvdlinde Jan 12, 2025
75e31a2
Merge remote-tracking branch 'origin/development' into feature/CONNEC…
rubenvdlinde Jan 12, 2025
d74bd96
Fixing the endpoint object
rubenvdlinde Jan 12, 2025
9c2d2d6
Add the tabs
rubenvdlinde Jan 12, 2025
21d1829
Add rule dialog
rubenvdlinde Jan 12, 2025
367eb1d
Fixed adding rules to endpoints
rubenvdlinde Jan 12, 2025
3f49014
Small fixed
rubenvdlinde Jan 12, 2025
76edc2b
Docs
rubenvdlinde Jan 12, 2025
58e72d8
Update the rules logic in the endpoint service
rubenvdlinde Jan 12, 2025
d682110
Let round up the rules logic
rubenvdlinde Jan 12, 2025
4f1c11e
add authentication and dowloads to ui en documentation
rubenvdlinde Jan 13, 2025
2da4454
Add upload and locking frontend
rubenvdlinde Jan 13, 2025
2ddd88e
PR review changes, incl. import&export fixes
WilcoLouwerse Jan 13, 2025
85b2975
Forgot to add findByRef for EventSubscriptionMapper & RuleMapper
WilcoLouwerse Jan 13, 2025
a220d22
Update list of objects that are not allowed to be imported/exported
WilcoLouwerse Jan 13, 2025
d0dcc21
Code style & docblock changes
WilcoLouwerse Jan 13, 2025
8e5861e
lint-fix
SudoThijn Jan 13, 2025
a2f33a8
Fix routes
WilcoLouwerse Jan 13, 2025
50d7baa
added my own requested changes
SudoThijn Jan 13, 2025
b91eafc
Merge remote-tracking branch 'origin/feature/CONNECTOR-52/cloud-event…
SudoThijn Jan 13, 2025
397212e
Some more route fixes
WilcoLouwerse Jan 13, 2025
fd71392
Merge remote-tracking branch 'origin/feature/CONNECTOR-52/cloud-event…
WilcoLouwerse Jan 13, 2025
43d304e
Update docblocks
WilcoLouwerse Jan 14, 2025
a00195a
Merge branch 'development' into feature/CONNECTOR-52/cloud-events
WilcoLouwerse Jan 14, 2025
6a12582
Small fix for checking rule method
WilcoLouwerse Jan 14, 2025
9c16b7d
Fixes for dealing with empty responces
rubenvdlinde Jan 14, 2025
7d21c04
Fix for getting objects from the root of a responce
rubenvdlinde Jan 14, 2025
c425180
Update documentation
rubenvdlinde Jan 14, 2025
31957a6
LInting fixes
rubenvdlinde Jan 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'Jobs' => ['url' => 'api/jobs'],
'Synchronizations' => ['url' => 'api/synchronizations'],
'Consumers' => ['url' => 'api/consumers'],
'Rules' => ['url' => 'api/rules'],
WilcoLouwerse marked this conversation as resolved.
Show resolved Hide resolved
],
'routes' => [
['name' => 'dashboard#page', 'url' => '/', 'verb' => 'GET'],
Expand Down
42 changes: 37 additions & 5 deletions docs/cloudevents.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,44 @@

We facilitate subscriptions on a pub/sub model. This is based on [CloudEvents](https://cloudevents.io/) but also supports the [NL GOV profile for CloudEvents](https://www.logius.nl/domeinen/gegevensuitwisseling/nl-gov-profile-cloudevents). More documentation can be found [here](https://gitdocumentatie.logius.nl/publicatie/notificatieservices/CloudEvents-NL/).

## Subsribers
# Event System

## Publishers
## Event Subscriptions

## Endpoints
The OpenConnector platform implements the [CloudEvents Subscription API specification](https://github.com/cloudevents/spec/blob/main/subscriptions/spec.md) to manage event subscriptions. This allows consumers to subscribe to specific events and receive them through various delivery mechanisms.

## Mappings
### Subscription Styles

## Events
The platform supports two subscription styles:

- **Push**: Events are actively sent to the subscriber's endpoint (sink)
- **Pull**: Subscribers fetch events from the platform

### Subscription Properties

Each subscription contains the following properties:

- `id`: Unique identifier for the subscription
- `source`: URI identifying where events originate
- `types`: Array of CloudEvent type values to subscribe to
- `config`: Subscription-specific configuration
- `filters`: Array of filter expressions for event matching
- `sink`: URI where events should be delivered
- `protocol`: Delivery protocol (HTTP, MQTT, AMQP, etc.)
- `protocolSettings`: Protocol-specific settings
- `style`: Delivery style ('push' or 'pull')
- `status`: Subscription status
- `userId`: Owner of the subscription

### Filter Dialects

The platform supports the following filter dialects as defined in the CloudEvents specification:

- `exact`: Exact matching of attribute values
- `prefix`: Prefix matching of attribute values
- `suffix`: Suffix matching of attribute values
- `all`: Logical AND of multiple filters
- `any`: Logical OR of multiple filters
- `not`: Logical NOT of a filter

### Example Subscription
100 changes: 100 additions & 0 deletions docs/rules/rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Rules

Rules are components that can be associated with endpoints to add additional functionality. Based on the current codebase, rules are stored as string IDs and can be attached to multiple endpoints.

## Adding Rules to Endpoints

Rules can be added to endpoints through the AddEndpointRule modal component. The process works as follows:

1. Select a rule from the available rule options dropdown
2. The rule ID is added to the endpoint's `rules` array property
3. The endpoint is updated with the new rule association
4. On success, the modal closes automatically after 2 seconds

## Rule Properties

Rules have several key properties that define their behavior:

- uuid: A unique identifier string for the rule
- name: The display name of the rule
- description: A detailed description of the rule's purpose
- action: Specifies when the rule triggers (create, read, update, delete)
- timing: Controls if rule runs 'before' or 'after' the action (defaults to 'before')
- conditions: JSON Logic format conditions that determine when rule applies
- type: The rule type (mapping, error, script, synchronization, authentication, download, upload, locking)
- configuration: Type-specific configuration stored as JSON
- order: Integer determining execution order when multiple rules exist

The properties work together to define:

1. When the rule executes (action + timing)
2. Under what conditions it runs (conditions)
3. What functionality it provides (type + configuration)
4. The sequence of execution (order)

Rules are stored in a structured format but referenced by endpoints using their UUID strings in an array format.

## Rule Implementation

The current implementation shows:

- Rules are managed through a dedicated API endpoint at `/api/rules`
- Rules can be retrieved and managed through the Rules resource controller
- Rule IDs are stored and validated as strings within endpoints
- The endpoint entity ensures rules are always stored as an array

## Rule Types

### Authentication Rules

Authentication rules control access to endpoints by validating user credentials and permissions. Configuration options include:

- type: The authentication method to use
- basic: Basic HTTP authentication
- jwt: JSON Web Token authentication
- jwt-zgw: ZGW-specific JWT authentication
- oauth: OAuth 2.0 authentication
- users: Array of specific users allowed to access the endpoint
- groups: Array of user groups allowed to access the endpoint

### Download Rules

Download rules handle file access and retrieval. Configuration includes:

- fileIdPosition: Specifies the position of the file ID in the URL path
- Automatic validation of user access rights to requested files

### Upload Rules

Upload rules manage file upload functionality and restrictions. Configuration includes:

- path: The target directory path for uploaded files
- allowedTypes: Comma-separated list of allowed file extensions (e.g., jpg,png,pdf)
- maxSize: Maximum allowed file size in megabytes

### Locking Rules

Locking rules provide exclusive access control for resources. Configuration includes:

- action: The locking operation to perform
- lock: Lock a resource for exclusive access
- unlock: Release a previously locked resource
- timeout: Duration in minutes before the lock automatically expires

## Rule Validation

When adding rules to an endpoint:

- The rules array is initialized if it doesn't exist
- Existing rule IDs are converted to strings
- New rule IDs are validated before being added
- The endpoint is revalidated after rule changes

## Error Handling

The rule addition process includes:

- Validation that a rule is selected before saving
- Error catching and display if the save fails
- Loading state management during the save process
- Success/error message display to the user
3 changes: 3 additions & 0 deletions lib/Controller/EndpointsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ public function destroy(int $id): JSONResponse
*/
public function handlePath(string $_path): JSONResponse
{
// @todo: move to a rule service
/*
try {
$token = $this->request->getHeader('Authorization');
$this->authorizationService->authorize(authorization: $token);
Expand All @@ -206,6 +208,7 @@ public function handlePath(string $_path): JSONResponse
statusCode: 401
);
}
*/

// Find matching endpoints for the given path and method
$matchingEndpoints = $this->endpointMapper->findByPathRegex(
Expand Down
Loading
Loading