Skip to content

Commit 1b1dc62

Browse files
committed
Experiment to propagate allowed-groups to clients
We probably want to have some structure to better filter out quads and better filter out information sent to consumers (also see #26). This experiment allows dropping the access rights used in the request's header. It doesn't allow dropping the mu-session-id though doing so could allow for more involved folding and we see no reason not allow this too. The mu-auth-allowed-groups are still persisted in the delta body. It's not documented to be available there so we could remove it there too. A function can be specified to alter the access rights.
1 parent 1b6cf04 commit 1b1dc62

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ The exported property contains an array of definitions, each linking a match to
7272
- `options.ignoreFromSelf`: Don't inform about changes that originated from the microservice to be informed (based on the hostname).
7373
- `options.retry`: (experimental) How many times the request is sent again on failure. Defaults to 0. Warning: in case of retries, deltas may be received out of order!
7474
- `options.retryTimeout`: (experimental) How much time is left in between retries (in ms). Currently defaults to 250ms.
75+
- `options.propagateAllowedGroups`: (experimental) Should we propagate allowed groups to the consumer or should they be dropped? Defaults to `true` which means propagate, can also be a function which receives the access rights to alter.
7576

7677
### Modifying quads
7778
#### Normalize datetime

send-request.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ export async function sendRequest(
106106
"mu-session-id": muSessionId,
107107
};
108108

109-
if (changeSets[0].allowedGroups) {
110-
headers["MU-AUTH-ALLOWED-GROUPS"] = changeSets[0].allowedGroups;
109+
if (changeSets[0].allowedGroups) { // TODO: underspecified with sudo
110+
const propagateAllowedGroups = entry.options?.propagateAllowedGroups;
111+
if ( propagateAllowedGroups === true || propagateAllowedGroups === undefined) {
112+
headers["MU-AUTH-ALLOWED-GROUPS"] = changeSets[0].allowedGroups;
113+
} else if ( typeof propagateAllowedGroups === "function" ) {
114+
headers["MU-AUTH-ALLOWED-GROUPS"] = propagateAllowedGroups(changeSets[0].allowedGroups);
115+
}
111116
}
112117

113118
let body;

0 commit comments

Comments
 (0)