Repository navigation
feat(iam): refuse to cache delegations seen revoked #177
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
463c9b5
feat(iam): refuse to cache delegations seen revoked
pyropy 07d2cc0
fix(iam): name the admin-account helper past main's account variable
pyropy 54cb3c5
fix(iam): check for a revocation and cache the delegations in one step
pyropy 8091f3d
fix(iam): refuse to cache a bucket-info delegation seen revoked
pyropy a6b7796
fix(iam): remember a revoked CID until restart, not midnight
pyropy 6fad20d
fix(iam): bound the revoked set by a TTL renewed on each sighting
pyropy a24e83a
chore(iam): drop the ponytail: prefix from two comments
pyropy 58440d6
refactor(iam): let each key's DelegationCache refuse revoked delegations
pyropy bd46182
revert: keep the revocation check in KeyProofs
pyropy 361b042
refactor(iam): call the delegations a deposit takes proofs, they are …
pyropy 1f42918
refactor(iam): let a key's DelegationCache refuse revoked proofs
pyropy 5982c2b
chore: pin hilt main at 42dd070e and libforge main at 6d9e32d4
pyropy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package iam | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/fil-forge/ucantone/ucan/delegation" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // TestRevocationTTL: a revocation names only a CID, and the grant behind it | ||
| // may never expire, so the revoked set keeps it for revokedTTL — past the | ||
| // authorize horizon — and renews it each time Hilt serves the CID again. | ||
| func TestRevocationTTL(t *testing.T) { | ||
| kp := NewKeyProofs() | ||
| dlg := mintDelegation(t, delegation.WithNoExpiration()) | ||
| id := dlg.Link().String() | ||
| expiresIn := func() time.Duration { | ||
| item, ok := kp.revoked.Items()[id] | ||
| require.True(t, ok, "the revocation is recorded") | ||
| return time.Until(time.Unix(0, item.Expiration)) | ||
| } | ||
|
|
||
| kp.InvalidateHolders(dlg.Link()) | ||
| require.InDelta(t, revokedTTL, expiresIn(), float64(time.Minute), "recorded for revokedTTL, not until midnight") | ||
|
|
||
| // A refusal while the entry is young leaves it alone: a read is not a write. | ||
| fresh := kp.revoked.Items()[id].Expiration | ||
| require.False(t, kp.For(dlg.Audience()).Add(dlg)) | ||
| require.Equal(t, fresh, kp.revoked.Items()[id].Expiration, "a young revocation is not rewritten") | ||
|
|
||
| // Hilt serving the revoked CID again once the entry has used up half its | ||
| // life renews it. | ||
| kp.revoked.Set(id, struct{}{}, time.Minute) | ||
| require.False(t, kp.For(dlg.Audience()).Add(dlg)) | ||
| require.InDelta(t, revokedTTL, expiresIn(), float64(time.Minute), "a refusal renews an ageing revocation") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.