Skip to content

Instantly share code, notes, and snippets.

@EdCharbeneau
Last active August 13, 2021 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EdCharbeneau/2b5d661da24e586d01e309db91f4fa83 to your computer and use it in GitHub Desktop.
Save EdCharbeneau/2b5d661da24e586d01e309db91f4fa83 to your computer and use it in GitHub Desktop.
Blazor powered auth pages

A tip sent to me by Brian Douglass...

The way it works is:

  • Create a new Server project with Identity activated, but no scaffolding
  • Modify Startup.cs to add the AF token as a header
  • Create a custom SignIn.razor
    • Collects credentials in a form
    • OnValidSubmit() after checking validity of credentials
      • Make Http call to Login.OnGet() and get the form, with the AF token attached
      • Build new request with Credentials + AF token in the Form data + AF token in the header.
      • Post the request to Login.OnPostAsync() User credentials are validated
      • Response (if successful) contains Authentication Cookie
      • Use Oqtane's Interop.SetCookie to add it to the Document
      • Magic Use NavigationManager.NavigateTo("/", true)
        • The true setting bypasses client-side routing and forces the browser to load a new page from the server
        • Voila, the authentication cookie is loaded into the browser, and all A&A facilities work as documented just like Asp.Net Core, but UI/UX is 100% Blazor! ~15 minutes. The rest of SUSISO is downhill from there. Would appreciate a looksee as this is to share with everyone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment