-
Notifications
You must be signed in to change notification settings - Fork 1
fix: proof chain terminates powerline delegations #36
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
Closed
Closed
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -162,6 +162,31 @@ func TestProofChain_Powerline(t *testing.T) { | |
| assertChain(t, proofs, links, []ucan.Delegation{root, powerline}) | ||
| } | ||
|
|
||
| // TestProofChain_PowerlineRoot covers the case where the only delegation in | ||
| // the chain is a powerline issued by the invocation subject itself (the | ||
| // resource owner). This is the shape produced by sprue's access/confirm | ||
| // flow for a did:mailto account: account → agent with did.Undef subject. | ||
| // Without explicit handling, the recursion looks for a parent of the | ||
| // account-issued delegation, finds none, and returns an empty chain — | ||
| // causing the server to reject the invocation as "issued by non-subject | ||
| // with no proofs." | ||
| func TestProofChain_PowerlineRoot(t *testing.T) { | ||
| account := testutil.RandomSigner(t) | ||
| agent := testutil.Alice | ||
| cmd := testutil.Must(command.Parse("/test/do"))(t) | ||
|
|
||
| // account → agent powerline (no subject). The account is the resource | ||
| // owner; this single delegation IS the proof chain. | ||
| dlg := testutil.Must(delegation.Delegate(account, agent.DID(), did.Undef, cmd))(t) | ||
|
|
||
| finder := &memLister{delegations: []ucan.Delegation{dlg}} | ||
| matcher := ucanlib.NewDelegationMatcher(finder.List) | ||
|
|
||
| proofs, links, err := ucanlib.ProofChain(t.Context(), matcher, agent.DID(), cmd, account.DID()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't return anything - we don't have a valid proof chain. Powerline cannot be the root delegation. |
||
| require.NoError(t, err) | ||
| assertChain(t, proofs, links, []ucan.Delegation{dlg}) | ||
| } | ||
|
|
||
| func TestProofChain_UnrelatedCommandIgnored(t *testing.T) { | ||
| space := testutil.RandomSigner(t) | ||
| alice := testutil.Alice | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subshould NOT benullhere - it is checked by the caller (ProofChain). ThematchDelegationsfunction should only be returning delegations with subject ==subor subject ==null.If the subject is the issuer then we are at the root, otherwise we need to keep going.
The change here allows a powerline to be the root delegation, since the delegation returned here MAY have a
nullsubject. This is explicitly not allowed.