Bearer-Authentifcation #7
82
.idea/.idea.DotNetAngular/.idea/workspace.xml
generated
82
.idea/.idea.DotNetAngular/.idea/workspace.xml
generated
@@ -13,68 +13,8 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<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$/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/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>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -91,7 +31,7 @@
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="develop" />
|
||||
<entry key="$PROJECT_DIR$" value="feature/nuget" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
@@ -122,14 +62,14 @@
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||
"com.intellij.ml.llm.matterhorn.ej.ui.settings.DefaultModelSelectionForGA.v1": "true",
|
||||
"git-widget-placeholder": "feature/dotnet",
|
||||
"git-widget-placeholder": "develop",
|
||||
"junie.onboarding.icon.badge.shown": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "vcs.Git",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"to.speed.mode.migration.done": "true",
|
||||
"ts.external.directory.path": "/home/natlinux/RiderProjects/DotNetAngular/src/ClientApp/node_modules/typescript/lib",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
@@ -270,6 +210,9 @@
|
||||
<workItem from="1771239672703" duration="359000" />
|
||||
<workItem from="1771331713319" duration="2451000" />
|
||||
<workItem from="1771503996420" duration="1283000" />
|
||||
<workItem from="1772664092787" duration="54000" />
|
||||
<workItem from="1772664174287" duration="646000" />
|
||||
<workItem from="1773053172796" duration="1432000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="updating template">
|
||||
<option name="closed" value="true" />
|
||||
@@ -303,7 +246,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1770318472632</updated>
|
||||
</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 />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -343,7 +294,8 @@
|
||||
<MESSAGE value="update to angular 20" />
|
||||
<MESSAGE value="login.component, register.component" />
|
||||
<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 name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" 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.SwaggerGen" Version="10.1.4" />
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.OpenApi;
|
||||
|
||||
namespace API.Extension;
|
||||
@@ -5,7 +8,7 @@ namespace API.Extension;
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddWebServices(this IServiceCollection services,
|
||||
ConfigurationManager builderConfiguration)
|
||||
IConfiguration configuration)
|
||||
{
|
||||
services.AddSwaggerGen(options =>
|
||||
{
|
||||
@@ -13,7 +16,43 @@ public static class ServiceCollectionExtensions
|
||||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "DotNetAngular API", Version = "v1" });
|
||||
// update names of the api
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user