Skip to content

Commit

Permalink
Merge branch 'dev' into Feat/StartPlanningWithTDD
Browse files Browse the repository at this point in the history
  • Loading branch information
RondineleG committed Sep 14, 2023
2 parents 1768738 + d05afe6 commit 60552dc
Show file tree
Hide file tree
Showing 105 changed files with 3,278 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Browl.sln
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Browl.Service.MarketDataCol
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Browl.Client.Test", "test\Presentation\Browl.Client.Test\Browl.Client.Test.csproj", "{72694572-0D50-4A39-A657-73133F074AF7}"
EndProject
<<<<<<< HEAD
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Browl.Service.MarketDataCollector.FakeData", "test\Services\Browl.Service.MarketDataCollector.Test\Browl.Service.MarketDataCollector.FakeData\Browl.Service.MarketDataCollector.FakeData.csproj", "{7A01F807-7685-48FB-BAD0-9303E96A53B5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FakeData", "FakeData", "{361920A2-8B95-47B1-AA42-C9ADD6D28D23}"
=======
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Browl.Service.MarketDataCollector.FakeData", "test\Services\Browl.Service.MarketDataCollector.Test\Browl.Service.MarketDataCollector.FakeData\Browl.Service.MarketDataCollector.FakeData.csproj", "{7A01F807-7685-48FB-BAD0-9303E96A53B5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "FakeData", "FakeData", "{361920A2-8B95-47B1-AA42-C9ADD6D28D23}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Browl.Service.AuthSecurity", "Browl.Service.AuthSecurity", "{09EE67D6-ADE1-4A0A-8766-974D00A71209}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Browl.Service.AuthSecurity.API", "src\Services\Browl.Service.AuthSecurity\Browl.Service.AuthSecurity.API\Browl.Service.AuthSecurity.API.csproj", "{051A7F26-D824-420B-B642-741C6CD41F13}"
>>>>>>> dev
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -138,6 +148,13 @@ Global
{7A01F807-7685-48FB-BAD0-9303E96A53B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7A01F807-7685-48FB-BAD0-9303E96A53B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7A01F807-7685-48FB-BAD0-9303E96A53B5}.Release|Any CPU.Build.0 = Release|Any CPU
<<<<<<< HEAD
=======
{051A7F26-D824-420B-B642-741C6CD41F13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{051A7F26-D824-420B-B642-741C6CD41F13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{051A7F26-D824-420B-B642-741C6CD41F13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{051A7F26-D824-420B-B642-741C6CD41F13}.Release|Any CPU.Build.0 = Release|Any CPU
>>>>>>> dev
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -164,6 +181,11 @@ Global
{72694572-0D50-4A39-A657-73133F074AF7} = {1B3CDB1E-8F3E-4900-A61F-B13C974872FF}
{7A01F807-7685-48FB-BAD0-9303E96A53B5} = {361920A2-8B95-47B1-AA42-C9ADD6D28D23}
{361920A2-8B95-47B1-AA42-C9ADD6D28D23} = {DB8F8AA6-A0F4-487D-B807-787C5117DD35}
<<<<<<< HEAD
=======
{09EE67D6-ADE1-4A0A-8766-974D00A71209} = {758EAD6C-01B5-4816-97E5-CA0E5F217D34}
{051A7F26-D824-420B-B642-741C6CD41F13} = {09EE67D6-ADE1-4A0A-8766-974D00A71209}
>>>>>>> dev
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {09C8AF50-40D4-48F2-A03D-9BC7AB6D3538}
Expand Down
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "7.0.306"
}
}
6 changes: 6 additions & 0 deletions src/Presentation/Browl.Client/Browl.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<<<<<<< HEAD
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="npm install" />
<Exec Command="npm run buildcss" />
=======
<Target Name="PostBuild">
<Exec Command="npm install" />
<Exec Command="npm run buildcss" />
>>>>>>> dev
</Target>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand Down
2 changes: 1 addition & 1 deletion src/Presentation/Browl.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

builder.Services.AddScoped(sp => new HttpClient
{
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress)
});
builder.Services.AddMudServices();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.32.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
namespace Browl.Service.AuthSecurity.API.Configuration;

public static class ApiConfig
{
public static IServiceCollection AddApiConfiguration(this IServiceCollection services, IWebHostEnvironment hostEnvironment)
{
_ = services.AddControllers();

IConfigurationBuilder builder = new ConfigurationBuilder()
.SetBasePath(hostEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{hostEnvironment.EnvironmentName}.json", true, true)
.AddEnvironmentVariables();

if (hostEnvironment.IsDevelopment())
{
_ = builder.AddUserSecrets<Program>();
}

return services;
}

public static IApplicationBuilder UseApiConfiguration(this IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
IApplicationBuilder unused5 = app.UseDeveloperExceptionPage();
}

IApplicationBuilder unused4 = app.UseHttpsRedirection();

IApplicationBuilder unused3 = app.UseRouting();

IApplicationBuilder unused2 = app.UseIdentityConfiguration();

IApplicationBuilder unused1 = app.UseEndpoints(endpoints =>
{
ControllerActionEndpointConventionBuilder unused = endpoints.MapControllers();
});

return app;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Browl.Service.AuthSecurity.API.Data;
using Browl.Service.AuthSecurity.Domain.Entities;

using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;

namespace Browl.Service.AuthSecurity.API.Configuration;

public static class DatabaseConfig
{

public static IServiceCollection AddDatabaseConfiguration(this IServiceCollection services, IConfiguration configuration)
{
services.AddDbContext<BrowlAuthSecurityDbContext>(options => options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")));

services.AddIdentity<User, IdentityRole>()
.AddEntityFrameworkStores<BrowlAuthSecurityDbContext>()
.AddDefaultUI()
.AddDefaultTokenProviders();

return services;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using Browl.Service.AuthSecurity.API.Data;
using Browl.Service.AuthSecurity.API.Entities;

using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.IdentityModel.Tokens;

using System.Text;

namespace Browl.Service.AuthSecurity.API.Configuration;

public static class IdentityConfig
{
public static IServiceCollection AddIdentityConfiguration(this IServiceCollection services,
IConfiguration configuration)
{
IServiceCollection unused3 = services.AddDbContext<BrowlAuthSecurityDbContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("DefaultConnection")));

IdentityBuilder unused2 = services.AddDefaultIdentity<IdentityUser>()
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<BrowlAuthSecurityDbContext>()
.AddDefaultTokenProviders();

// JWT

IConfigurationSection appSettingsSection = configuration.GetSection("AppSettings");
IServiceCollection unused1 = services.Configure<AppSettings>(appSettingsSection);

AppSettings? appSettings = appSettingsSection.Get<AppSettings>();
byte[] key = Encoding.ASCII.GetBytes(appSettings.Secret);

Microsoft.AspNetCore.Authentication.AuthenticationBuilder unused = services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(bearerOptions =>
{
bearerOptions.RequireHttpsMetadata = true;
bearerOptions.SaveToken = true;
bearerOptions.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(key),
ValidateIssuer = true,
ValidateAudience = true,
ValidAudience = appSettings.ValidOn,
ValidIssuer = appSettings.Issuer
};
});

return services;
}



public static IServiceCollection AddJWConfiguration(this IServiceCollection services, IConfiguration configuration)
{
services.AddAuthentication(x =>
{
x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(o =>
{
var Key = Encoding.UTF8.GetBytes(configuration["JWT:Key"]);
o.SaveToken = true;
o.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = false,
ValidateAudience = false,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = configuration["JWT:Issuer"],
ValidAudience = configuration["JWT:Audience"],
IssuerSigningKey = new SymmetricSecurityKey(Key)
};
});

return services;
}

public static IApplicationBuilder UseIdentityConfiguration(this IApplicationBuilder app)
{
_ = app.UseAuthentication();
_ = app.UseAuthorization();

return app;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Microsoft.OpenApi.Models;

namespace Browl.Service.AuthSecurity.API.Configuration;

public static class SwaggerConfig
{
public static IServiceCollection AddSwaggerConfiguration(this IServiceCollection services)
{
IServiceCollection unused = services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo()
{
Title = "Browl Service AuthSecurity API",
Description = "This API guarantees the security and proper authentication of users in the application.",
Contact = new OpenApiContact() { Name = "Rondinele Guimarães", Email = "[email protected]" },
License = new OpenApiLicense() { Name = "MIT", Url = new Uri("https://opensource.org/licenses/MIT") }
});
});

return services;
}

public static IApplicationBuilder UseSwaggerConfiguration(this IApplicationBuilder app)
{
IApplicationBuilder unused1 = app.UseSwagger();
IApplicationBuilder unused = app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
});

return app;
}
}
Loading

0 comments on commit 60552dc

Please sign in to comment.