Skip to content
No description, website, or topics provided.
C# JavaScript HTML
Branch: master
Clone or download
Latest commit 1bfd879 Sep 26, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Adds SessionStateChangedEventAsync. Adds Processing Status Return Inv… Sep 25, 2019
src Fixes aud issue. Sep 25, 2019
.gitignore first commit Sep 24, 2019
LICENSE first commit Sep 24, 2019
README.md Small imprecision correction Sep 25, 2019

README.md

Blazor.OpenId

This is a library for Blazor authentication with OpenId Authorization Code-Grantflow, using IdenityServer or other OpenId providers and Silent Refresh for Blazor over .NET Core v3.0.0 client & server-side solutions, the idea behind this is to have an easy way of using OpenId services in Blazor without the need of the js library.

Nuget

Prerequisites

Blazor

You'll want to follow the Getting Started instructions in Blazor website

IdenityServer or Another OpenId Server

You need need to setup and configure OpenId Server. By default Blazor.OpenId redirects to the root of your application.

Installation

Install via Nuget.

Server Side

Install-Package Blazor-OpenId  

Usage

Note: Following example is for a server-side with require authenticated user implementation, for client-side and core-hosted example implementations please refer to the examples

Startup.cs

// Import Blazor.Auth0
using Blazor.Auth0;
using Blazor.Auth0.Models;
// ...

public void ConfigureServices(IServiceCollection services)
{
	// Other code...

	/// This one-liner will initialize Blazor.Auth0 with all the defaults
	    services.AddBlazorOpenid(options =>
            {
                options.Domain = "[Your-Domain]";
                options.ClientId = "[Your-Client-Id]";
                options.SlidingExpiration = true;
                options.Scope = "[Your-Scopes]";  // By default openid profile email
                options.RequestMode = Blazor.OpenId.Models.RequestModes.Form_Post;
            });

	// Other code...
}

Replace App.razor content with the following code

App.razor

<Router AppAssembly="@typeof(Program).Assembly">
    <Found Context="routeData">
        <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
            <Authorizing>
                <p>>Determining session state, please wait...</p>
            </Authorizing>
            <NotAuthorized>
                <h1>Sorry</h1>
                <p>You're not authorized to reach this page. You may need to log in as a different user.</p>
            </NotAuthorized>
        </AuthorizeRouteView>
    </Found>
    <NotFound>        
        <p>Sorry, there's nothing at this address.</p>        
    </NotFound>
</Router>

Authors

John J Bomhold - OpenId implementation of Auth0

Blazor.Auth0 was created by Henry Alberto Rodriguez - GitHub - Twitter - Linkedin

License

This project is licensed under the MIT License - see the LICENSE file for details.

You can’t perform that action at this time.