Browse Source

Merge pull request #195 from abpframework/rel-1.1

Merge rel-1.1 to main
pull/199/head
Halil İbrahim Kalkan 3 years ago
committed by GitHub
parent
commit
9ae6c2d480
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .gitignore
  2. 2
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Toolbar/Cart/Default.cshtml
  3. 2
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs
  4. 33
      apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserBasketProvider.cs
  5. 2
      build/build-images-locally.sh
  6. 12
      etc/README.md
  7. 4
      etc/k8s/azure/scripts/push-images-ghcr.sh
  8. 29
      etc/k8s/azure/values.azure.yaml
  9. 4
      etc/k8s/eshoponabp/charts/mongodb/templates/mongodb-deployment.yaml
  10. 2
      etc/k8s/eshoponabp/charts/mongodb/values.yaml
  11. 4
      etc/k8s/eshoponabp/charts/postgres/templates/postgres-deployment.yaml
  12. 2
      etc/k8s/eshoponabp/charts/postgres/values.yaml
  13. 2
      etc/k8s/eshoponabp/charts/rabbitmq/values.yaml
  14. 2
      etc/k8s/eshoponabp/charts/redis/values.yaml
  15. 24
      etc/k8s/eshoponabp/values.yaml
  16. 29
      services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/Handlers/CustomerRoleCreationHandler.cs
  17. 1
      services/identity/src/EShopOnAbp.IdentityService.Domain/IdentityServiceDbProperties.cs
  18. 51
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityPublicRoleDataSeeder.cs
  19. 29
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/Handlers/IdentityUserCreationHandler.cs

2
.gitignore

@ -355,3 +355,5 @@ MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
.angular

2
apps/public-web/src/EShopOnAbp.PublicWeb/Components/Toolbar/Cart/Default.cshtml

@ -10,7 +10,7 @@
@if (Model == null)
{
<span class="cart-error" style="vertical-align: -webkit-baseline-middle;color: white">@L["Toolbar:BasketNotLoaded"] </span>
<span class="cart-error" style="vertical-align: initial;color: white">@L["Toolbar:BasketNotLoaded"] </span>
}
else
{

2
apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs

@ -305,7 +305,7 @@ public class EShopOnAbpPublicWebModule : AbpModule
app.UseAuthentication();
app.UseAbpSerilogEnrichers();
app.UseAuthorization();
app.UseAnonymousUser();
// app.UseAnonymousUser();
app.UseConfiguredEndpoints(endpoints =>
{
endpoints.MapReverseProxy();

33
apps/public-web/src/EShopOnAbp.PublicWeb/ServiceProviders/UserBasketProvider.cs

@ -3,7 +3,6 @@ using System.Threading.Tasks;
using EShopOnAbp.BasketService.Services;
using EShopOnAbp.Shared.Hosting.AspNetCore;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Volo.Abp.DependencyInjection;
namespace EShopOnAbp.PublicWeb.ServiceProviders
@ -13,34 +12,40 @@ namespace EShopOnAbp.PublicWeb.ServiceProviders
private HttpContext HttpContext => _httpContextAccessor.HttpContext;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly ILogger<UserBasketProvider> _logger;
private readonly IBasketAppService _basketAppService;
public UserBasketProvider(
IHttpContextAccessor httpContextAccessor,
ILogger<UserBasketProvider> logger,
IBasketAppService basketAppService)
{
_httpContextAccessor = httpContextAccessor;
_logger = logger;
_basketAppService = basketAppService;
}
public virtual async Task<BasketDto> GetBasketAsync()
{
try
{
// Get anonymous user id from cookie
HttpContext.Request.Cookies.TryGetValue(EShopConstants.AnonymousUserClaimName,
out string anonymousUserId);
var anonymousUserId = await GetAnonymousUserId();
return await _basketAppService.GetAsync(Guid.Parse(anonymousUserId));
}
catch (Exception ex)
return await _basketAppService.GetAsync(Guid.Parse(anonymousUserId));
}
// Get anonymous user id from cookie
private async Task<string> GetAnonymousUserId()
{
HttpContext.Request.Cookies.TryGetValue(EShopConstants.AnonymousUserClaimName, out string anonymousUserId);
// Generate guid for anonymous user id and set to cookie for 14 days
if (string.IsNullOrEmpty(anonymousUserId))
{
_logger.LogError(ex, ex.Message);
return null;
anonymousUserId = Guid.NewGuid().ToString();
HttpContext.Response.Cookies.Append(EShopConstants.AnonymousUserClaimName, anonymousUserId,
new CookieOptions
{
SameSite = SameSiteMode.Lax,
Expires = DateTimeOffset.UtcNow.AddDays(14)
});
}
return anonymousUserId;
}
}
}

2
build/build-images-locally.sh

@ -1,6 +1,6 @@
#!/bin/bash
export IMAGE_TAG="1.0.0"
export IMAGE_TAG="1.1.0"
export total=12
cd ../
export currentFolder=`pwd`

12
etc/README.md

@ -33,6 +33,18 @@ helm upgrade --install --version=4.0.19 ingress-nginx ingress-nginx/ingress-ngin
127.0.0.1 eshop-st-gateway-web
127.0.0.1 eshop-st-gateway-web-public
````
Once Helm is set up properly, add the repo as follows:
```console
helm repo add eshoponabp https://abpframework.github.io/abp-charts/
```
You can then run `helm search repo eshoponabp` to see the charts.
```console
helm install eshop-st eshoponabp/eshoponabp
```
OR
* Run `build-images.ps1` or `build-images.sh` in the `build` directory.
* Run `deploy-staging.ps1` or `deploy-staging.sh` in the `helm-chart` directory. It is deployed with the `eshop` namespace.

4
etc/k8s/azure/scripts/push-images-ghcr.sh

@ -1,4 +1,4 @@
export version="1.0.0"
export version="latest"
az acr login --name volocr
@ -30,7 +30,7 @@ docker tag eshoponabp/service-catalog:"${version}" ghcr.io/volosoft/eshoponabp/s
docker push ghcr.io/volosoft/eshoponabp/service-catalog:"${version}"
docker tag eshoponabp/service-ordering:"${version}" ghcr.io/volosoft/eshoponabp/service-ordering:"${version}"
docker push ghcr.io/volosoft/eshoponabp/service-ordering:"1.0.1"
docker push ghcr.io/volosoft/eshoponabp/service-ordering:"${version}"
docker tag eshoponabp/service-cmskit:"${version}" ghcr.io/volosoft/eshoponabp/service-cmskit:"${version}"
docker push ghcr.io/volosoft/eshoponabp/service-cmskit:"${version}"

29
etc/k8s/azure/values.azure.yaml

@ -14,6 +14,8 @@ authserver:
redisHost: eshop-az-redis
rabbitmqHost: eshop-az-rabbitmq
elasticsearchHost: eshop-az-elasticsearch
nodeSelector:
agentpool: demopool
ingress:
host: auth.eshoponabp.com
tlsSecret: eshop-wildcard-tls
@ -32,6 +34,8 @@ web:
responseType: "code"
strictDiscoveryDocumentValidation: false
skipIssuerCheck: true
nodeSelector:
agentpool: demopool
ingress:
host: admin.eshoponabp.com
image:
@ -52,7 +56,8 @@ public-web:
redisHost: eshop-az-redis
rabbitmqHost: eshop-az-rabbitmq
elasticsearchHost: eshop-az-elasticsearch
nodeSelector:
agentpool: demopool
ingress:
host: eshoponabp.com
image:
@ -89,6 +94,8 @@ identity:
orderingServiceRootUrl: https://order.eshoponabp.com
cmskitServiceRootUrl: https://cmskit.eshoponabp.com
paymentServiceRootUrl: https://payment.eshoponabp.com
nodeSelector:
agentpool: demopool
ingress:
host: identity.eshoponabp.com
image:
@ -115,7 +122,9 @@ administration:
rabbitmqHost: eshop-az-rabbitmq
elasticsearchHost: eshop-az-elasticsearch
synchedCommunication: # Used for server-to-server (client-credentials) communication with identityService for user permissions
authority: https://auth.eshoponabp.com
authority: https://auth.eshoponabp.com
nodeSelector:
agentpool: demopool
ingress:
host: administration.eshoponabp.com
image:
@ -137,6 +146,8 @@ gateway-web:
redisHost: eshop-az-redis
rabbitmqHost: eshop-az-rabbitmq
elasticsearchHost: eshop-az-elasticsearch
nodeSelector:
agentpool: demopool
ingress:
host: gateway.eshoponabp.com
image:
@ -169,6 +180,8 @@ gateway-web-public:
redisHost: eshop-az-redis
rabbitmqHost: eshop-az-rabbitmq
elasticsearchHost: eshop-az-elasticsearch
nodeSelector:
agentpool: demopool
ingress:
host: gateway-public.eshoponabp.com
image:
@ -211,6 +224,8 @@ basket:
remoteServices:
catalogBaseUrl: http://eshop-az-catalog:80
catalogGrpcUrl: http://eshop-az-catalog:81
nodeSelector:
agentpool: demopool
ingress:
host: basket.eshoponabp.com
image:
@ -262,13 +277,14 @@ ordering:
redisHost: eshop-az-redis
rabbitmqHost: eshop-az-rabbitmq
elasticsearchHost: eshop-az-elasticsearch
nodeSelector:
agentpool: demopool
ingress:
host: order.eshoponabp.com
image:
repository: "ghcr.io/volosoft/eshoponabp/service-ordering"
tag: 1.0.1
# cmskit-service sub-chart override
cmskit:
config:
selfUrl: https://cmskit.eshoponabp.com
@ -312,6 +328,8 @@ payment:
redisHost: eshop-az-redis
rabbitmqHost: eshop-az-rabbitmq
elasticsearchHost: eshop-az-elasticsearch
nodeSelector:
agentpool: demopool
ingress:
host: payment.eshoponabp.com
image:
@ -395,7 +413,8 @@ autoscaling:
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: {}
nodeSelector:
agentpool: demopool
tolerations: []

4
etc/k8s/eshoponabp/charts/mongodb/templates/mongodb-deployment.yaml

@ -31,8 +31,8 @@ spec:
name: {{ .Release.Name }}-{{ .Chart.Name }}-database-volume
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "managed-premium-retain"
storageClassName: "managed-csi"
resources:
requests:
storage: 32Gi
storage: 16Gi
{{- end }}

2
etc/k8s/eshoponabp/charts/mongodb/values.yaml

@ -0,0 +1,2 @@
nodeSelector:
agentpool: demopool

4
etc/k8s/eshoponabp/charts/postgres/templates/postgres-deployment.yaml

@ -34,8 +34,8 @@ spec:
name: {{ .Release.Name }}-{{ .Chart.Name }}-database-volume
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "managed-premium-retain"
storageClassName: "managed-csi"
resources:
requests:
storage: 32Gi
storage: 16Gi
{{- end }}

2
etc/k8s/eshoponabp/charts/postgres/values.yaml

@ -0,0 +1,2 @@
nodeSelector:
agentpool: demopool

2
etc/k8s/eshoponabp/charts/rabbitmq/values.yaml

@ -0,0 +1,2 @@
nodeSelector:
agentpool: demopool

2
etc/k8s/eshoponabp/charts/redis/values.yaml

@ -0,0 +1,2 @@
nodeSelector:
agentpool: demopool

24
etc/k8s/eshoponabp/values.yaml

@ -21,7 +21,7 @@ authserver:
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/app-authserver"
tag: 1.0.0
tag: latest
# web sub-chart override
web:
@ -38,7 +38,7 @@ web:
host: eshop-st-web
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/app-web"
repository: "eshoponabp/app-web"
tag: 1.0.0
# public-web sub-chart override
@ -59,7 +59,7 @@ public-web:
host: eshop-st-public-web
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/app-publicweb"
repository: "eshoponabp/app-publicweb"
tag: 1.0.0
# identity-service sub-chart override
@ -96,7 +96,7 @@ identity:
host: eshop-st-identity
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/service-identity"
repository: "eshoponabp/service-identity"
tag: 1.0.0
# administration sub-chart override
@ -124,7 +124,7 @@ administration:
host: eshop-st-administration
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/service-administration"
repository: "eshoponabp/service-administration"
tag: 1.0.0
# gateway-web sub-chart override
@ -146,7 +146,7 @@ gateway-web:
host: eshop-st-gateway-web
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/gateway-web"
repository: "eshoponabp/gateway-web"
tag: 1.0.0
reRoutes:
accountService:
@ -179,7 +179,7 @@ gateway-web-public:
host: eshop-st-gateway-web-public
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/gateway-web-public"
repository: "eshoponabp/gateway-web-public"
tag: 1.0.0
reRoutes:
accountService:
@ -222,7 +222,7 @@ basket:
host: eshop-st-basket
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/service-basket"
repository: "eshoponabp/service-basket"
tag: 1.0.0
# catalog-service sub-chart override
@ -251,7 +251,7 @@ catalog:
host: eshop-st-catalog
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/service-catalog"
repository: "eshoponabp/service-catalog"
tag: 1.0.0
# ordering-service sub-chart override
@ -275,8 +275,8 @@ ordering:
host: eshop-st-ordering
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/service-ordering"
tag: 1.0.1
repository: "eshoponabp/service-ordering"
tag: 1.0.0
# cmskit-service sub-chart override
cmskit:
@ -327,7 +327,7 @@ payment:
host: eshop-st-payment
tlsSecret: eshop-wildcard-tls
image:
repository: "ghcr.io/volosoft/eshoponabp/service-payment"
repository: "eshoponabp/service-payment"
tag: 1.0.0
# Default values for eshoponabp.

29
services/administration/src/EShopOnAbp.AdministrationService.HttpApi.Host/Handlers/CustomerRoleCreationHandler.cs

@ -0,0 +1,29 @@
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Identity;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Uow;
namespace EShopOnAbp.AdministrationService.Handlers;
public class CustomerRoleCreationHandler : IDistributedEventHandler<EntityCreatedEto<IdentityRoleEto>>,
ITransientDependency
{
private readonly IPermissionManager _permissionManager;
protected const string CustomerRole = "customer";
protected const string OrderPermission = "OrderingService.Orders";
public CustomerRoleCreationHandler(IPermissionManager permissionManager)
{
_permissionManager = permissionManager;
}
[UnitOfWork]
public virtual async Task HandleEventAsync(EntityCreatedEto<IdentityRoleEto> eventData)
{
// Assign initial permissions for the customer role
await _permissionManager.SetForRoleAsync(CustomerRole, OrderPermission, true);
}
}

1
services/identity/src/EShopOnAbp.IdentityService.Domain/IdentityServiceDbProperties.cs

@ -11,5 +11,6 @@
public const string DefaultAdminEmailAddress = "admin@abp.io";
public const string DefaultAdminPassword = "1q2w3E*";
public const string CustomerRoleName = "customer";
}
}

51
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityPublicRoleDataSeeder.cs

@ -0,0 +1,51 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
using Volo.Abp.Identity;
using IdentityRole = Volo.Abp.Identity.IdentityRole;
namespace EShopOnAbp.IdentityService.DbMigrations;
public class IdentityPublicRoleDataSeeder : IDataSeedContributor, ITransientDependency
{
private readonly IIdentityRoleRepository _roleRepository;
private readonly ILookupNormalizer _lookupNormalizer;
private readonly IGuidGenerator _guidGenerator;
private readonly IdentityRoleManager _roleManager;
public IdentityPublicRoleDataSeeder(
IIdentityRoleRepository roleRepository,
ILookupNormalizer lookupNormalizer,
IGuidGenerator guidGenerator,
IdentityRoleManager roleManager)
{
_roleRepository = roleRepository;
_lookupNormalizer = lookupNormalizer;
_guidGenerator = guidGenerator;
_roleManager = roleManager;
}
public async Task SeedAsync(DataSeedContext context)
{
await CreateCustomerRoleAsync();
}
private async Task CreateCustomerRoleAsync()
{
//"customer" role
var customerRole =
await _roleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName(IdentityServiceDbProperties.CustomerRoleName));
if (customerRole == null)
{
customerRole = new IdentityRole(_guidGenerator.Create(), IdentityServiceDbProperties.CustomerRoleName)
{
IsStatic = true,
IsPublic = true
};
(await _roleManager.CreateAsync(customerRole)).CheckErrors();
}
}
}

29
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/Handlers/IdentityUserCreationHandler.cs

@ -0,0 +1,29 @@
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Identity;
using Volo.Abp.Uow;
using Volo.Abp.Users;
namespace EShopOnAbp.IdentityService.Handlers;
public class IdentityUserCreationHandler : IDistributedEventHandler<EntityCreatedEto<UserEto>>, ITransientDependency
{
private readonly IdentityUserManager _identityUserManager;
public IdentityUserCreationHandler(IdentityUserManager identityUserManager)
{
_identityUserManager = identityUserManager;
}
[UnitOfWork]
public virtual async Task HandleEventAsync(EntityCreatedEto<UserEto> eventData)
{
if (eventData.Entity.Email != IdentityServiceDbProperties.DefaultAdminEmailAddress)
{
var identityUser = await _identityUserManager.FindByIdAsync(eventData.Entity.Id.ToString());
await _identityUserManager.AddToRoleAsync(identityUser, IdentityServiceDbProperties.CustomerRoleName);
}
}
}
Loading…
Cancel
Save