In the default Blazor web app template (with "Individual Accounts" authentication) there is a page in Components\Account\Pages\Manage\ExternalLogins.razor that has a page URL /Account/Manage/ExternalLogins.
Relevant parts of the page are
@inject SignInManager<ApplicationUser> SignInManager<h4>Add another service to log in.</h4><hr /><form class="form-horizontal" action="Account/Manage/LinkExternalLogin" method="post"><AntiforgeryToken /><div><p> @foreach (var provider in otherLogins) {<button type="submit" class="btn btn-primary" name="Provider" value="@provider.Name" title="Log in using your @provider.DisplayName account"> @provider.DisplayName</button> }</p></div></form>@code{ private IList<AuthenticationScheme>? otherLogins; protected override async Task OnInitializedAsync() { otherLogins = (await SignInManager.GetExternalAuthenticationSchemesAsync()) .Where(auth => currentLogins.All(ul => auth.Name != ul.LoginProvider)) .ToList(); }}For an item to appear in this list it must descend from Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler<TOptions> where TOptions : RemoteAuthenticationOptions.
I'd like to have an option that appears on the list which
- Directs the user to
/sign-in/meta-mask. - This would render a page that asks to connect to the wallet
- Asks it to sign some information to prove the user owns the wallet - this is done with JavaScript talking to the browser plugin for the crypto wallet
- Redirects to some kind of
/complete-sign-in/meta-mask?data=xxxxxxxx&signature=xxxxxxxx(or whatever the standard is in Blazor) - The server will then process the signature to confirm it, and if it succeeds then use that as an authentication for the user.
I have muddled my way around but I am unable to work out even the first step, which is handling the post to Account/Manage/LinkExternalLogin.
An example of how do to this would be great, but at this point I'd love to know even how to know if my RemoteAuthenticationHandler<T> descendant should even handle the request.
Any help will be gratefully received!