Skip to content

Commit a35eca5

Browse files
Implement Codebreaker.Identity library and core components
Co-authored-by: christiannagel <1908285+christiannagel@users.noreply.github.com>
1 parent 0d1dc0a commit a35eca5

10 files changed

Lines changed: 423 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
14+
<PackageReference Include="xunit" />
15+
<PackageReference Include="xunit.runner.visualstudio">
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
<PrivateAssets>all</PrivateAssets>
18+
</PackageReference>
19+
<PackageReference Include="coverlet.collector">
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
<PrivateAssets>all</PrivateAssets>
22+
</PackageReference>
23+
<PackageReference Include="Moq" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<ProjectReference Include="..\Codebreaker.Identity\Codebreaker.Identity.csproj" />
28+
</ItemGroup>
29+
30+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
global using Xunit;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Codebreaker.Identity.Tests;
2+
3+
public class UnitTest1
4+
{
5+
[Fact]
6+
public void Test1()
7+
{
8+
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Codebreaker.Identity;
2+
3+
public class Class1
4+
{
5+
6+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.Graph" />
11+
<PackageReference Include="Microsoft.Extensions.Options" />
12+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
13+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
14+
<PackageReference Include="Azure.Identity" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace Codebreaker.Identity.Configuration;
2+
3+
/// <summary>
4+
/// Configuration options for anonymous users
5+
/// </summary>
6+
public class AnonymousUserOptions
7+
{
8+
/// <summary>
9+
/// Gets or sets the tenant ID for the Azure AD tenant
10+
/// </summary>
11+
public string TenantId { get; set; } = string.Empty;
12+
13+
/// <summary>
14+
/// Gets or sets the client ID for the Azure AD application used for graph operations
15+
/// </summary>
16+
public string ClientId { get; set; } = string.Empty;
17+
18+
/// <summary>
19+
/// Gets or sets the client secret for the Azure AD application
20+
/// </summary>
21+
public string ClientSecret { get; set; } = string.Empty;
22+
23+
/// <summary>
24+
/// Gets or sets the domain for anonymous users
25+
/// </summary>
26+
public string Domain { get; set; } = string.Empty;
27+
28+
/// <summary>
29+
/// Gets or sets the password policy for anonymous users
30+
/// </summary>
31+
public string PasswordPolicy { get; set; } = string.Empty;
32+
33+
/// <summary>
34+
/// Gets or sets the password length for anonymous users
35+
/// </summary>
36+
public int PasswordLength { get; set; } = 12;
37+
38+
/// <summary>
39+
/// Gets or sets the user name prefix for anonymous users
40+
/// </summary>
41+
public string UserNamePrefix { get; set; } = "anon";
42+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using Codebreaker.Identity.Configuration;
2+
using Codebreaker.Identity.Services;
3+
using Microsoft.Extensions.DependencyInjection;
4+
5+
namespace Codebreaker.Identity.Extensions;
6+
7+
/// <summary>
8+
/// Extension methods to configure Codebreaker.Identity services
9+
/// </summary>
10+
public static class ServiceCollectionExtensions
11+
{
12+
/// <summary>
13+
/// Adds the anonymous user service to the service collection
14+
/// </summary>
15+
/// <param name="services">The service collection</param>
16+
/// <returns>The service collection</returns>
17+
public static IServiceCollection AddAnonymousUserService(this IServiceCollection services)
18+
{
19+
services.AddScoped<IAnonymousUserService, GraphAnonymousUserService>();
20+
return services;
21+
}
22+
23+
/// <summary>
24+
/// Adds the anonymous user service to the service collection with configuration
25+
/// </summary>
26+
/// <param name="services">The service collection</param>
27+
/// <param name="configureOptions">The configuration action</param>
28+
/// <returns>The service collection</returns>
29+
public static IServiceCollection AddAnonymousUserService(
30+
this IServiceCollection services,
31+
Action<AnonymousUserOptions> configureOptions)
32+
{
33+
services.Configure(configureOptions);
34+
services.AddScoped<IAnonymousUserService, GraphAnonymousUserService>();
35+
return services;
36+
}
37+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace Codebreaker.Identity.Models;
2+
3+
/// <summary>
4+
/// Represents an anonymous user with access credentials
5+
/// </summary>
6+
public class AnonymousUser
7+
{
8+
/// <summary>
9+
/// Gets or sets the user's unique identifier
10+
/// </summary>
11+
public string Id { get; set; } = string.Empty;
12+
13+
/// <summary>
14+
/// Gets or sets the user name
15+
/// </summary>
16+
public string UserName { get; set; } = string.Empty;
17+
18+
/// <summary>
19+
/// Gets or sets the display name
20+
/// </summary>
21+
public string DisplayName { get; set; } = string.Empty;
22+
23+
/// <summary>
24+
/// Gets or sets the email address
25+
/// </summary>
26+
public string Email { get; set; } = string.Empty;
27+
28+
/// <summary>
29+
/// Gets or sets the password
30+
/// </summary>
31+
public string Password { get; set; } = string.Empty;
32+
33+
/// <summary>
34+
/// Gets or sets the creation date
35+
/// </summary>
36+
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
37+
38+
/// <summary>
39+
/// Gets or sets the last login date
40+
/// </summary>
41+
public DateTimeOffset? LastLoginAt { get; set; }
42+
}

0 commit comments

Comments
 (0)