Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4840

Can I use MetaMask as an asp.net RemoteAuthenticationHandler?

$
0
0

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

  1. Directs the user to /sign-in/meta-mask.
  2. This would render a page that asks to connect to the wallet
  3. 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
  4. Redirects to some kind of /complete-sign-in/meta-mask?data=xxxxxxxx&signature=xxxxxxxx (or whatever the standard is in Blazor)
  5. 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!


Viewing all articles
Browse latest Browse all 4840

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>