Adding security

This commit is contained in:
Zeeshaun
2026-03-24 09:49:29 -05:00
parent 69648a3b8f
commit a3b74e62a9
59 changed files with 2480 additions and 0 deletions
@@ -0,0 +1,11 @@
namespace LCU.Library.Internal.Security.Models.AccessPolicy;
public class AccessPolicies
{
public AccessPolicy[] Policies { get; set; }
public AccessPolicies(AccessPolicy[] policies)
{
Policies = policies;
}
}
@@ -0,0 +1,15 @@
namespace LCU.Library.Internal.Security.Models.AccessPolicy;
public class AccessPolicy
{
public string Name { get; set; }
public string[] Groups { get; set; }
public AccessPolicy[]? Policies { get; set; }
public AccessPolicy(string name, string[] groups, AccessPolicy[]? policies)
{
Name = name;
Groups = groups;
Policies = policies;
}
}
@@ -0,0 +1,13 @@
using Microsoft.AspNetCore.Authorization;
namespace LCU.Library.Internal.Security.Models.AccessPolicy;
public class GroupMembershipRequirement : IAuthorizationRequirement
{
public IReadOnlyCollection<string> Groups { get; }
public GroupMembershipRequirement(params string[] groups)
{
Groups = groups;
}
}
@@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace LCU.Library.Internal.Security.Models.AuthRequest
{
public class AuthRequest
{
[Required] public string UserName { get; set; }
[Required] public string Password { get; set; }
}
}
@@ -0,0 +1,9 @@
namespace LCU.Library.Internal.Security.Models.Configuration;
public class AzureActiveDirectoryOptions
{
public string ClientId { get; set; }
public string Instance { get; set; }
public string TenantId { get; set; }
public string ValidAudience { get; set; }
}
@@ -0,0 +1,10 @@
namespace LCU.Library.Internal.Security.Models.Configuration;
public class AzureAdJwtRetrievalConfiguration
{
public string AuthenticationUrl { get; set; }
public string Role { get; set; }
public string Scope { get; set; }
public string ClientId { get; set; }
public string ClientSecret { get; set; }
}
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Title>LCU.Library.Internal.Security</Title>
<Authors>Landmark Credit Union</Authors>
<RepositoryUrl>https://landmarkcu.visualstudio.com/Platform/_git/LCU.Library.Internal.Security</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<Company>Landmark Credit Union</Company>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<LangVersion>latest</LangVersion>
<FileVersion>1.2.3</FileVersion>
<AssemblyVersion>1.2.3</AssemblyVersion>
<PackageVersion>1.2.3</PackageVersion>
<Description>
1.2.3 - Model Lib for LCU API Security Library
</Description>
<PackageReleaseNotes>
1.2.3 - Model Lib for LCU API Security Library
</PackageReleaseNotes>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="3.1.12" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="9.0.2" />
</ItemGroup>
<ItemGroup>
<Folder Include="AuthRequest\" />
</ItemGroup>
</Project>
@@ -0,0 +1,21 @@
using System.Text.Json.Serialization;
namespace LCU.Library.Internal.Security.Models.Response;
public class AzureAdAuthorizationResponse
{
[JsonPropertyName("token_type")]
public string TokenType { get; set; }
[JsonPropertyName("scope")]
public string Scope { get; set; }
[JsonPropertyName("expires_in")]
public long ExpiresIn { get; set; }
[JsonPropertyName("ext_expires_in")]
public long ExtExpiresIn { get; set; }
[JsonPropertyName("access_token")]
public string AccessToken { get; set; }
}