Giter Site home page Giter Site logo

itninja04 / blazor.auth0 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from henalbrod/blazor.auth0

0.0 0.0 0.0 3.14 MB

The library for using Auth0 in Blazor applications.

Home Page: https://github.com/henalbrod/Blazor.Auth0

License: MIT License

C# 98.43% JavaScript 1.57%

blazor.auth0's Introduction

Blazor.Auth0

Blazor Auth0 Library

This is a library for Blazor authentication with OIDC Authorization Code-Grant and Implicit-Grant flows, using Auth0's Universal Login and Silent Login for Blazor over .NET Core v3.0.0-RC1 client & server-side solutions, the idea behind this is to have an easy way of using Auth0's services in Blazor without the need of the auth0.js library.

GitHub license Nuget Nuget Github Actions

About Auth0

Auth0 is a platform that provides authentication and authorization as a service. Giving developers and companies the building blocks they need to secure their applications without having to become security experts.

You can connect any application (written in any language or on any stack) to Auth0 and define the identity providers you want to use (how you want your users to log in).

Learn more at:

JWT Auth for open source projects

Prerequisites

Blazor

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

Auth0

Basic knowledge of Auth0 IDaaS platform is assumed, otherwise, visiting Auth0 docs is highly recommended.

Installation

Install via NPM.

Server Side

Install-Package Blazor-Auth0-ServerSide -Version 1.0.0-Preview2

Client Side

Install-Package Blazor-Auth0-ClientSide -Version 1.0.0-Preview2

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

appsettings.json or Secrets file (recommended)

{
	"Auth0":{
		"Domain": "[Your_Auth0_Tenant_Domain]",
		"ClientId": "[Your_Auth0_Client/Application_Id]",
		"ClientSecret": "[Your_Auth0_Client/Application_Secret]",
		"Audience": "[Your_Auth0_Audience/API_Identifier]"
	}
}

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.AddDefaultBlazorAuth0Authentication(Configuration.GetSection("Auth0").Get<ClientOptions>());	

	// Other code...
}

 public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
 {
    // Otrher code...

	app.UseHttpsRedirection();
	app.UseStaticFiles();
     
	// Add Blazor.Auth0 middleware     
	app.UseBlazorAuth0();

	// 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>

Support

If you found a bug, have a consultation or a feature request please feel free to open an issue.

When opening issues please take in account to:

  • Avoid duplication: Please search for similar issues before.
  • Be specific: Please don't put several problems/ideas in the same issue.
  • Use short descriptive titles: You'll have the description box to explain yourself.
  • Include images whenever possible: A picture is worth a thousand words.
  • Include reproduction steps for bugs: Will be appreciated

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork it (https://github.com/henalbrod/Blazor.Auth0/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Authors

Henry Alberto Rodriguez - Initial work - GitHub - Twitter - Linkedin

  • Especial thanks for its contributions to:

jbomhold3 GitHub TopSwagCode GitHub

License

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

Acknowledgments

Release History

v1.0.0-Preview2

  • Overall upgrade to .Net Core 3.0 RC1
  • Removed Shell.razor in Example projects
  • Simplified App.razor in Example projects
  • Removed local _imports.razor in Example projects

v0.1.0.0-Preview1

  • Upgraded to .Net Core 3.0.0-preview8
  • Removed AuthComponent
  • New One-Liner instantiation
  • Server Side full rewrite
    • Better server-side Blazor Authentication compatibility/integration
    • Cookie-based session (No more silent login iframe in server-side)
    • Refresh token support (Refreshing and Revoking)
    • Client secret
    • Server-side sliding expiration

blazor.auth0's People

Contributors

henalbrod avatar jbomhold3 avatar topswagcode avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.