Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 9a5077e

Browse files
maksymarDfinity-Bjoernmraszyk
authored
[FINAL] feat: [EXC-1676] add allowed viewers variant to canister's log visibility (#326)
* add log_visibility allowlist * . * add limit * wording * no opt * allowed_viewers * rm canister_log_allowlist * AllowedViewers * AllowedViewers * . * . * wording * canister_log_visibility = * formatting * change variants order * Update spec/index.md Co-authored-by: mraszyk <[email protected]> * Update spec/index.md * wording * changelog --------- Co-authored-by: Björn Tackmann <[email protected]> Co-authored-by: mraszyk <[email protected]> Co-authored-by: Martin Raszyk <[email protected]>
1 parent 2f4aede commit 9a5077e

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

spec/_attachments/ic.did

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type snapshot_id = blob;
55
type log_visibility = variant {
66
controllers;
77
public;
8+
allowed_viewers : vec principal;
89
};
910

1011
type canister_settings = record {

spec/_attachments/interface-spec-changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### ∞ (unreleased)
44
* Allow anonymous query and read state requests with invalid `ingress_expiry`.
5+
* Add allowed viewers variant to canister log visibility.
56

67
### 0.28.0 (2024-10-11) {#0_28_0}
78
* Add new management canister methods for canister snapshot support.

spec/index.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,7 +2617,12 @@ The canister logs are *not* collected in canister methods running in non-replica
26172617
The total size of all returned logs does not exceed 4KiB.
26182618
If new logs are added resulting in exceeding the maximum total log size of 4KiB, the oldest logs will be removed.
26192619
Logs persist across canister upgrades and they are deleted if the canister is reinstalled or uninstalled.
2620-
The log visibility is defined in the `log_visibility` field of `canister_settings`: logs can be either public (visible to everyone) or only visible to the canister's controllers (by default).
2620+
2621+
The log visibility is defined in the `log_visibility` field of `canister_settings` and can be one of the following variants:
2622+
2623+
- `controllers`: only the canister's controllers can fetch logs (default);
2624+
- `public`: everyone can fetch logs;
2625+
- `allowed_viewers` (`vec principal`): only principals in the provided list and the canister's controllers can fetch logs, the maximum length of the list is 10.
26212626

26222627
A single log is a record with the following fields:
26232628

@@ -3389,6 +3394,7 @@ CanisterHistory = {
33893394
CanisterLogVisibility
33903395
= Controllers
33913396
| Public
3397+
| AllowedViewers [Principal]
33923398
CanisterLog = {
33933399
idx : Nat;
33943400
timestamp_nanos : Nat;
@@ -6147,7 +6153,11 @@ Q.canister_id = ic_principal
61476153
Q.method_name = 'fetch_canister_logs'
61486154
Q.arg = candid(A)
61496155
A.canister_id = effective_canister_id
6150-
S[A.canister_id].canister_log_visibility = Public or Q.sender in S[A.canister_id].controllers
6156+
(S[A.canister_id].canister_log_visibility = Public)
6157+
or
6158+
(S[A.canister_id].canister_log_visibility = Controllers and Q.sender in S[A.canister_id].controllers)
6159+
or
6160+
(S[A.canister_id].canister_log_visibility = AllowedViewers Principals and (Q.sender in S[A.canister_id].controllers or Q.sender in Principals))
61516161

61526162
```
61536163

0 commit comments

Comments
 (0)