Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/prod-docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
--set "extraSecretEnvVars.InnerCircleServiceUrls__MailServiceUrl=${{ secrets.DEV_MAIL_SERVICE_URL }}" \
--set "extraSecretEnvVars.InnerCircleServiceUrls__AuthUIServiceUrl=${{ secrets.DEV_AUTH_UI_SERVICE_URL }}" \
--set "extraSecretEnvVars.InnerCircleServiceUrls__AccountsServiceUrl=${{ secrets.DEV_ACCOUNTS_SERVICE_URL }}" \
--set "extraSecretEnvVars.InnerCircleServiceUrls__EmployeesServiceUrl=${{ secrets.DEV_EMPLOYEES_SERVICE_URL }}" \
"${RELEASE_NAME}" \
bitnami/aspnet-core --version 4.4.7
kubeconfig: "${{ secrets.DEV_KUBECONFIG }}"
3 changes: 3 additions & 0 deletions Api/Services/IInnerCircleHttpClient.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using DataAccess.Models;

namespace Api.Services;

public interface IInnerCircleHttpClient
Expand All @@ -6,4 +8,5 @@ public interface IInnerCircleHttpClient
Task SendPasswordResetLink(string email, string token);
Task<List<string>> GetPermissions(long accountId);
Task<long> GetTenantId(long accountId);
Task<Employee> GetEmployeeAsync(string corporateEmail);
}
8 changes: 8 additions & 0 deletions Api/Services/InnerCircleHttpClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text.Json;
using System.Web;
using Api.Services.Options;
using DataAccess.Models;
using Microsoft.Extensions.Options;

namespace Api.Services
Expand Down Expand Up @@ -56,5 +57,12 @@ public async Task<long> GetTenantId(long accountId)
var response = await _client.GetStringAsync(link);
return JsonSerializer.Deserialize<long>(response);
}

public async Task<Employee> GetEmployeeAsync(string corporateEmail)
{
var link = $"{_urls.EmployeesServiceUrl}/internal/get-employee?corporateEmail={corporateEmail}";
var response = await _client.GetStringAsync(link);
return Newtonsoft.Json.JsonConvert.DeserializeObject<Employee>(response);
}
}
}
1 change: 1 addition & 0 deletions Api/Services/Options/InnerCircleServiceUrl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ public class InnerCircleServiceUrls
public string MailServiceUrl { get; set; }
public string AuthUIServiceUrl { get; set; }
public string AccountsServiceUrl { get; set; }
public string EmployeesServiceUrl { get; set; }
}
}
7 changes: 5 additions & 2 deletions Api/Services/Users/UserClaimsProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class UserClaimsProvider : IUserClaimsProvider

private const string CorporateEmailClaimType = "corporateEmail";

private const string EmployeeIdClaimType = "employeeId";

public UserClaimsProvider(
IFindUserQuery userQuery,
ILogger<UserClaimsProvider> logger,
Expand All @@ -33,13 +35,14 @@ public async Task<List<Claim>> GetUserClaimsAsync(string login)
var user = await _userQuery.FindUserByCorporateEmailAsync(login);
var privileges = await _innerCircleHttpClient.GetPermissions(user.AccountId);
var tenantId = await _innerCircleHttpClient.GetTenantId(user.AccountId);
var employee = await _innerCircleHttpClient.GetEmployeeAsync(login);

var claims = new List<Claim>
{
new (NameIdentifierClaimType, login),
new (CorporateEmailClaimType, user.UserName),
new (TenantIdClaimType, tenantId.ToString())

new (TenantIdClaimType, tenantId.ToString()),
new (EmployeeIdClaimType, employee.Id.ToString())
};
privileges.ForEach(x => claims.Add(new Claim(PermissionsClaimType, x.ToString())));

Expand Down
3 changes: 2 additions & 1 deletion Api/appsettings.LocalEnvForDevelopment.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"InnerCircleServiceUrls": {
"MailServiceUrl": "http://inner-circle.local.tourmalinecore.internal/api",
"AuthUIServiceUrl": "http://inner-circle.local.tourmalinecore.internal",
"AccountsServiceUrl": "http://inner-circle.local.tourmalinecore.internal"
"AccountsServiceUrl": "http://inner-circle.local.tourmalinecore.internal",
"EmployeesServiceUrl": "http://inner-circle.local.tourmalinecore.internal"
}
}
3 changes: 2 additions & 1 deletion Api/appsettings.MockForDevelopment.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"InnerCircleServiceUrls": {
"MailServiceUrl": "http://localhost:5005/api",
"AuthUIServiceUrl": "https://localhost:3000",
"AccountsServiceUrl": "http://localhost:5001"
"AccountsServiceUrl": "http://localhost:5001",
"EmployeesServiceUrl": "http://localhost:5006"
}
}
3 changes: 2 additions & 1 deletion Api/appsettings.MockForPullRequest.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"InnerCircleServiceUrls": {
"MailServiceUrl": "http://mockServer:1080/api",
"AuthUIServiceUrl": "https://localhost:3000",
"AccountsServiceUrl": "http://mockServer:1080"
"AccountsServiceUrl": "http://mockServer:1080",
"EmployeesServiceUrl": "http://mockServer:1080"
}
}
3 changes: 2 additions & 1 deletion Api/appsettings.ProdForDeployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"InnerCircleServiceUrls": {
"MailServiceUrl": "**secret**",
"AuthUIServiceUrl": "**secret**",
"AccountsServiceUrl": "**secret**"
"AccountsServiceUrl": "**secret**",
"EmployeesServiceUrl": "**secret**"
}
}
3 changes: 2 additions & 1 deletion Api/appsettings.ProdForDevelopment.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"InnerCircleServiceUrls": {
"MailServiceUrl": "not_completed_yet",
"AuthUIServiceUrl": "not_completed_yet",
"AccountsServiceUrl": "not_completed_yet"
"AccountsServiceUrl": "not_completed_yet",
"EmployeesServiceUrl": "not_completed_yet"
}
}
6 changes: 6 additions & 0 deletions DataAccess/Models/Employee.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace DataAccess.Models;

public class Employee
{
public long Id { get; set; }
}