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

Commit 2b20d54

Browse files
committed
Client update
1 parent 63bae3a commit 2b20d54

71 files changed

Lines changed: 38824 additions & 229 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.

src/Backend/Jp.Application/AutoMapper/DomainToViewModelMappingProfile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ public class DomainToViewModelMappingProfile : Profile
1313
{
1414
public DomainToViewModelMappingProfile()
1515
{
16-
CreateMap<Client, ClientViewModel>();
16+
CreateMap<ApiResource, ApiResourceViewModel>();
1717
CreateMap<User, UserViewModel>().ForMember(a => a.Password, o => o.Ignore()).ForMember(a => a.ConfirmPassword, o => o.Ignore());
18-
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});
18+
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 });
1919
CreateMap<Client, ClientListViewModel>(MemberList.Destination);
2020
}
2121
}

src/Backend/Jp.Application/AutoMapper/ViewModelToDomainMappingProfile.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using AutoMapper;
2+
using IdentityServer4.Models;
23
using Jp.Application.ViewModels;
4+
using Jp.Application.ViewModels.ClientsViewModels;
5+
using Jp.Domain.Commands.Client;
36
using Jp.Domain.Commands.User;
47
using Jp.Domain.Commands.UserManagement;
58

@@ -29,6 +32,12 @@ public ViewModelToDomainMappingProfile()
2932
CreateMap<ChangePasswordViewModel, ChangePasswordCommand>().ConstructUsing(c => new ChangePasswordCommand(c.Id,c.OldPassword, c.NewPassword, c.ConfirmPassword));
3033
CreateMap<SetPasswordViewModel, SetPasswordCommand>().ConstructUsing(c => new SetPasswordCommand(c.Id, c.NewPassword, c.ConfirmPassword));
3134
CreateMap<RemoveAccountViewModel, RemoveAccountCommand>().ConstructUsing(c => new RemoveAccountCommand(c.Id));
35+
36+
/*
37+
* Client commands
38+
*/
39+
CreateMap<Client, UpdateClientCommand>().ConstructUsing(c => new UpdateClientCommand(c));
40+
CreateMap<ClientViewModel, Client>(MemberList.Destination);
3241
}
3342
}
3443
}

src/Backend/Jp.Application/Interfaces/IClientAppService.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ public interface IClientAppService: IDisposable
1010
{
1111
Task<IEnumerable<ClientListViewModel>> GetClients();
1212
Task<Client> GetClientDetails(string clientId);
13+
Task Update(Client client);
1314
}
1415
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Threading.Tasks;
5+
using IdentityServer4.Models;
6+
using Jp.Application.ViewModels;
7+
8+
namespace Jp.Application.Interfaces
9+
{
10+
public interface IIdentityResourcesAppService: IDisposable
11+
{
12+
Task<IEnumerable<IdentityResource>> GetIdentityResourcess();
13+
14+
}
15+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
5+
namespace Jp.Application.Interfaces
6+
{
7+
public interface IScopesAppService : IDisposable
8+
{
9+
Task<IEnumerable<string>> GetScopes(string search);
10+
11+
}
12+
}

src/Backend/Jp.Application/Services/ClientAppService.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using IdentityServer4.Models;
88
using Jp.Application.Interfaces;
99
using Jp.Application.ViewModels.ClientsViewModels;
10+
using Jp.Domain.Commands.Client;
1011
using Jp.Domain.Core.Bus;
1112
using Jp.Domain.Interfaces;
1213

@@ -42,6 +43,13 @@ public async Task<Client> GetClientDetails(string clientId)
4243
return resultado.ToModel();
4344
}
4445

46+
public Task Update(Client client)
47+
{
48+
var registerCommand = _mapper.Map<UpdateClientCommand>(client);
49+
return Bus.SendCommand(registerCommand);
50+
}
51+
52+
4553
public void Dispose()
4654
{
4755
GC.SuppressFinalize(this);
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using AutoMapper;
6+
using IdentityServer4.EntityFramework.Mappers;
7+
using IdentityServer4.Models;
8+
using Jp.Application.Interfaces;
9+
using Jp.Application.ViewModels;
10+
using Jp.Domain.Core.Bus;
11+
using Jp.Domain.Interfaces;
12+
13+
namespace Jp.Application.Services
14+
{
15+
public class IdentityResourcesAppService : IIdentityResourcesAppService
16+
{
17+
private IMapper _mapper;
18+
private IEventStoreRepository _eventStoreRepository;
19+
private readonly IIdentityResourcesRepository _identityResourcesRepository;
20+
public IMediatorHandler Bus { get; set; }
21+
22+
public IdentityResourcesAppService(IMapper mapper,
23+
IMediatorHandler bus,
24+
IEventStoreRepository eventStoreRepository,
25+
IIdentityResourcesRepository identityResourcesRepository)
26+
{
27+
_mapper = mapper;
28+
Bus = bus;
29+
_eventStoreRepository = eventStoreRepository;
30+
_identityResourcesRepository = identityResourcesRepository;
31+
}
32+
33+
34+
public Task<IEnumerable<IdentityResource>> GetIdentityResourcess()
35+
{
36+
var resultado = _identityResourcesRepository.GetAll().Select(id => id.ToModel()).ToList();
37+
return Task.FromResult<IEnumerable<IdentityResource>>(resultado);
38+
}
39+
40+
41+
public void Dispose()
42+
{
43+
GC.SuppressFinalize(this);
44+
}
45+
}
46+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using AutoMapper;
6+
using Jp.Application.Interfaces;
7+
using Jp.Domain.Core.Bus;
8+
using Jp.Domain.Interfaces;
9+
10+
namespace Jp.Application.Services
11+
{
12+
public class ScopesAppService : IScopesAppService
13+
{
14+
private IMapper _mapper;
15+
private IEventStoreRepository _eventStoreRepository;
16+
private readonly IIdentityResourcesRepository _identityResourcesRepository;
17+
private readonly IApiResourceRepository _apiResourceRepository;
18+
public IMediatorHandler Bus { get; set; }
19+
20+
public ScopesAppService(IMapper mapper,
21+
IMediatorHandler bus,
22+
IEventStoreRepository eventStoreRepository,
23+
IIdentityResourcesRepository identityResourcesRepository,
24+
IApiResourceRepository apiResourceRepository)
25+
{
26+
_mapper = mapper;
27+
Bus = bus;
28+
_eventStoreRepository = eventStoreRepository;
29+
_identityResourcesRepository = identityResourcesRepository;
30+
_apiResourceRepository = apiResourceRepository;
31+
}
32+
33+
34+
35+
public void Dispose()
36+
{
37+
GC.SuppressFinalize(this);
38+
}
39+
40+
public async Task<IEnumerable<string>> GetScopes(string search)
41+
{
42+
var identityScopes = await _identityResourcesRepository.GetScopes(search);
43+
var apiScopes = await _apiResourceRepository.GetScopes(search);
44+
identityScopes.AddRange(apiScopes);
45+
return identityScopes.OrderBy(a => a);
46+
}
47+
}
48+
}

src/Backend/Jp.Application/ViewModels/ClientViewModel.cs renamed to src/Backend/Jp.Application/ViewModels/ApiResourceViewModel.cs

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

44
namespace Jp.Application.ViewModels
55
{
6-
public class ClientViewModel
6+
public class ApiResourceViewModel
77
{
88

99

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Security.Claims;
4+
using System.Text;
5+
using IdentityServer4.Models;
6+
7+
namespace Jp.Application.ViewModels.ClientsViewModels
8+
{
9+
public class ClientViewModel
10+
{
11+
public bool Enabled { get; set; }
12+
13+
public string ClientId { get; set; }
14+
15+
public string ProtocolType { get; set; }
16+
17+
public ICollection<Secret> ClientSecrets { get; set; }
18+
19+
public bool RequireClientSecret { get; set; }
20+
21+
public string ClientName { get; set; }
22+
23+
public string ClientUri { get; set; }
24+
25+
public string LogoUri { get; set; }
26+
27+
public bool RequireConsent { get; set; }
28+
29+
public bool AllowRememberConsent { get; set; }
30+
31+
public ICollection<string> AllowedGrantTypes { get; set; }
32+
33+
public bool RequirePkce { get; set; }
34+
35+
public bool AllowPlainTextPkce { get; set; }
36+
37+
public bool AllowAccessTokensViaBrowser { get; set; }
38+
39+
public ICollection<string> RedirectUris { get; set; }
40+
41+
public ICollection<string> PostLogoutRedirectUris { get; set; }
42+
43+
public string FrontChannelLogoutUri { get; set; }
44+
45+
public bool FrontChannelLogoutSessionRequired { get; set; }
46+
47+
public string BackChannelLogoutUri { get; set; }
48+
49+
public bool BackChannelLogoutSessionRequired { get; set; }
50+
51+
public bool AllowOfflineAccess { get; set; }
52+
53+
public ICollection<string> AllowedScopes { get; set; }
54+
55+
public bool AlwaysIncludeUserClaimsInIdToken { get; set; }
56+
57+
public int IdentityTokenLifetime { get; set; }
58+
59+
public int AccessTokenLifetime { get; set; }
60+
61+
public int AuthorizationCodeLifetime { get; set; }
62+
63+
public int AbsoluteRefreshTokenLifetime { get; set; }
64+
65+
public int SlidingRefreshTokenLifetime { get; set; }
66+
67+
public int? ConsentLifetime { get; set; }
68+
69+
public TokenUsage RefreshTokenUsage { get; set; }
70+
71+
public bool UpdateAccessTokenClaimsOnRefresh { get; set; }
72+
73+
public TokenExpiration RefreshTokenExpiration { get; set; }
74+
75+
public AccessTokenType AccessTokenType { get; set; }
76+
77+
public bool EnableLocalLogin { get; set; }
78+
79+
public ICollection<string> IdentityProviderRestrictions { get; set; }
80+
81+
public bool IncludeJwtId { get; set; }
82+
83+
public ICollection<Claim> Claims { get; set; }
84+
85+
public bool AlwaysSendClientClaims { get; set; }
86+
87+
public string ClientClaimsPrefix { get; set; }
88+
89+
public string PairWiseSubjectSalt { get; set; }
90+
91+
public ICollection<string> AllowedCorsOrigins { get; set; }
92+
93+
public IDictionary<string, string> Properties { get; set; }
94+
95+
}
96+
}

0 commit comments

Comments
 (0)