Each user owns an individual canister. Previously this lookup was done using a global user index canister which had a mapping for user's principal to their individual canister's principal
The single user index has been changed to a sharded index instead in our new multi subnet model. We currently don't have a quick way to do this lookup.
This proposal defines a rough sketch for allowing this lookup via the auth service
Requirements
A User should be able to set their canister id
A User should be able to set their username
Frontend should be able to query the canister id given user's principal
Frontend should be able to query the canister id given user's username
Endpoints
An authenticated endpoint to set the canister id for a user's principal
An authenticated endpoint to set the username for a user's principal
A read endpoint for querying the user's canister id by the user's principal
A read endpoint for querying the user's canister id by user's principal
Security
We should use signatures for ensuring that the correct user is making the request. Signatures from delegated identity can be verified in rust outside canisters as well. An example is available here: https://github.com/go-bazzinga/ic-verify-example
I don't have an example to verify this identity unfortunately
For the sake of a quick implementation, we can add the verification later as well but please make sure to track this as its a severe security flaw that could lead to DoS. (An attacker could store an arbitrary canister id for anyone and cause failures in frontend for the user(s))
Entities
A User Principal -> User Canister mapping
A Username -> User Canister mapping
(Optional) Store user canister in user's metadata as well & make this part of the session: The reason why i think this is optional is that frontend can afford to make another call for getting the user's canister (it previously had to call user index anyways) as cloudflare kv is super optimized for reads
Proposal Details
Each user owns an individual canister. Previously this lookup was done using a global user index canister which had a mapping for user's principal to their individual canister's principal
The single user index has been changed to a sharded index instead in our new multi subnet model. We currently don't have a quick way to do this lookup.
This proposal defines a rough sketch for allowing this lookup via the auth service
Requirements
Endpoints
Security
We should use signatures for ensuring that the correct user is making the request. Signatures from delegated identity can be verified in rust outside canisters as well. An example is available here: https://github.com/go-bazzinga/ic-verify-example
Another alternative is to use the Delegated Identity: https://docs.rs/ic-agent/latest/ic_agent/identity/struct.DelegatedIdentity.html Which the frontend can provide. Note that to ensure that a Delegated Identity is valid, we need to ensure that the delegation chain points to the current public key: https://docs.rs/ic-agent/latest/ic_agent/trait.Identity.html#method.delegation_chain
I don't have an example to verify this identity unfortunately
For the sake of a quick implementation, we can add the verification later as well but please make sure to track this as its a severe security flaw that could lead to DoS. (An attacker could store an arbitrary canister id for anyone and cause failures in frontend for the user(s))
Entities
A User Principal -> User Canister mapping A Username -> User Canister mapping (Optional) Store user canister in user's metadata as well & make this part of the session: The reason why i think this is optional is that frontend can afford to make another call for getting the user's canister (it previously had to call user index anyways) as cloudflare kv is super optimized for reads