Compare commits

..

2 Commits

3 changed files with 59 additions and 67 deletions

View File

@@ -13,68 +13,8 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="1ac72a4a-52ad-4e70-9b15-c330b1ed3e7a" name="Changes" comment=""> <list default="true" id="1ac72a4a-52ad-4e70-9b15-c330b1ed3e7a" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/src/API/Controllers/AuthController.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/API/Controllers/UserController.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/API/Extension/ResultExtension.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Common/Results/Error.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Common/Results/ErrorTypeConstant.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Common/Results/Result.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Common/Results/TResult.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/DTOs/PagedResult.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/DTOs/ResetPasswordDto.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/DTOs/UserDto.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Errors/AuthError.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Errors/UserError.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Extensions/ServiceCollectionExtensions.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Interfaces/IAuthenticationService.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Interfaces/IEmailService.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Interfaces/IJwtService.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Interfaces/IUserService.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Models/AssingRoleRequest.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Models/EmailRequest.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Models/LoginRequest.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Models/RefreshTokenRequest.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Models/RegisterRequest.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Models/TokenResponse.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Models/UserUpdateRequest.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Services/AuthenticationService.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Services/EmailService.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Services/JwtService.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Services/UserService.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Validators/LoginRequestValidator.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Validators/RegisterRequestValidator.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Application/Validators/UserUpdateRequestValidator.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/ClientApp/package-lock.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Domain/Entities/Role.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Domain/Entities/User.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Domain/Entities/UserRole.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Domain/Interface/IGenericRepository.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Domain/Interface/IUnitOfWork.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Domain/Interface/IUserRepository.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Domain/Interface/IUserRoleRepository.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Configuration/RoleConfiguration.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Configuration/UserConfiguration.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Configuration/UserRoleConfiguration.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Context/ApplicationDbContext.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Context/ApplicationDbContextFactory.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Extensions/ServiceCollectionExtensions.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Migrations/20260206104345_InitialCreate.Designer.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Migrations/20260206104345_InitialCreate.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Migrations/ApplicationDbContextModelSnapshot.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Repositories/GenericRepository.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Repositories/UnitOfWork.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Repositories/UserRepository.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Repositories/UserRoleRepository.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Utilities/EmailBody.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Utilities/GenerateRefreshTokenHelper.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/Infrastructure/Utilities/PostgreSqlSettings.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.DotNetAngular/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.DotNetAngular/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.DotNetAngular/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.DotNetAngular/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/API/API.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/src/API/API.csproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/API/Extension/ServiceCollectionExtensions.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/API/Extension/ServiceCollectionExtensions.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/API/Extension/ServiceCollectionExtensions.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/API/Extension/ServiceCollectionExtensions.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/API/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/API/Program.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/API/appsettings.json" beforeDir="false" afterPath="$PROJECT_DIR$/src/API/appsettings.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Application/Application.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/src/Application/Application.csproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/Infrastructure/Infrastructure.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/src/Infrastructure/Infrastructure.csproj" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -91,7 +31,7 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$" value="develop" /> <entry key="$PROJECT_DIR$" value="feature/nuget" />
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@@ -122,14 +62,14 @@
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;, &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;RunOnceActivity.typescript.service.memoryLimit.init&quot;: &quot;true&quot;, &quot;RunOnceActivity.typescript.service.memoryLimit.init&quot;: &quot;true&quot;,
&quot;com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1&quot;: &quot;true&quot;, &quot;com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;feature/dotnet&quot;, &quot;git-widget-placeholder&quot;: &quot;develop&quot;,
&quot;junie.onboarding.icon.badge.shown&quot;: &quot;true&quot;, &quot;junie.onboarding.icon.badge.shown&quot;: &quot;true&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;, &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;, &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;, &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;, &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;vcs.Git&quot;, &quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
&quot;to.speed.mode.migration.done&quot;: &quot;true&quot;, &quot;to.speed.mode.migration.done&quot;: &quot;true&quot;,
&quot;ts.external.directory.path&quot;: &quot;/home/natlinux/RiderProjects/DotNetAngular/src/ClientApp/node_modules/typescript/lib&quot;, &quot;ts.external.directory.path&quot;: &quot;/home/natlinux/RiderProjects/DotNetAngular/src/ClientApp/node_modules/typescript/lib&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot; &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
@@ -270,6 +210,9 @@
<workItem from="1771239672703" duration="359000" /> <workItem from="1771239672703" duration="359000" />
<workItem from="1771331713319" duration="2451000" /> <workItem from="1771331713319" duration="2451000" />
<workItem from="1771503996420" duration="1283000" /> <workItem from="1771503996420" duration="1283000" />
<workItem from="1772664092787" duration="54000" />
<workItem from="1772664174287" duration="646000" />
<workItem from="1773053172796" duration="1432000" />
</task> </task>
<task id="LOCAL-00001" summary="updating template"> <task id="LOCAL-00001" summary="updating template">
<option name="closed" value="true" /> <option name="closed" value="true" />
@@ -303,7 +246,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1770318472632</updated> <updated>1770318472632</updated>
</task> </task>
<option name="localTasksCounter" value="5" /> <task id="LOCAL-00005" summary="update nuget packages to new versions">
<option name="closed" value="true" />
<created>1771506336945</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1771506336945</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@@ -343,7 +294,8 @@
<MESSAGE value="update to angular 20" /> <MESSAGE value="update to angular 20" />
<MESSAGE value="login.component, register.component" /> <MESSAGE value="login.component, register.component" />
<MESSAGE value="update to dotnet 10" /> <MESSAGE value="update to dotnet 10" />
<option name="LAST_COMMIT_MESSAGE" value="update to dotnet 10" /> <MESSAGE value="update nuget packages to new versions" />
<option name="LAST_COMMIT_MESSAGE" value="update nuget packages to new versions" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>

View File

@@ -11,6 +11,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.3" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="10.0.3" /> <PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="10.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="10.1.4" /> <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="10.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.1.4" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="10.1.4" />

View File

@@ -1,3 +1,6 @@
using System.Text;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using Microsoft.OpenApi; using Microsoft.OpenApi;
namespace API.Extension; namespace API.Extension;
@@ -5,7 +8,7 @@ namespace API.Extension;
public static class ServiceCollectionExtensions public static class ServiceCollectionExtensions
{ {
public static IServiceCollection AddWebServices(this IServiceCollection services, public static IServiceCollection AddWebServices(this IServiceCollection services,
ConfigurationManager builderConfiguration) IConfiguration configuration)
{ {
services.AddSwaggerGen(options => services.AddSwaggerGen(options =>
{ {
@@ -13,7 +16,43 @@ public static class ServiceCollectionExtensions
options.SwaggerDoc("v1", new OpenApiInfo { Title = "DotNetAngular API", Version = "v1" }); options.SwaggerDoc("v1", new OpenApiInfo { Title = "DotNetAngular API", Version = "v1" });
// update names of the api // update names of the api
options.SwaggerGeneratorOptions.DocumentFilters.Add(new LowerCaseDocumentFilter()); options.SwaggerGeneratorOptions.DocumentFilters.Add(new LowerCaseDocumentFilter());
// configure JWT authentication
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Name = "Authorization",
Type = SecuritySchemeType.Http,
Scheme = "Bearer",
BearerFormat = "JWT",
In = ParameterLocation.Header,
Description =
"JWT Authorization header using the Bearer scheme. Enter your token in the text input below."
});
options.AddSecurityRequirement(doc =>
{
var schemeRef = new OpenApiSecuritySchemeReference("Bearer", doc);
return new OpenApiSecurityRequirement
{
{ schemeRef, new List<string>() }
};
});
});
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = configuration["Jwt:Issuer"],
ValidAudience = configuration["Jwt:Audience"],
IssuerSigningKey = new SymmetricSecurityKey
(Encoding.UTF8.GetBytes(configuration["Jwt:Key"] ??
throw new InvalidOperationException("Jwt:Key is not configured"))),
ClockSkew = TimeSpan.Zero // remove delay of token expiration time
};
}); });
return services; return services;
} }