diff --git a/README.md b/README.md index fe0f18f..b323d35 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Blazor.Auth0 -Blazor Auth0 Library +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](http://blazor.net) over .NET Core v3.0.0-preview8 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. +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](http://blazor.net) 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](https://img.shields.io/github/license/Pegazux/Blazor.Auth0?color=blue)](https://github.com/Pegazux/Blazor.Auth0/blob/master/LICENSE) +[![GitHub license](https://img.shields.io/github/license/henalbrod/Blazor.Auth0?color=blue)](https://github.com/henalbrod/Blazor.Auth0/blob/master/LICENSE) [![Nuget](https://img.shields.io/nuget/v/Blazor-Auth0-ServerSide?color=green&label=Nuget%3A%20Blazor-Auth0-ServerSide)](https://www.nuget.org/packages/Blazor-Auth0-ServerSide) [![Nuget](https://img.shields.io/nuget/v/Blazor-Auth0-ClientSide?color=green&label=Nuget%3A%20Blazor-Auth0-Clientside)](https://www.nuget.org/packages/Blazor-Auth0-ClientSide) [![Github Actions](https://github.com/henalbrod/Blazor.Auth0/workflows/Github%20Actions%20CI/badge.svg)](https://github.com/henalbrod/Blazor.Auth0/actions) @@ -35,12 +35,12 @@ Install via [NPM](https://www.nuget.org/). >Server Side ```bash -Install-Package Blazor-Auth0-ServerSide -Version 1.0.0-Preview1 +Install-Package Blazor-Auth0-ServerSide -1.0.0-Preview2 ```` >Client Side ```bash -Install-Package Blazor-Auth0-ClientSide -Version 1.0.0-Preview1 +Install-Package Blazor-Auth0-ClientSide -1.0.0-Preview2 ```` ## Usage @@ -90,56 +90,28 @@ public void ConfigureServices(IServiceCollection services) // Other code... } ``` -### -Create a new Shell.razor file inside the Shared folder with the following code -> #### Shell.razor -```HTML -@inherits LayoutComponentBase - - - -

Sorry, there's nothing at this address.

-
- -

Sorry

-

You're not authorized to reach this page. You may need to log in as a different user.

-
- -

Please wait...

-
-
-``` ### Replace App.razor content with the following code > #### App.razor ```HTML -@inject Blazor.Auth0.IAuthenticationService authService -@inject Blazor.Auth0.Models.ClientOptions clientOptions - - - - - - - - - - - @if (authService.SessionState == SessionStates.Undefined || clientOptions.RequireAuthenticatedUser) - { -

Determining session state, please wait...

- } - else - { - - } -
- -
- -
+ + + + +

>Determining session state, please wait...

+
+ +

Sorry

+

You're not authorized to reach this page. You may need to log in as a different user.

+
+
+
+ +

Sorry, there's nothing at this address.

+
+
``` ## Support If you found a bug, have a consultation or a feature request please feel free to [open an issue](https://github.com/henalbrod/Blazor.Auth0/issues). @@ -164,6 +136,11 @@ Pull requests are welcome. For major changes, please open an issue first to disc ## Authors **Henry Alberto Rodriguez** - _Initial work_ - [GitHub](https://github.com/henalbrod) - [Twitter](https://twitter.com/henalbrod) - [Linkedin](https://www.linkedin.com/in/henalbrod/) +* Especial thanks for its contributions to: + +**jbomhold3** [GitHub](https://github.com/jbomhold3) +**TopSwagCode** [GitHub](https://github.com/TopSwagCode) + ## License This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/henalbrod/Blazor.Auth0/blob/master/LICENSE) file for details. @@ -176,6 +153,12 @@ This project is licensed under the MIT License - see the [LICENSE.md](https://gi ## 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 diff --git a/examples/Examples.AspNetCoreHosted/Client/App.razor b/examples/Examples.AspNetCoreHosted/Client/App.razor index e5aa922..5b52348 100644 --- a/examples/Examples.AspNetCoreHosted/Client/App.razor +++ b/examples/Examples.AspNetCoreHosted/Client/App.razor @@ -1,25 +1,16 @@ -@inject Blazor.Auth0.IAuthenticationService authService -@inject Blazor.Auth0.Models.ClientOptions clientOptions - - - - - - - - - - - @if (authService.SessionState == SessionStates.Undefined || clientOptions.RequireAuthenticatedUser) - { -

Determining session state, please wait...

- } - else - { - - } -
- -
- -
\ No newline at end of file + + + + +

>Determining session state, please wait...

+
+ +

Sorry

+

You're not authorized to reach this page. You may need to log in as a different user.

+
+
+
+ +

Sorry, there's nothing at this address.

+
+
\ No newline at end of file diff --git a/examples/Examples.AspNetCoreHosted/Client/Startup.cs b/examples/Examples.AspNetCoreHosted/Client/Startup.cs index ae6b603..c051eb3 100644 --- a/examples/Examples.AspNetCoreHosted/Client/Startup.cs +++ b/examples/Examples.AspNetCoreHosted/Client/Startup.cs @@ -11,13 +11,13 @@ public void ConfigureServices(IServiceCollection services) services.AddBlazorAuth0(options => { // Required - options.Domain = "blazor-auth0.auth0.com"; + options.Domain = "[Auth0_Domain]"; // Required - options.ClientId = "W6zJ2E5noUKYdnNblZh0M8imCCM5WT0z"; + options.ClientId = "[Auth0_client_Id]"; //// Required if you want to make use of Auth0's RBAC - options.Audience = "https://blazor-auth0-serverside.com"; + options.Audience = "[Auth0_Audience]"; // PLEASE! PLEASE! PLEASE! DO NOT USE SECRETS IN CLIENT-SIDE APPS... https://medium.com/chingu/protect-application-assets-how-to-secure-your-secrets-a4165550c5fb // options.ClientSecret = "NEVER!!"; diff --git a/examples/Examples.AspNetCoreHosted/Server/appsettings.json b/examples/Examples.AspNetCoreHosted/Server/appsettings.json index b723a33..df71354 100644 --- a/examples/Examples.AspNetCoreHosted/Server/appsettings.json +++ b/examples/Examples.AspNetCoreHosted/Server/appsettings.json @@ -1,6 +1,6 @@ { "Auth0": { - "Domain": "[Auth0_Audience]", + "Domain": "[Auth0_Domain]", "Audience": "[Auth0_Audience]" }, diff --git a/examples/Examples.ClientSide/Startup.cs b/examples/Examples.ClientSide/Startup.cs index 6bf4475..b6da7b0 100644 --- a/examples/Examples.ClientSide/Startup.cs +++ b/examples/Examples.ClientSide/Startup.cs @@ -13,13 +13,13 @@ public void ConfigureServices(IServiceCollection services) services.AddBlazorAuth0(options => { // Required - options.Domain = "blazor-auth0.auth0.com"; + options.Domain = "[Auth0_Domain]"; // Required - options.ClientId = "Psu6c0Sa4MC1QvdK2OJPONlON8JvaSQt"; + options.ClientId = "[Auth0_client_Id]"; //// Required if you want to make use of Auth0's RBAC - options.Audience = "https://blazor-auth0-serverside.com"; + options.Audience = "[Auth0_Audience]"; // PLEASE! PLEASE! PLEASE! DO NOT USE SECRETS IN CLIENT-SIDE APPS... https://medium.com/chingu/protect-application-assets-how-to-secure-your-secrets-a4165550c5fb // options.ClientSecret = "NEVER!!"; diff --git a/src/Blazor.Auth0.ClientSide/Authentication.cs b/src/Blazor.Auth0.ClientSide/Authentication.cs index f11c111..432e3c5 100644 --- a/src/Blazor.Auth0.ClientSide/Authentication.cs +++ b/src/Blazor.Auth0.ClientSide/Authentication.cs @@ -313,6 +313,11 @@ public static void ValidateAuthorizationResponse(AuthorizationResponse authoriza errorDescription = "Login Required"; + break; + case "consent_required": + + errorDescription = "Consent Required"; + break; default: errorDescription = authorizationResponse.ErrorDescription; diff --git a/src/Blazor.Auth0.ClientSide/AuthenticationService.cs b/src/Blazor.Auth0.ClientSide/AuthenticationService.cs index 070605e..002a3a2 100644 --- a/src/Blazor.Auth0.ClientSide/AuthenticationService.cs +++ b/src/Blazor.Auth0.ClientSide/AuthenticationService.cs @@ -461,7 +461,7 @@ private AuthorizeOptions BuildAuthorizeOptions() CodeChallengeMethods codeChallengeMethod = !isUsingSecret && responseType == ResponseTypes.Code ? CodeChallengeMethods.S256 : CodeChallengeMethods.None; string codeVerifier = codeChallengeMethod != CodeChallengeMethods.None ? CommonAuthentication.GenerateNonce(this.clientOptions.KeyLength) : null; string codeChallenge = codeChallengeMethod != CodeChallengeMethods.None ? Utils.GetSha256(codeVerifier) : null; - string nonce = this.RequiresNonce ? CommonAuthentication.GenerateNonce(this.clientOptions.KeyLength) : string.Empty; + string nonce = CommonAuthentication.GenerateNonce(this.clientOptions.KeyLength); return new AuthorizeOptions { diff --git a/src/Blazor.Auth0.ClientSide/Blazor.Auth0.ClientSide.csproj b/src/Blazor.Auth0.ClientSide/Blazor.Auth0.ClientSide.csproj index 6e857b7..40e10a3 100644 --- a/src/Blazor.Auth0.ClientSide/Blazor.Auth0.ClientSide.csproj +++ b/src/Blazor.Auth0.ClientSide/Blazor.Auth0.ClientSide.csproj @@ -16,11 +16,8 @@ true https://raw.githubusercontent.com/henalbrod/Blazor.Auth0/master/src/Blazor.Auth0.ClientSide/icon.png Blazor-Auth0-ClientSide - - Upgraded to .Net Core 3.0.0-preview8 - Removed AuthComponent - New One-Liner instantiation - + Upgraded to .Net Core 3.0.0-RC1 + true diff --git a/src/Blazor.Auth0.ServerSide/Blazor.Auth0.ServerSide.csproj b/src/Blazor.Auth0.ServerSide/Blazor.Auth0.ServerSide.csproj index 867b4c9..fdbd8d2 100644 --- a/src/Blazor.Auth0.ServerSide/Blazor.Auth0.ServerSide.csproj +++ b/src/Blazor.Auth0.ServerSide/Blazor.Auth0.ServerSide.csproj @@ -15,15 +15,7 @@ true https://raw.githubusercontent.com/henalbrod/Blazor.Auth0/master/src/Blazor.Auth0.ClientSide/icon.png Blazor-Auth0-ServerSide - 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 + Upgraded to .Net Core 3.0.0-RC1 true diff --git a/src/Blazor.Auth0.Shared/Blazor.Auth0.Shared.csproj b/src/Blazor.Auth0.Shared/Blazor.Auth0.Shared.csproj index 07378d3..56c14dd 100644 --- a/src/Blazor.Auth0.Shared/Blazor.Auth0.Shared.csproj +++ b/src/Blazor.Auth0.Shared/Blazor.Auth0.Shared.csproj @@ -15,16 +15,7 @@ true https://raw.githubusercontent.com/henalbrod/Blazor.Auth0/master/src/Blazor.Auth0.ClientSide/icon.png Blazor-Auth0-Shared - 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 - + Upgraded to .Net Core 3.0.0-RC1 true