Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Commit

Permalink
v2.0.0-Preview5
Browse files Browse the repository at this point in the history
Fixed issue #41, Upgraded to .Net Core v3.2.0-preview1
  • Loading branch information
henalbrod committed Mar 4, 2020
1 parent 71fa61d commit 8474591
Show file tree
Hide file tree
Showing 21 changed files with 293 additions and 273 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/blank.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
build:

container:
image: mcr.microsoft.com/dotnet/core/sdk:3.1.100-preview3-bionic
image: mcr.microsoft.com/dotnet/core/sdk:3.1.102-bionic

runs-on: ubuntu-16.04

Expand Down
71 changes: 37 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Learn more at:

### Blazor

>You'll want to follow the [Getting Started](https://docs.microsoft.com/en-us/aspnet/core/blazor/get-started?view=aspnetcore-3.0&tabs=visual-studio) instructions in [Blazor website](https://blazor.net)
>You'll want to follow the [Getting Started](https://docs.microsoft.com/en-us/aspnet/core/blazor/get-started?view=aspnetcore-3.1&tabs=visual-studio) instructions in [Blazor website](https://blazor.net)
### Auth0

Expand All @@ -38,60 +38,58 @@ Install via [Nuget](https://www.nuget.org/).

>Server Side
```bash
Install-Package Blazor-Auth0-ServerSide -Version 2.0.0-Preview4
Install-Package Blazor-Auth0-ServerSide -Version 2.0.0-Preview5
````

>Client Side
```bash
Install-Package Blazor-Auth0-ClientSide -Version 2.0.0-Preview4
Install-Package Blazor-Auth0-ClientSide -Version 2.0.0-Preview5
````
## 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](https://github.com/henalbrod/Blazor.Auth0/tree/master/examples)
**Note**: Following example is for a client-side with require-authenticated-user implementation, for server-side and core-hosted example implementations please refer to the [examples](https://github.com/henalbrod/Blazor.Auth0/tree/master/examples)
> #### appsettings.json or [Secrets file](https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-3.0&tabs=windows#secret-manager) (recommended)
```Json
{
"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
> #### Program.cs
```C#
// Import Blazor.Auth0

using Blazor.Auth0;
using Blazor.Auth0.Models;

// ...

public void ConfigureServices(IServiceCollection services)

public static async Task Main(string[] args)
{
// Other code...
var builder = WebAssemblyHostBuilder.CreateDefault(args);

/// This one-liner will initialize Blazor.Auth0 with all the defaults
services.AddDefaultBlazorAuth0Authentication(Configuration.GetSection("Auth0").Get<ClientOptions>());
builder.Services.AddBlazorAuth0(options =>
{
// Required
options.Domain = "[Auth0_Domain]";

// Other code...
}
// Required
options.ClientId = "[Auth0_Client_Id]";

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// Otrher code...
//// Required if you want to make use of Auth0's RBAC
options.Audience = "[Auth0_Audience]";
app.UseHttpsRedirection();
app.UseStaticFiles();

// Add Blazor.Auth0 middleware
app.UseBlazorAuth0();
//// Uncomment the following line if you don't want your users to be automatically logged-off on token expiration
// options.SlidingExpiration = true;

//// Uncomment the following two lines if you want your users to log in via a pop-up window instead of being redirected
// options.LoginMode = LoginModes.Popup;

//// Uncomment the following line if you don't want your unauthenticated users to be automatically redirected to Auth0's Universal Login page
// options.RequireAuthenticatedUser = false;
});

builder.RootComponents.Add<App>("app");

await builder.Build().RunAsync();
}

// Other code...
}
```
###
Expand Down Expand Up @@ -153,6 +151,11 @@ This project is licensed under the MIT License - see the [LICENSE](https://githu
## Release History
**v2.0.0-Preview5**
* Upgraded to .Net Core v3.2.0-preview1
* Fixed issue #41
**v2.0.0-Preview4**
* Upgraded to .Net Core v3.1.0-preview3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.1.0-preview3.19555.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.1.0-preview3.19555.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.2.0-preview1.20073.1" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview1.20073.1" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
</ItemGroup>

<Choose>
Expand All @@ -22,7 +22,7 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="Blazor-Auth0-ClientSide" Version="2.0.0-Preview4" />
<PackageReference Include="Blazor-Auth0-ClientSide" Version="2.0.0-Preview5" />
</ItemGroup>
</Otherwise>
</Choose>
Expand Down
53 changes: 45 additions & 8 deletions examples/Examples.AspNetCoreHosted/Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,53 @@
using Microsoft.AspNetCore.Blazor.Hosting;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Blazor.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Blazor.Auth0;

namespace Examples.AspNetCoreHosted.Client
{
public static class Program
public class Program
{
public static void Main(string[] args)
public static async Task Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Services.AddBlazorAuth0(options =>
{
// Required
options.Domain = "[Auth0_Domain]";

// Required
options.ClientId = "[Auth0_Client_Id]";

//// Required if you want to make use of Auth0's RBAC
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!!";

//// Uncomment the following line if you don't want your users to be automatically logged-off on token expiration
// options.SlidingExpiration = true;

public static IWebAssemblyHostBuilder CreateHostBuilder(string[] args) =>
BlazorWebAssemblyHost.CreateDefaultBuilder()
.UseBlazorStartup<Startup>();
//// Uncomment the following two lines if you want your users to log in via a pop-up window instead of being redirected
// options.LoginMode = LoginModes.Popup;

//// Uncomment the following line if you don't want your unauthenticated users to be automatically redirected to Auth0's Universal Login page
// options.RequireAuthenticatedUser = false;
});

// Policy based authorization, learn more here: https://docs.microsoft.com/en-us/aspnet/core/security/authorization/policies?view=aspnetcore-3.1
builder.Services.AddAuthorizationCore(options =>
{
options.AddPolicy("read:weather_forecast", policy => policy.RequireClaim("permissions", "read:weather_forecast"));
options.AddPolicy("execute:increment_counter", policy => policy.RequireClaim("permissions", "execute:increment_counter"));
});

builder.RootComponents.Add<App>("app");

await builder.Build().RunAsync();
}
}
}
48 changes: 0 additions & 48 deletions examples/Examples.AspNetCoreHosted/Client/Startup.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>7.3</LangVersion>
<UserSecretsId>29ffcc70-613f-459f-a62d-8cdd218eb11b</UserSecretsId>
<UserSecretsId>6c2330d9-84c7-4bf5-80a9-6b48c017bbab</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="3.2.0-preview1.20073.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions examples/Examples.AspNetCoreHosted/Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseAuthentication();

app.UseStaticFiles();
app.UseClientSideBlazorFiles<Client.Startup>();
app.UseClientSideBlazorFiles<Client.Program>();

app.UseRouting();

Expand All @@ -73,7 +73,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
endpoints.MapFallbackToClientSideBlazor<Client.Startup>("index.html");
endpoints.MapFallbackToClientSideBlazor<Client.Program>("index.html");
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

</Project>
12 changes: 6 additions & 6 deletions examples/Examples.ClientSide/Examples.ClientSide.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<OutputType>Exe</OutputType>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.1.0-preview3.19555.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.1.0-preview3.19555.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.1.0-preview3.19555.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.2.0-preview1.20073.1" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview1.20073.1" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.2.0-preview1.20073.1" PrivateAssets="all" />
</ItemGroup>

<Choose>
Expand All @@ -22,7 +22,7 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="Blazor-Auth0-ClientSide" Version="2.0.0-Preview4" />
<PackageReference Include="Blazor-Auth0-ClientSide" Version="2.0.0-Preview5" />
</ItemGroup>
</Otherwise>
</Choose>
Expand Down
Loading

0 comments on commit 8474591

Please sign in to comment.