Skip to content
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

refactor candid ui auth #500

Merged
merged 4 commits into from
Dec 6, 2023
Merged

refactor candid ui auth #500

merged 4 commits into from
Dec 6, 2023

Conversation

chenyan-dfinity
Copy link
Contributor

@chenyan-dfinity chenyan-dfinity commented Dec 5, 2023

  • Allow customizing II url and derivationOrigin via parameter ii and origin. Report error on the login button if there is an error in the parameters.
  • Remove derivationOrigin by default, unless in the mainnet and we can detect the destination canister has set candid UI to be the alternativeOrigin.

@frederikrothenberger
Copy link

if there is an easy way to detect that alternativeOrigin has been set in the destination canister, we can enable derivationOrigin without the parameter.

There is not, unfortunately.

@chenyan-dfinity
Copy link
Contributor Author

There is not, unfortunately.

@frederikrothenberger Would it work if we fetch canister-id.icp0.io/.well-known/ii-alternative-origins, and parse the JSON response?

Copy link
Contributor

@rvanasa rvanasa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (suggested a fix for a subtle corner case).

tools/ui/src/auth/auth.ts Outdated Show resolved Hide resolved
Co-authored-by: Ryan Vandersmith <[email protected]>
@chenyan-dfinity
Copy link
Contributor Author

cc @Web3NL

@frederikrothenberger
Copy link

There is not, unfortunately.

@frederikrothenberger Would it work if we fetch canister-id.icp0.io/.well-known/ii-alternative-origins, and parse the JSON response?

Yes, you can parse that file. And if it contains the URL of the candid UI then you could set the canister base URL as a derivationOrigin.

But this only works in a narrow scenario and should still be a user choice.

Even better would be, to allow checking an arbitrary domain (i.e. a new input field) where you look up the asset .well-known/ii-alternative-origins and if the candid UI is in the list, you use that domain as derivation origin. This way, the candid UI would also play nice with dapps hosted on custom domains.

@chenyan-dfinity
Copy link
Contributor Author

Make sense. Users can still customize the derivation url with the origin parameter. This sounds like a good default option.

@chenyan-dfinity chenyan-dfinity merged commit 2f70240 into master Dec 6, 2023
4 checks passed
@chenyan-dfinity chenyan-dfinity deleted the ui-auth branch December 6, 2023 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants