-
Notifications
You must be signed in to change notification settings - Fork 28
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
Do you support delegations in signing certificates when making calls to canisters? #58
Comments
I'm guessing no as when the signing occurs here: Line 15 in 7754db0
In the envelope there is no option for sender_delegation, as defined here: https://smartcontracts.org/docs/current/references/ic-interface-spec/#authentication Any plans to add sender_delegation? |
Try to support delegation in #59. It is just a simple implementation. You can switch to that branch and test. Using the ic_delegation and ic_identity in the local storage can construct an II delegation identity. from ic.Identity import DelegationIdentity
from ic.Agent import Agent
from ic.Client import Client
# delegation and identity get from browser local storage
ic_delegation = """
{
"delegations": [
{
"delegation": {
"expiration": "xxx",
"pubkey": "xxx"
},
"signature": "xxx"
}
],
"publicKey": "xxx"
}
"""
ic_identity = """
[
"xxx",
"xxx"
]
"""
client = Client()
iden = DelegateIdentity.from_json(ic_identity, ic_delegation)
print('principal:', Principal.self_authenticating(iden.der_pubkey))
ag = Agent(iden, client)
# now can use the agent to do query or update call Remember that delegation identity from II has an expiry, thus it can't be used forever. |
Oh nice! This is awesome! I'll test this out this week. And yeah, I know it has an expiry, but I'm going to use the II backend to actually add my script as a new device so then I have permanent authenticated access. I had to figure out authenticated/delegated II calls first though as you need those to register a new device. |
All of my testing appears to be working on the delegation branch. Loading in a delegated identity using the information from II in the browser works great. |
I just tried to pull some data from a different canister using the same feat_delegation branch I used for my other testing, and it gave me an error reading the data using the candid. When I switched back to main it worked again, so something is probably still off on the feat_delegation branch. Maybe you have tests you can run to spruce it up before merging those changes in to main. 😀 Just figured I would let you know. |
Can you paste your error here? Some snippets that can reproduce it would be great! |
Yeah, here's an error:
And this happens when I call a few methods. Let me find you a public method to call to reproduce the error. |
Here's a public reproducible error for you:
|
Just as a follow-up, this code works fine on the main branch, but breaks with the error above on the feat-delegation branch. Maybe due to the type table parsing fix you pull into it to fix the other bug. |
Should be fixed now. Thanks! |
Yeah perfect. That solved the issue. Running into one more issue. This is the governance canister (same .did as above)
In this case, I get the following error:
Usually if I have a formatting error between types/values in candid I get a record formatting error, so it seems my values match the candid. But for some reason it is failing to correctly encode the data using the candid. So I thought maybe an ic-py issue? |
Fixed! Thank you very much for the detail. I think we should test it more carefully and thoroughly. |
Yeah, that fixes it. Thanks! Everything seems to be working now on feat-delegation branch. I'm able to authenticate with II across apps and automate process. So I'm in really good shape. Thanks for all the help. When are you thinking about merging this branch into production? Would love to get it in sooner rather than later (assuming all bugs have been fixed) to prevent too many conflicts from the main repo. |
Would love to be able to pass in a delegation as a parameter to Identity or Canister or query_raw (or somewhere else) to be able to call on behalf of delegated principal. Is this possible right now?
The text was updated successfully, but these errors were encountered: