Browse Source

Merge branch 'main' into aspire

azure-deployment
Galip Tolga Erdem 2 years ago
parent
commit
4c720315fd
  1. 16
      delete-bin-obj-folders.bat
  2. 21
      delete-temp-directories.bat
  3. 310
      etc/k8s/azure/azure-pipelines.yml
  4. 30
      services/identity/src/EShopOnAbp.IdentityService.Application/UserLoggedInEventHandler.cs

16
delete-bin-obj-folders.bat

@ -1,16 +0,0 @@
@ECHO off
cls
ECHO Deleting all BIN and OBJ folders...
ECHO.
FOR /d /r . %%d in (bin,obj, logs, node_modules) DO ((
ECHO.Deleting: %%d
rd /s/q "%%d"
)
)
)
ECHO.
ECHO.BIN and OBJ folders have been successfully deleted. Press any key to exit.
pause > nul

21
delete-temp-directories.bat

@ -0,0 +1,21 @@
@echo off
cls
set directories= bin, obj, logs, node_modules
set /a count = 0
echo Deleting all following directories:
for %%d in (%directories%) do echo %%d
echo.
for /d /r . %%d in (%directories%) do if exist "%%d" (
echo. Deleting: %%d
rd /s/q "%%d"
set /a count += 1
)
echo.
echo The specified directories were successfully scanned.
echo Number of deleted directories: %count%
echo Press any key to exit.
pause > nul

310
etc/k8s/azure/azure-pipelines.yml

@ -1,7 +1,7 @@
trigger:
branches:
include:
- skoc/azure-pipeline
- main
paths:
include:
- apps/angular/src/**
@ -87,20 +87,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedAngular'], 'true'))
# displayName: 'Deploy Angular App'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/web'
# releaseName: 'administration'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/web/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedAngular'], 'true'))
displayName: 'Deploy Angular App'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/web'
releaseName: 'web'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/web/values.yaml'
waitForExecution: false
# Public Web
- task: Docker@2
@ -123,20 +123,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedPublicWeb'], 'true'))
# displayName: 'Deploy Public Web'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/public-web'
# releaseName: 'public-web'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/public-web/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedPublicWeb'], 'true'))
displayName: 'Deploy Public Web'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/public-web'
releaseName: 'public-web'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/public-web/values.yaml'
waitForExecution: false
# Web Gateway
- task: Docker@2
@ -159,20 +159,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedWebGateway'], 'true'))
# displayName: 'Deploy Web Gateway'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/gateway-web'
# releaseName: 'web-gateway'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/gateway-web/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedWebGateway'], 'true'))
displayName: 'Deploy Web Gateway'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/gateway-web'
releaseName: 'web-gateway'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/gateway-web/values.yaml'
waitForExecution: false
# Web Public Gateway
- task: Docker@2
@ -195,20 +195,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedWebPublicGateway'], 'true'))
# displayName: 'Deploy Web Public Gateway'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/gateway-web-public'
# releaseName: 'web-public-gateway'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/gateway-web-public/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedWebPublicGateway'], 'true'))
displayName: 'Deploy Web Public Gateway'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/gateway-web-public'
releaseName: 'web-public-gateway'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/gateway-web-public/values.yaml'
waitForExecution: false
# Administration
- task: Docker@2
@ -231,20 +231,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedAdministration'], 'true'))
# displayName: 'Deploy Administration'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/administration'
# releaseName: 'administration'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/administration/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedAdministration'], 'true'))
displayName: 'Deploy Administration'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/administration'
releaseName: 'administration'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/administration/values.yaml'
waitForExecution: false
# Basket
- task: Docker@2
@ -267,20 +267,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedBasket'], 'true'))
# displayName: 'Deploy Basket'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/basket'
# releaseName: 'basket'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/basket/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedBasket'], 'true'))
displayName: 'Deploy Basket'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/basket'
releaseName: 'basket'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/basket/values.yaml'
waitForExecution: false
# Catalog
- task: Docker@2
@ -303,20 +303,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedCatalog'], 'true'))
# displayName: 'Deploy Catalog'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/catalog'
# releaseName: 'catalog'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/catalog/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedCatalog'], 'true'))
displayName: 'Deploy Catalog'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/catalog'
releaseName: 'catalog'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/catalog/values.yaml'
waitForExecution: false
# cmskit
- task: Docker@2
@ -339,20 +339,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedCmsKit'], 'true'))
# displayName: 'Deploy CmsKit'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/cmskit'
# releaseName: 'cmskit'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/cmskit/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedCmsKit'], 'true'))
displayName: 'Deploy CmsKit'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/cmskit'
releaseName: 'cmskit'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/cmskit/values.yaml'
waitForExecution: false
# Identity
- task: Docker@2
@ -375,20 +375,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedIdentity'], 'true'))
# displayName: 'Deploy Identity'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/identity'
# releaseName: 'identity'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/identity/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedIdentity'], 'true'))
displayName: 'Deploy Identity'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/identity'
releaseName: 'identity'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/identity/values.yaml'
waitForExecution: false
# Ordering
- task: Docker@2
@ -411,20 +411,20 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedOrdering'], 'true'))
# displayName: 'Deploy Ordering'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/ordering'
# releaseName: 'ordering'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/ordering/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedOrdering'], 'true'))
displayName: 'Deploy Ordering'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/ordering'
releaseName: 'ordering'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/ordering/values.yaml'
waitForExecution: false
# Payment
- task: Docker@2
@ -447,17 +447,17 @@ stages:
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag)
# - task: HelmDeploy@0
# #condition: and(succeeded(), eq(variables['hasChangedPayment'], 'true'))
# displayName: 'Deploy Payment'
# inputs:
# connectionType: Kubernetes Service Connection
# kubernetesServiceConnection: 'aks-demoms'
# namespace: 'eshop'
# command: 'upgrade'
# hartType: 'FilePath'
# chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/payment'
# releaseName: 'payment'
# overrideValues: 'image.tag=$(tag)'
# valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/payment/values.yaml'
# waitForExecution: false
- task: HelmDeploy@0
#condition: and(succeeded(), eq(variables['hasChangedPayment'], 'true'))
displayName: 'Deploy Payment'
inputs:
connectionType: Kubernetes Service Connection
kubernetesServiceConnection: 'aks-demoms'
namespace: 'eshop'
command: 'upgrade'
chartType: 'FilePath'
chartPath: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/payment'
releaseName: 'payment'
overrideValues: 'image.tag=$(tag)'
valueFile: 'devops/eshoponabp/k8s/eshoponabp-istio/charts/payment/values.yaml'
waitForExecution: false

30
services/identity/src/EShopOnAbp.IdentityService.Application/UserLoggedInEventHandler.cs

@ -1,8 +1,11 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.IdentityService.ETOs;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Identity;
using Volo.Abp.Uow;
@ -13,16 +16,22 @@ public class UserLoggedInEventHandler : IDistributedEventHandler<UserLoggedInEto
{
private readonly IdentityUserManager _userManager;
private readonly ILogger<UserLoggedInEventHandler> _logger;
private readonly IIdentityUserRepository _identityUserRepository;
private readonly ILookupNormalizer _lookupNormalizer;
public UserLoggedInEventHandler(IdentityUserManager userManager, ILogger<UserLoggedInEventHandler> logger)
public UserLoggedInEventHandler(IdentityUserManager userManager,
ILogger<UserLoggedInEventHandler> logger,
IIdentityUserRepository identityUserRepository,
ILookupNormalizer lookupNormalizer)
{
_userManager = userManager;
_logger = logger;
_identityUserRepository = identityUserRepository;
_lookupNormalizer = lookupNormalizer;
}
[UnitOfWork]
public async virtual Task HandleEventAsync(UserLoggedInEto eventData)
public virtual async Task HandleEventAsync(UserLoggedInEto eventData)
{
if (eventData == null)
{
@ -59,8 +68,15 @@ public class UserLoggedInEventHandler : IDistributedEventHandler<UserLoggedInEto
// This should run once to sync the admin userIds that seeded by IdentityModule and the Keycloak admin
if (userInfo.UserName == "admin")
{
var adminUser = await _userManager.FindByNameAsync("admin");
await _userManager.DeleteAsync(adminUser);
var normalizedName = _lookupNormalizer.NormalizeName(userInfo.UserName);
var adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync(normalizedName);
foreach (var role in adminUser.Roles.ToList())
{
user.AddRole(role.RoleId);
}
// Hard delete the admin-user
await _identityUserRepository.HardDeleteAsync(adminUser, true);
}
var result = await _userManager.CreateAsync(user);

Loading…
Cancel
Save