- Timestamp:
- 10/28/25 10:44:31 (11 months ago)
- Branches:
- master
- Children:
- 43459e1, ff7f308
- Parents:
- c11d3a3 (diff), 1e58098 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Boris Gjorgjievski <69085722+imbrsk@…> (10/28/25 10:44:31)
- git-committer:
- GitHub <noreply@…> (10/28/25 10:44:31)
- Location:
- iknow-api
- Files:
-
- 17 added
- 2 deleted
- 3 edited
-
Controllers/AuthController.cs (added)
-
Controllers/WeatherForecastController.cs (deleted)
-
DTOs/RefreshTokenDTO.cs (added)
-
DTOs/UserDTO.cs (added)
-
Data/AppDbContext.cs (added)
-
Migrations/20251028091953_new.Designer.cs (added)
-
Migrations/20251028091953_new.cs (added)
-
Migrations/AppDbContextModelSnapshot.cs (added)
-
Models/RefreshToken.cs (added)
-
Models/User.cs (added)
-
Program.cs (modified) (2 diffs)
-
Repository/Implementations/RefreshTokenRepository.cs (added)
-
Repository/Implementations/UserRepository.cs (added)
-
Repository/Interface/IRefreshTokenRepository.cs (added)
-
Repository/Interface/IUserRepository.cs (added)
-
Services/Implementations/AuthService.cs (added)
-
Services/Implementations/RefreshTokenService.cs (added)
-
Services/Interfaces/IAuthService.cs (added)
-
Services/Interfaces/IRefreshTokenService.cs (added)
-
WeatherForecast.cs (deleted)
-
appsettings.json (modified) (1 diff)
-
iknow-api.csproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
iknow-api/Program.cs
rc11d3a3 r7a1fe00 1 using System.Text; 2 using iknow_api.Data; 3 using iknow_api.Repositories; 4 using iknow_api.Services; 5 using Microsoft.AspNetCore.Authentication.JwtBearer; 6 using Microsoft.EntityFrameworkCore; 7 using Microsoft.IdentityModel.Tokens; 8 1 9 var builder = WebApplication.CreateBuilder(args); 10 builder.Services.AddAuthentication(options => 11 { 12 options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; 13 options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; 14 }) 15 .AddJwtBearer(options => 16 { 17 options.RequireHttpsMetadata = false; // only for development 18 options.SaveToken = true; 19 options.TokenValidationParameters = new TokenValidationParameters 20 { 21 ValidateIssuer = true, 22 ValidIssuer = "iknow-api", 2 23 24 ValidateAudience = true, 25 ValidAudience = "iknow-api", 26 27 ValidateLifetime = true, 28 29 ValidateIssuerSigningKey = true, 30 IssuerSigningKey = new SymmetricSecurityKey( 31 Encoding.UTF8.GetBytes(builder.Configuration["Jwt:Key"])) 32 }; 33 }); 3 34 // Add services to the container. 4 5 35 builder.Services.AddControllers(); 6 // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi7 36 builder.Services.AddOpenApi(); 8 37 38 // Register DbContext 39 builder.Services.AddDbContext<AppDbContext>(options => 40 options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection"))); 41 42 // Register your services 43 builder.Services.AddScoped<IAuthService, AuthService>(); 44 builder.Services.AddScoped<IRefreshTokenService, RefreshTokenService>(); 45 builder.Services.AddScoped<IUserRepository, UserRepository>(); 46 builder.Services.AddScoped<IRefreshTokenRepository, RefreshTokenRepository>(); 47 builder.Services.AddAuthorization(); 9 48 var app = builder.Build(); 10 49 … … 16 55 17 56 app.UseHttpsRedirection(); 18 57 app.UseAuthentication(); // <-- must come BEFORE UseAuthorization 19 58 app.UseAuthorization(); 20 21 59 app.MapControllers(); 22 60 -
iknow-api/appsettings.json
rc11d3a3 r7a1fe00 6 6 } 7 7 }, 8 "AllowedHosts": "*" 8 "ConnectionStrings": { 9 "DefaultConnection": "Host=localhost;Port=55432;Database=myappdb;Username=postgres;Password=REDACTED_ROTATE_ME" 10 }, 11 "Jwt": { 12 "Key": "REDACTED_SET_VIA_USER_SECRETS" 13 } 9 14 } -
iknow-api/iknow-api.csproj
rc11d3a3 r7a1fe00 9 9 10 10 <ItemGroup> 11 <PackageReference Include="BCrypt.Net-Next" Version="4.0.3" /> 12 <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.10" /> 11 13 <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.9" /> 14 <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.10"> 15 <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> 16 <PrivateAssets>all</PrivateAssets> 17 </PackageReference> 18 <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" /> 19 <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.14.0" /> 12 20 </ItemGroup> 13 21
Note:
See TracChangeset
for help on using the changeset viewer.
