Auth0ExtensionManager 1.1.0
See the version list below for details.
dotnet add package Auth0ExtensionManager --version 1.1.0
NuGet\Install-Package Auth0ExtensionManager -Version 1.1.0
<PackageReference Include="Auth0ExtensionManager" Version="1.1.0" />
<PackageVersion Include="Auth0ExtensionManager" Version="1.1.0" />
<PackageReference Include="Auth0ExtensionManager" />
paket add Auth0ExtensionManager --version 1.1.0
#r "nuget: Auth0ExtensionManager, 1.1.0"
#:package Auth0ExtensionManager@1.1.0
#addin nuget:?package=Auth0ExtensionManager&version=1.1.0
#tool nuget:?package=Auth0ExtensionManager&version=1.1.0
Introduction
Project created to quickly onboard Auth0 .net 3.1 + apps
Add to appSettgins
Add the following section to appSettings.json file
"Auth0": {
"Authority": "[DOMAIN]",
"ApiIdentifier": "[AUDIENCE]"
},
Update statup.cs file
Next in Statup.cs add the following code to the ConfigureServices method/section
services.AddAuth0ExtensionManager();
Next made sure you have add the following to the Configure method in statup.cs
app.UseAuthentication();
app.UseAuthorization();
Secure Controllers
you can use the follwoing sample code to test if your security is configured correctly.
[Route("api")]
[ApiController]
public class ApiController : ControllerBase
{
[HttpGet("public")]
public IActionResult Public()
{
return Ok(new
{
Message = "Hello from a public endpoint! You don't need to be authenticated to see this."
});
}
[HttpGet("private")]
[Authorize]
public IActionResult Private()
{
return Ok(new
{
Message = "Hello from a private endpoint! You need to be authenticated to see this."
});
}
[HttpGet("private-scoped")]
[Authorize("read:messages")]
public IActionResult Scoped()
{
return Ok(new
{
Message = "Hello from a private endpoint! You need to be authenticated and have a scope of read:messages to see this."
});
}
// This is a helper action. It allows you to easily view all the claims of the token.
[HttpGet("claims")]
public IActionResult Claims()
{
return Ok(User.Claims.Select(c =>
new
{
c.Type,
c.Value
}));
}
}
that's it all done. just [Authorize] or the [Authorize("read:messages")] the a spicifc scope to any controller or method in the controller you would like to secure.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 3.1.10)
- Microsoft.Extensions.DependencyInjection (>= 3.1.10)
- Microsoft.Extensions.Http (>= 3.1.10)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.