Skip to content

Commit e5936d0

Browse files
Oidc init
1 parent 1f26f5b commit e5936d0

19 files changed

+35
-35
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using Microsoft.AspNetCore.Authorization;
2+
3+
namespace Authentication;
4+
5+
/// <summary>
6+
/// Аутентификация по хэдерам
7+
/// </summary>
8+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
9+
public class AuthAttribute : AuthorizeAttribute
10+
{
11+
public AuthAttribute()
12+
{
13+
AuthenticationSchemes = AuthSchemeNames.Headers;
14+
}
15+
}

backend/Authentication/AuthSchemeNames.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ namespace Authentication;
22

33
public static class AuthSchemeNames
44
{
5-
public const string Ldap = "ldap";
5+
public const string Headers = "headers";
66
}

backend/Authentication/LdapAuthAttribute.cs

Lines changed: 0 additions & 15 deletions
This file was deleted.

backend/Authentication/ServiceCollectionExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ namespace Authentication;
55

66
public static class ServiceCollectionExtensions
77
{
8-
public static AuthenticationBuilder AddLdapAuth(this IServiceCollection services) =>
8+
public static AuthenticationBuilder AddAuthHeaders(this IServiceCollection services) =>
99
services.AddAuthentication()
1010
.AddScheme<AuthenticationSchemeOptions, UserAuthHandler>(
11-
AuthSchemeNames.Ldap, o => { });
11+
AuthSchemeNames.Headers, o => { });
1212
}

backend/Authentication/UserAuthHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ public class UserAuthHandler(
1313
ISystemClock clock)
1414
: AuthenticationHandler<AuthenticationSchemeOptions>(options, logger, encoder, clock)
1515
{
16-
private static readonly string? LdapUserIdKey = Environment.GetEnvironmentVariable("LDAP_USER_ID_KEY");
16+
private static readonly string? UserIdKey = Environment.GetEnvironmentVariable("USER_ID_KEY");
1717

1818
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
1919
{
2020
var headers = Request.Headers;
2121

2222
var userId = string.Empty;
23-
if (!string.IsNullOrEmpty(LdapUserIdKey))
24-
userId = headers[LdapUserIdKey].ToString();
23+
if (!string.IsNullOrEmpty(UserIdKey))
24+
userId = headers[UserIdKey].ToString();
2525

2626
if (string.IsNullOrEmpty(userId))
2727
{

backend/Bugget.DA/Files/EmployeesDataAccess.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private async Task LoadEmployees()
7373
},
7474
new EmployeeObsolete
7575
{
76-
Id = "any-ldap-id",
76+
Id = "any-id-1",
7777
FirstName = "Петр",
7878
LastName = "Петров",
7979
Surname = "Петрович",

backend/Bugget.DA/Files/EmployeesFileClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private static Employee[] GetDefaultEmployees()
6666
},
6767
new Employee
6868
{
69-
Id = "any-ldap-id",
69+
Id = "any-id-1",
7070
Name = "Петров Петр Петрович",
7171
NotificationUserId = "67xpfgxex2da4p5fn8dx17pcnr",
7272
TeamId = "4",

backend/Bugget.Entities/BO/Employee.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Bugget.Entities.BO;
33
public class Employee
44
{
55
/// <summary>
6-
/// Уникальный идентификатор соответствующий хэдеру авторизации LDAP_USER_ID_KEY
6+
/// Уникальный идентификатор соответствующий хэдеру авторизации USER_ID_KEY
77
/// </summary>
88
public required string Id { get; init; }
99

backend/Bugget.Entities/BO/EmployeeObsolete.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ namespace Bugget.Entities.BO;
33
public class EmployeeObsolete
44
{
55
/// <summary>
6-
/// Уникальный идентификатор соответствующий хэдеру авторизации LDAP_USER_ID_KEY
6+
/// Уникальный идентификатор соответствующий хэдеру авторизации USER_ID_KEY
77
/// </summary>
88
public required string Id { get; init; }
99
public string? FirstName { get; init; }

backend/Bugget/Controllers/AttachmentsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace Bugget.Controllers;
1010

11-
[LdapAuth]
11+
[Auth]
1212
[Route("bugget/public/v1/reports/{reportId}/bug/{bugId}/attachments")]
1313
public sealed class AttachmentsController(AttachmentService attachmentService) : ApiController
1414
{

0 commit comments

Comments
 (0)