OLT.Core.Identity.Abstractions
8.4.0-beta-0010
Prefix Reserved
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
This is a prerelease version of OLT.Core.Identity.Abstractions.
dotnet add package OLT.Core.Identity.Abstractions --version 8.4.0-beta-0010
NuGet\Install-Package OLT.Core.Identity.Abstractions -Version 8.4.0-beta-0010
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="OLT.Core.Identity.Abstractions" Version="8.4.0-beta-0010" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OLT.Core.Identity.Abstractions --version 8.4.0-beta-0010
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: OLT.Core.Identity.Abstractions, 8.4.0-beta-0010"
#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 OLT.Core.Identity.Abstractions as a Cake Addin #addin nuget:?package=OLT.Core.Identity.Abstractions&version=8.4.0-beta-0010&prerelease // Install OLT.Core.Identity.Abstractions as a Cake Tool #tool nuget:?package=OLT.Core.Identity.Abstractions&version=8.4.0-beta-0010&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
OLT Identity
OltIdentity
Injectable Identity wrapper from IOltIdentity
Abstract wrapper class that requires System.Security.Claims.ClaimsPrincipal. This concept it to be injected
Example using IHttpContextAccessor for a Asp.net Core web project with a Custom Claim
public interface IAppIdentity : IOltIdentity
{
string? MyCustomClaim { get; }
}
public class AppIdentity : OltIdentity, IAppIdentity
{
private readonly IHttpContextAccessor _httpContext;
public AppIdentity(IHttpContextAccessor httpContext)
{
_httpContext = httpContext;
}
public override ClaimsPrincipal Identity => _httpContext?.HttpContext?.User;
public string? MyCustomClaim => GetClaims("MyCustomClaim").FirstOrDefault()?.Value;
}
...
//Note: add to DI
services
.AddScoped<IAppIdentity, AppIdentity>();
Example for a console app or batch service using a Role Enum
// An enum used for a role using custom attribute "CodeAttribute" from OLT.Core.Attribute.Abstractions
public enum SecurityRoles
{
[Code("read-only")]
[Description("View all records")]
ReadOnly = 1000
}
public class BatchServiceIdentity : OltIdentity, IOltIdentity
{
public BatchServiceIdentity()
{
}
public const string SERVICE_NAME = "Batch Service";
public override string NameId => "Unique Id boes into this claim";
public override string Username => SERVICE_NAME;
public override ClaimsPrincipal Identity
{
get
{
var roles = new List<string>();
foreach (SecurityRoles role in Enum.GetValues(typeof(SecurityRoles)))
{
roles.Add(role.GetCodeEnum());
}
return new GenericPrincipal(new GenericIdentity(SERVICE_NAME), roles.ToArray());
}
}
}
public class MyExampleService : OltCoreService, IMyExampleService
{
private readonly IOltIdentity _identity;
public ReportManager(IOltIdentity identity)
{
_identity = identity;
}
public void ExampleMethod()
{
if (_identity.HasRole(SecurityRoles.ReadOnly))
{
//The Identity has the role
}
Debug.WriteLine(_identity.Username);
Debug.WriteLine(_identity.NameId);
Debug.WriteLine(_identity.FirstName);
Debug.WriteLine(_identity.LastName);
}
}
...
//Note: add to DI
services.AddScoped<IOltIdentity, BatchServiceIdentity>();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- OLT.Core.Attribute.Abstractions (>= 8.4.0-beta-0010)
- OLT.Core.DependencyInjection.Abstractions (>= 8.4.0-beta-0010)
- OLT.Core.Model.Abstractions (>= 8.4.0-beta-0010)
- System.ComponentModel.Annotations (>= 5.0.0)
-
net6.0
- OLT.Core.Attribute.Abstractions (>= 8.4.0-beta-0010)
- OLT.Core.DependencyInjection.Abstractions (>= 8.4.0-beta-0010)
- OLT.Core.Model.Abstractions (>= 8.4.0-beta-0010)
-
net8.0
- OLT.Core.Attribute.Abstractions (>= 8.4.0-beta-0010)
- OLT.Core.DependencyInjection.Abstractions (>= 8.4.0-beta-0010)
- OLT.Core.Model.Abstractions (>= 8.4.0-beta-0010)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on OLT.Core.Identity.Abstractions:
Package | Downloads |
---|---|
OLT.EF.Core
Base Context, Context Extensions, Seed Helpers, Entity Interfaces, Base Entity Models |
|
OLT.AspNetCore
OLT AspNetCore Library |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.4.0-beta-0010 | 113 | 11/7/2024 |
8.4.0-beta-0005 | 102 | 10/9/2024 |