-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backend integration with Keycloak tokens.
- Loading branch information
Showing
24 changed files
with
552 additions
and
627 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace api.Constants; | ||
|
||
public static class ErrorMessages | ||
{ | ||
public const string UserAlreadyExists = "User already exists"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
using Microsoft.AspNetCore.Identity; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace api.Data.DAO; | ||
|
||
public class UserModel : IdentityUser | ||
public class UserModel | ||
{ | ||
[Key] | ||
public int Id { get; set; } | ||
public required string KeycloakUuid { get; set; } | ||
[EmailAddress] | ||
public required string Email { get; set; } | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
backend/src/api/Data/JwtOptions.cs → backend/src/api/Data/KeycloakJwtOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Serilog; | ||
using Serilog.Configuration; | ||
using Serilog.Core; | ||
using Serilog.Events; | ||
|
||
namespace api; | ||
|
||
public static class LoggingExtensions | ||
{ | ||
public static LoggerConfiguration WithCorrelationId(this LoggerEnrichmentConfiguration config) | ||
=> config.With(new CorrelationIdEnricher()); | ||
} | ||
|
||
public class CorrelationIdEnricher : ILogEventEnricher | ||
{ | ||
private const string _propertyName = "CorelationId"; | ||
private readonly IHttpContextAccessor _contextAccessor; | ||
|
||
public CorrelationIdEnricher() | ||
{ | ||
_contextAccessor = new HttpContextAccessor(); | ||
} | ||
|
||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) | ||
{ | ||
var httpContext = _contextAccessor.HttpContext; | ||
if (httpContext == null) | ||
{ | ||
return; | ||
} | ||
|
||
if (httpContext.Items[_propertyName] is LogEventProperty logEventProperty) | ||
{ | ||
logEvent.AddPropertyIfAbsent(logEventProperty); | ||
return; | ||
} | ||
|
||
var correlationId = Guid.NewGuid().ToString(); | ||
|
||
var correlationIdProperty = new LogEventProperty(_propertyName, new ScalarValue(correlationId)); | ||
logEvent.AddOrUpdateProperty(correlationIdProperty); | ||
|
||
httpContext.Items.Add(_propertyName, correlationIdProperty); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
backend/src/api/Migrations/20240214220927_KeycloakUser.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.