CodeWorks.Auth0Provider
2.0.0
dotnet add package CodeWorks.Auth0Provider --version 2.0.0
NuGet\Install-Package CodeWorks.Auth0Provider -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CodeWorks.Auth0Provider" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CodeWorks.Auth0Provider --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: CodeWorks.Auth0Provider, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CodeWorks.Auth0Provider as a Cake Addin #addin nuget:?package=CodeWorks.Auth0Provider&version=2.0.0 // Install CodeWorks.Auth0Provider as a Cake Tool #tool nuget:?package=CodeWorks.Auth0Provider&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
CodeWorks.Auth0Provider
dotnet add package CodeWorks.Auth0Provider
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<CodeWorks.Utils.Auth0Provider>();
}
UserInfoModel
Create you own UserInfo model and have the library extract and cast to your prefered class with generics.
Profile.cs
public class Profile
{
public string Id { get; set; } // Will be mapped to the id (uuid) from Auth0
public string Name { get; set; }
public string Email { get; set; }
public string Picture { get; set; }
public List<string> Roles { get; set; } = new List<string>(); // Will be mapped to the Roles from Auth0
public List<string> Permissions { get; set; } = new List<string>(); // Will be mapped to the Permissions from Auth0
}
HttpContext
extract the UserInfo in your controllers via HttpContext
AccountController.cs
public class AccountController : ControllerBase
{
// Uses Dependency IOC
private readonly Auth0Provider _auth0Provider;
public AccountController(Auth0Provider auth0Provider)
{
_auth0Provider = auth0Provider;
}
[HttpGet]
[Authorize] // Works with native controls
public async Task<ActionResult<Account>> Get()
{
try
{
// retrieves userInfo from Auth0 or CacheControl
Account userInfo = await _auth0Provider.GetUserInfoAsync<Account>(HttpContext);
return Ok(userInfo);
}
catch (Exception e)
{
return BadRequest(e.Message);
}
}
}
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. |
.NET Core | netcoreapp3.1 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.Extensions.Caching.Memory (>= 3.1.9)
- Newtonsoft.Json (>= 12.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.