Skip to content
This repository was archived by the owner on Aug 1, 2021. It is now read-only.

Commit 929ffa8

Browse files
committed
Merge branch 'adminui'
2 parents c67003a + a79486b commit 929ffa8

660 files changed

Lines changed: 189734 additions & 8600 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
![image](https://github.com/brunohbrito/JP-Project/blob/master/docs/images/logo.png?raw=true)
22

33
[![Build status](https://ci.appveyor.com/api/projects/status/08v6mg6q439x16xt?svg=true)](https://ci.appveyor.com/project/brunohbrito/jp-project)
4+
[![Build Status](https://dev.azure.com/brunohbrito/Jp-Project/_apis/build/status/brunohbrito.JP-Project)](https://dev.azure.com/brunohbrito/Jp-Project/_build/latest?definitionId=1)
45
[![License](https://img.shields.io/github/license/brunohbrito/jp-project.svg)](LICENSE)
56

67
Jp Project is a Open Source Quickstart for IdentityServer4.
@@ -50,5 +51,7 @@ There are several ways we can help you out.
5051
# What comes next?
5152

5253
Admin panel to manage IdentityServer4 configuration.
54+
5355
Translation
56+
5457
Code coverage

build/build.bat

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
echo Restore nuget dep's
3-
dotnet restore "../src/Backend/Jp.UserManagement"
4-
dotnet restore "../src/Frontend/Jp.UI.SSO"
3+
dotnet build "../src/Backend/Jp.UserManagement"
4+
dotnet build "../src/Frontend/Jp.UI.SSO"
55

66
CLS
77
echo RUN API
@@ -10,5 +10,9 @@ start /d "../src/Backend/Jp.UserManagement" dotnet run args
1010
echo RUN SSO
1111
start /d "../src/Frontend/Jp.UI.SSO" dotnet run args
1212

13-
(cd "../src/Frontend/Jp.UserManagement" && npm install && start ng serve)
13+
echo RUN UserManagement
14+
(cd "../src/Frontend/Jp.UserManagement" && npm install && start npm start)
15+
16+
echo RUN AdminUi
17+
(cd "../src/Frontend/Jp.AdminUI" && npm install && start npm start)
1418

build/build.ps1

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@ $src = (Get-Item -Path "../src" -Verbose).FullName;
33
$sso = (Get-Item -Path ($src + "/Frontend/Jp.UI.SSO") -Verbose).FullName
44
$api = (Get-Item -Path ($src + "/Backend/Jp.UserManagement") -Verbose).FullName
55
$ui = (Get-Item -Path ($src + "/Frontend/Jp.UserManagement") -Verbose).FullName
6+
$adminui = (Get-Item -Path ($src + "/Frontend/Jp.AdminUI") -Verbose).FullName
67

78
$paramsSSO= "/c cd " + $sso + " && dotnet run";
89
$paramsAPI= "/c cd " + $api + " && dotnet run";
9-
$paramsUI= "/c cd " + $ui + " && ng serve";
10-
10+
$paramsUI= "/c cd " + $ui + " && npm start";
11+
$paramsAdminUI= "/c cd " + $adminui + " && npm start";
1112

1213
Write-Information Restore deps
13-
dotnet restore $sso
14-
dotnet restore $api
14+
dotnet build $sso
15+
dotnet build $api
1516
# The best way to npm install is from src folder
1617
cd $ui; npm install
1718
cd $currentPath
19+
cd $adminui; npm install
20+
cd $currentPath
21+
1822

1923
# Start-Process -Verb runas "cmd.exe" $paramsSSO;
2024
Start-Process "cmd.exe" $paramsAPI;
2125
Start-Process "cmd.exe" $paramsSSO;
22-
Start-Process "cmd.exe" $paramsUI;
26+
Start-Process "cmd.exe" $paramsUI;
27+
Start-Process "cmd.exe" $paramsAdminUI;
Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,40 @@
1-
using System.Globalization;
2-
using AutoMapper;
1+
using AutoMapper;
2+
using IdentityServer4.Models;
33
using Jp.Application.EventSourcedNormalizers;
44
using Jp.Application.ViewModels;
5+
using Jp.Application.ViewModels.ApiResouceViewModels;
6+
using Jp.Application.ViewModels.ClientsViewModels;
7+
using Jp.Application.ViewModels.IdentityResourceViewModels;
8+
using Jp.Application.ViewModels.UserViewModels;
59
using Jp.Domain.Core.Events;
610
using Jp.Domain.Models;
11+
using System.Globalization;
12+
using System.Security.Claims;
13+
using Jp.Application.ViewModels.RoleViewModels;
714

815
namespace Jp.Application.AutoMapper
916
{
1017
public class DomainToViewModelMappingProfile : Profile
1118
{
1219
public DomainToViewModelMappingProfile()
1320
{
14-
CreateMap<User, UserViewModel>().ForMember(a => a.Password, o => o.Ignore()).ForMember(a => a.ConfirmPassword, o => o.Ignore());
15-
CreateMap<StoredEvent, EventHistoryData>().ConstructUsing(a => new EventHistoryData() { Action = a.MessageType, Id = a.Id.ToString(), Details = a.Data, When = a.Timestamp.ToString(CultureInfo.InvariantCulture), Who = a.User});
21+
CreateMap<ApiResource, ApiResourceListViewModel>();
22+
CreateMap<User, UserViewModel>(MemberList.Destination);//.ForMember(x => x.LockoutEnd, opt => opt.MapFrom(src => src.LockoutEnd != null ? src.LockoutEnd.Value.DateTime.ToShortDateString() : string.Empty));
23+
CreateMap<User, UserListViewModel>(MemberList.Destination);
24+
25+
CreateMap<StoredEvent, EventHistoryData>().ConstructUsing(a => new EventHistoryData() { Action = a.MessageType, Id = a.Id.ToString(), Details = a.Data, When = a.Timestamp.ToString(CultureInfo.InvariantCulture), Who = a.User });
26+
CreateMap<Client, ClientListViewModel>(MemberList.Destination);
27+
CreateMap<IdentityServer4.EntityFramework.Entities.Secret, SecretViewModel>(MemberList.Destination);
28+
CreateMap<IdentityServer4.EntityFramework.Entities.ClientProperty, ClientPropertyViewModel>();
29+
CreateMap<IdentityServer4.EntityFramework.Entities.ClientClaim, ClaimViewModel>();
30+
CreateMap<IdentityServer4.EntityFramework.Entities.IdentityResource, IdentityResourceListView>(MemberList.Destination);
31+
CreateMap<IdentityServer4.EntityFramework.Entities.ApiScope, ScopeViewModel>();
32+
CreateMap<IdentityServer4.EntityFramework.Entities.UserClaim, ClaimViewModel>(MemberList.Destination);
33+
34+
CreateMap<Claim, ClaimViewModel>(MemberList.Destination);
35+
CreateMap<Role, RoleViewModel>(MemberList.Destination);
36+
CreateMap<UserLogin, UserLoginViewModel>(MemberList.Destination);
37+
1638
}
1739
}
1840
}
Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
using AutoMapper;
2+
using IdentityServer4.Models;
23
using Jp.Application.ViewModels;
4+
using Jp.Application.ViewModels.ApiResouceViewModels;
5+
using Jp.Application.ViewModels.ClientsViewModels;
6+
using Jp.Application.ViewModels.IdentityResourceViewModels;
7+
using Jp.Application.ViewModels.RoleViewModels;
8+
using Jp.Application.ViewModels.UserViewModels;
9+
using Jp.Domain.Commands.ApiResource;
10+
using Jp.Domain.Commands.Client;
11+
using Jp.Domain.Commands.IdentityResource;
12+
using Jp.Domain.Commands.PersistedGrant;
13+
using Jp.Domain.Commands.Role;
314
using Jp.Domain.Commands.User;
415
using Jp.Domain.Commands.UserManagement;
516

@@ -9,26 +20,79 @@ public class ViewModelToDomainMappingProfile : Profile
920
{
1021
public ViewModelToDomainMappingProfile()
1122
{
23+
/*
24+
* Persisted grant
25+
*/
26+
CreateMap<RemovePersistedGrantViewModel, RemovePersistedGrantCommand>().ConstructUsing(c => new RemovePersistedGrantCommand(c.Key));
27+
1228
/*
1329
* User Creation Commands
1430
*/
15-
CreateMap<UserViewModel, RegisterNewUserCommand>().ConstructUsing(c => new RegisterNewUserCommand(c.Username, c.Email, c.Name, c.PhoneNumber, c.Password, c.ConfirmPassword));
31+
CreateMap<RegisterUserViewModel, RegisterNewUserCommand>().ConstructUsing(c => new RegisterNewUserCommand(c.Username, c.Email, c.Name, c.PhoneNumber, c.Password, c.ConfirmPassword));
1632
CreateMap<SocialViewModel, RegisterNewUserWithoutPassCommand>(MemberList.Source).ConstructUsing(c => new RegisterNewUserWithoutPassCommand(c.Email, c.Email, c.Name, c.Picture, c.Provider, c.ProviderId));
17-
CreateMap<UserViewModel, RegisterNewUserWithProviderCommand>().ConstructUsing(c => new RegisterNewUserWithProviderCommand(c.Username, c.Email, c.Name, c.PhoneNumber, c.Password, c.ConfirmPassword, c.Picture, c.Provider, c.ProviderId));
33+
CreateMap<RegisterUserViewModel, RegisterNewUserWithProviderCommand>().ConstructUsing(c => new RegisterNewUserWithProviderCommand(c.Username, c.Email, c.Name, c.PhoneNumber, c.Password, c.ConfirmPassword, c.Picture, c.Provider, c.ProviderId));
1834
CreateMap<ForgotPasswordViewModel, SendResetLinkCommand>().ConstructUsing(c => new SendResetLinkCommand(c.UsernameOrEmail, c.UsernameOrEmail));
1935
CreateMap<ResetPasswordViewModel, ResetPasswordCommand>().ConstructUsing(c => new ResetPasswordCommand(c.Password, c.ConfirmPassword, c.Code, c.Email));
2036
CreateMap<ConfirmEmailViewModel, ConfirmEmailCommand>().ConstructUsing(c => new ConfirmEmailCommand(c.Code, c.Email));
2137

22-
2338
/*
2439
* User Management commands
2540
*/
26-
CreateMap<ProfileViewModel, UpdateProfileCommand>().ConstructUsing(c => new UpdateProfileCommand(c.Id, c.Url, c.Bio, c.Company, c.JobTitle, c.Name, c.PhoneNumber));
41+
CreateMap<UserViewModel, UpdateProfileCommand>().ConstructUsing(c => new UpdateProfileCommand(c.Id, c.Url, c.Bio, c.Company, c.JobTitle, c.Name, c.PhoneNumber));
42+
CreateMap<UserViewModel, UpdateUserCommand>().ConstructUsing(c => new UpdateUserCommand(c.Email, c.UserName, c.Name, c.PhoneNumber, c.EmailConfirmed, c.PhoneNumberConfirmed, c.TwoFactorEnabled, c.LockoutEnd, c.LockoutEnabled, c.AccessFailedCount));
2743
CreateMap<ProfilePictureViewModel, UpdateProfilePictureCommand>().ConstructUsing(c => new UpdateProfilePictureCommand(c.Id));
28-
29-
CreateMap<ChangePasswordViewModel, ChangePasswordCommand>().ConstructUsing(c => new ChangePasswordCommand(c.Id,c.OldPassword, c.NewPassword, c.ConfirmPassword));
44+
CreateMap<ChangePasswordViewModel, ChangePasswordCommand>().ConstructUsing(c => new ChangePasswordCommand(c.Id, c.OldPassword, c.NewPassword, c.ConfirmPassword));
3045
CreateMap<SetPasswordViewModel, SetPasswordCommand>().ConstructUsing(c => new SetPasswordCommand(c.Id, c.NewPassword, c.ConfirmPassword));
3146
CreateMap<RemoveAccountViewModel, RemoveAccountCommand>().ConstructUsing(c => new RemoveAccountCommand(c.Id));
47+
CreateMap<SaveUserClaimViewModel, SaveUserClaimCommand>().ConstructUsing(c => new SaveUserClaimCommand(c.Username, c.Type, c.Value));
48+
CreateMap<RemoveUserClaimViewModel, RemoveUserClaimCommand>().ConstructUsing(c => new RemoveUserClaimCommand(c.Username, c.Type));
49+
CreateMap<RemoveUserRoleViewModel, RemoveUserRoleCommand>().ConstructUsing(c => new RemoveUserRoleCommand(c.Username, c.Role));
50+
CreateMap<SaveUserRoleViewModel, SaveUserRoleCommand>().ConstructUsing(c => new SaveUserRoleCommand(c.Username, c.Role));
51+
CreateMap<RemoveUserLoginViewModel, RemoveUserLoginCommand>().ConstructUsing(c => new RemoveUserLoginCommand(c.Username, c.LoginProvider, c.ProviderKey));
52+
CreateMap<AdminChangePasswordViewodel, AdminChangePasswordCommand>().ConstructUsing(c => new AdminChangePasswordCommand(c.Password, c.ConfirmPassword, c.Username));
53+
54+
/*
55+
* Client commands
56+
*/
57+
CreateMap<Client, UpdateClientCommand>().ConstructUsing(c => new UpdateClientCommand(c));
58+
CreateMap<RemoveClientSecretViewModel, RemoveClientSecretCommand>().ConstructUsing(c => new RemoveClientSecretCommand(c.Id, c.ClientId));
59+
CreateMap<RemovePropertyViewModel, RemovePropertyCommand>().ConstructUsing(c => new RemovePropertyCommand(c.Id, c.ClientId));
60+
CreateMap<SaveClientSecretViewModel, SaveClientSecretCommand>().ConstructUsing(c => new SaveClientSecretCommand(c.ClientId, c.Description, c.Value, c.Type, c.Expiration, (int)c.Hash.GetValueOrDefault(HashType.Sha256)));
61+
CreateMap<SaveClientPropertyViewModel, SaveClientPropertyCommand>().ConstructUsing(c => new SaveClientPropertyCommand(c.ClientId, c.Key, c.Value));
62+
CreateMap<SaveClientClaimViewModel, SaveClientClaimCommand>().ConstructUsing(c => new SaveClientClaimCommand(c.ClientId, c.Type, c.Value));
63+
CreateMap<RemoveClientClaimViewModel, RemoveClientClaimCommand>().ConstructUsing(c => new RemoveClientClaimCommand(c.Id, c.ClientId));
64+
CreateMap<RemoveClientViewModel, RemoveClientCommand>().ConstructUsing(c => new RemoveClientCommand(c.ClientId));
65+
CreateMap<CopyClientViewModel, CopyClientCommand>().ConstructUsing(c => new CopyClientCommand(c.ClientId));
66+
CreateMap<SaveClientViewModel, SaveClientCommand>().ConstructUsing(c => new SaveClientCommand(c.ClientId, c.ClientName, c.ClientUri, c.LogoUri, c.Description, c.ClientType));
67+
68+
/*
69+
* Identity Resource commands
70+
*/
71+
CreateMap<IdentityResource, RegisterIdentityResourceCommand>().ConstructUsing(c => new RegisterIdentityResourceCommand(c));
72+
CreateMap<IdentityResource, UpdateIdentityResourceCommand>().ConstructUsing(c => new UpdateIdentityResourceCommand(c));
73+
CreateMap<RemoveIdentityResourceViewModel, RemoveIdentityResourceCommand>().ConstructUsing(c => new RemoveIdentityResourceCommand(c.Name));
74+
75+
/*
76+
* Api Resource commands
77+
*/
78+
CreateMap<ApiResource, RegisterApiResourceCommand>().ConstructUsing(c => new RegisterApiResourceCommand(c));
79+
CreateMap<ApiResource, UpdateApiResourceCommand>().ConstructUsing(c => new UpdateApiResourceCommand(c));
80+
CreateMap<RemoveApiResourceViewModel, RemoveApiResourceCommand>().ConstructUsing(c => new RemoveApiResourceCommand(c.Name));
81+
82+
CreateMap<SaveApiSecretViewModel, SaveApiSecretCommand>().ConstructUsing(c => new SaveApiSecretCommand(c.ResourceName, c.Description, c.Value, c.Type, c.Expiration, (int)c.Hash.GetValueOrDefault(HashType.Sha256)));
83+
CreateMap<RemoveApiSecretViewModel, RemoveApiSecretCommand>().ConstructUsing(c => new RemoveApiSecretCommand(c.Id, c.ResourceName));
84+
85+
CreateMap<RemoveApiScopeViewModel, RemoveApiScopeCommand>().ConstructUsing(c => new RemoveApiScopeCommand(c.Id, c.ResourceName));
86+
CreateMap<SaveApiScopeViewModel, SaveApiScopeCommand>().ConstructUsing(c => new SaveApiScopeCommand(c.ResourceName, c.Name, c.Description, c.DisplayName, c.Emphasize, c.ShowInDiscoveryDocument, c.UserClaims));
87+
88+
/*
89+
* Role commands
90+
*/
91+
CreateMap<RemoveRoleViewModel, RemoveRoleCommand>().ConstructUsing(c => new RemoveRoleCommand(c.Name));
92+
CreateMap<SaveRoleViewModel, SaveRoleCommand>().ConstructUsing(c => new SaveRoleCommand(c.Name));
93+
CreateMap<UpdateRoleViewModel, UpdateRoleCommand>().ConstructUsing(c => new UpdateRoleCommand(c.Name, c.OldName));
94+
CreateMap<RemoveUserFromRoleViewModel, RemoveUserFromRoleCommand>().ConstructUsing(c => new RemoveUserFromRoleCommand(c.Role, c.Username));
95+
3296
}
3397
}
3498
}

src/Backend/Jp.Application/EventSourcedNormalizers/CustomerHistory.cs

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using IdentityServer4.Models;
2+
using Jp.Application.ViewModels;
3+
using Jp.Application.ViewModels.ApiResouceViewModels;
4+
using Jp.Application.ViewModels.IdentityResourceViewModels;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Threading.Tasks;
8+
9+
namespace Jp.Application.Interfaces
10+
{
11+
public interface IApiResourceAppService : IDisposable
12+
{
13+
Task<IEnumerable<ApiResourceListViewModel>> GetApiResources();
14+
Task<ApiResource> GetDetails(string name);
15+
Task Save(ApiResource model);
16+
Task Update(ApiResource model);
17+
Task Remove(RemoveApiResourceViewModel model);
18+
Task<IEnumerable<SecretViewModel>> GetSecrets(string name);
19+
Task RemoveSecret(RemoveApiSecretViewModel model);
20+
Task SaveSecret(SaveApiSecretViewModel model);
21+
Task<IEnumerable<ScopeViewModel>> GetScopes(string name);
22+
Task RemoveScope(RemoveApiScopeViewModel model);
23+
Task SaveScope(SaveApiScopeViewModel model);
24+
}
25+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
using IdentityServer4.Models;
5+
using Jp.Application.ViewModels;
6+
using Jp.Application.ViewModels.ClientsViewModels;
7+
8+
namespace Jp.Application.Interfaces
9+
{
10+
public interface IClientAppService: IDisposable
11+
{
12+
Task<IEnumerable<ClientListViewModel>> GetClients();
13+
Task<Client> GetClientDetails(string clientId);
14+
Task Update(Client client);
15+
Task<IEnumerable<SecretViewModel>> GetSecrets(string clientId);
16+
Task RemoveSecret(RemoveClientSecretViewModel model);
17+
Task SaveSecret(SaveClientSecretViewModel model);
18+
Task<IEnumerable<ClientPropertyViewModel>> GetProperties(string clientId);
19+
Task RemoveProperty(RemovePropertyViewModel model);
20+
Task SaveProperty(SaveClientPropertyViewModel model);
21+
Task<IEnumerable<ClaimViewModel>> GetClaims(string clientId);
22+
Task RemoveClaim(RemoveClientClaimViewModel model);
23+
Task SaveClaim(SaveClientClaimViewModel model);
24+
//Task Save(SaveClientViewModel client);
25+
Task Save(SaveClientViewModel client);
26+
Task Remove(RemoveClientViewModel client);
27+
Task Copy(CopyClientViewModel client);
28+
Task<Client> GetClientDefaultDetails(string clientId);
29+
}
30+
}

0 commit comments

Comments
 (0)