-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathIdentityServerMapperlyMappers.cs
More file actions
238 lines (216 loc) · 11.5 KB
/
IdentityServerMapperlyMappers.cs
File metadata and controls
238 lines (216 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Riok.Mapperly.Abstractions;
using Volo.Abp.Mapperly;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.ApiScopes;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
using Volo.Abp.IdentityServer.Grants;
using Volo.Abp.IdentityServer.IdentityResources;
namespace Volo.Abp.IdentityServer;
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ClientToISClientMapper : MapperBase<Client, IdentityServer4.Models.Client>
{
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.AllowedIdentityTokenSigningAlgorithms))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.Claims))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.ClientSecrets))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.AllowedGrantTypes))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.AllowedScopes))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.AllowedCorsOrigins))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.RedirectUris))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.PostLogoutRedirectUris))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.IdentityProviderRestrictions))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.Properties))]
public override partial IdentityServer4.Models.Client Map(Client source);
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.AllowedIdentityTokenSigningAlgorithms))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.Claims))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.ClientSecrets))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.AllowedGrantTypes))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.AllowedScopes))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.AllowedCorsOrigins))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.RedirectUris))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.PostLogoutRedirectUris))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.IdentityProviderRestrictions))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.Client.Properties))]
public override partial void Map(Client source, IdentityServer4.Models.Client destination);
public override void AfterMap(Client source, IdentityServer4.Models.Client destination)
{
destination.AllowedIdentityTokenSigningAlgorithms = AllowedSigningAlgorithmsConverter.SplitToArray(source.AllowedIdentityTokenSigningAlgorithms);
if (source.Properties != null)
{
destination.Properties = source.Properties.ToDictionary(x => x.Key, x => x.Value);
}
if (source.Claims != null)
{
destination.Claims = source.Claims.Select(x => new IdentityServer4.Models.ClientClaim(x.Type, x.Value, ClaimValueTypes.String)).ToList();
}
if (source.ClientSecrets != null)
{
destination.ClientSecrets = source.ClientSecrets.Select(x => new IdentityServer4.Models.Secret(x.Value, x.Expiration) { Type = x.Type, Description = x.Description }).ToList();
}
if (source.AllowedGrantTypes != null)
{
destination.AllowedGrantTypes = source.AllowedGrantTypes.Select(x => x.GrantType).ToList();
}
if (source.AllowedScopes != null)
{
destination.AllowedScopes = source.AllowedScopes.Select(x => x.Scope).ToList();
}
if (source.AllowedCorsOrigins != null)
{
destination.AllowedCorsOrigins = source.AllowedCorsOrigins.Select(x => x.Origin).ToList();
}
if (source.RedirectUris != null)
{
destination.RedirectUris = source.RedirectUris.Select(x => x.RedirectUri).ToList();
}
if (source.PostLogoutRedirectUris != null)
{
destination.PostLogoutRedirectUris = source.PostLogoutRedirectUris.Select(x => x.PostLogoutRedirectUri).ToList();
}
if (source.IdentityProviderRestrictions != null)
{
destination.IdentityProviderRestrictions = source.IdentityProviderRestrictions.Select(x => x.Provider).ToList();
}
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ApiResourceToISApiResourceMapper : MapperBase<ApiResource, IdentityServer4.Models.ApiResource>
{
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.AllowedAccessTokenSigningAlgorithms))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.ApiSecrets))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.Properties))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.Scopes))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.UserClaims))]
public override partial IdentityServer4.Models.ApiResource Map(ApiResource source);
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.AllowedAccessTokenSigningAlgorithms))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.ApiSecrets))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.Properties))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.Scopes))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiResource.UserClaims))]
public override partial void Map(ApiResource source, IdentityServer4.Models.ApiResource destination);
public override void AfterMap(ApiResource source, IdentityServer4.Models.ApiResource destination)
{
destination.AllowedAccessTokenSigningAlgorithms = AllowedSigningAlgorithmsConverter.SplitToArray(source.AllowedAccessTokenSigningAlgorithms);
if (source.Properties != null)
{
destination.Properties = source.Properties.ToDictionary(x => x.Key, x => x.Value);
}
if (source.Secrets != null)
{
destination.ApiSecrets = source.Secrets.Select(x => new IdentityServer4.Models.Secret(x.Value, x.Expiration) { Type = x.Type, Description = x.Description }).ToList();
}
if (source.UserClaims != null)
{
destination.UserClaims = source.UserClaims.Select(x => x.Type).ToList();
}
if (source.Scopes != null)
{
destination.Scopes = source.Scopes.Select(x => x.Scope).ToList();
}
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ApiScopeToISApiScopeMapper : MapperBase<ApiScope, IdentityServer4.Models.ApiScope>
{
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiScope.UserClaims))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiScope.Properties))]
public override partial IdentityServer4.Models.ApiScope Map(ApiScope source);
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiScope.UserClaims))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.ApiScope.Properties))]
public override partial void Map(ApiScope source, IdentityServer4.Models.ApiScope destination);
public override void AfterMap(ApiScope source, IdentityServer4.Models.ApiScope destination)
{
if (source.Properties != null)
{
destination.Properties = source.Properties.ToDictionary(x => x.Key, x => x.Value);
}
if (source.UserClaims != null)
{
destination.UserClaims = source.UserClaims.Select(x => x.Type).ToList();
}
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class IdentityResourceToISIdentityResourceMapper : MapperBase<IdentityResource, IdentityServer4.Models.IdentityResource>
{
[MapperIgnoreTarget(nameof(IdentityServer4.Models.IdentityResource.UserClaims))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.IdentityResource.Properties))]
public override partial IdentityServer4.Models.IdentityResource Map(IdentityResource source);
[MapperIgnoreTarget(nameof(IdentityServer4.Models.IdentityResource.UserClaims))]
[MapperIgnoreTarget(nameof(IdentityServer4.Models.IdentityResource.Properties))]
public override partial void Map(IdentityResource source, IdentityServer4.Models.IdentityResource destination);
public override void AfterMap(IdentityResource source, IdentityServer4.Models.IdentityResource destination)
{
if (source.Properties != null)
{
destination.Properties = source.Properties.ToDictionary(x => x.Key, x => x.Value);
}
if (source.UserClaims != null)
{
destination.UserClaims = source.UserClaims.Select(x => x.Type).ToList();
}
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class ClientToClientEtoMapper : MapperBase<Client, ClientEto>
{
public override partial ClientEto Map(Client source);
public override partial void Map(Client source, ClientEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class IdentityResourceToIdentityResourceEtoMapper : MapperBase<IdentityResource, IdentityResourceEto>
{
public override partial IdentityResourceEto Map(IdentityResource source);
public override partial void Map(IdentityResource source, IdentityResourceEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class PersistedGrantToISPersistedGrantMapper : TwoWayMapperBase<PersistedGrant, IdentityServer4.Models.PersistedGrant>
{
public override partial IdentityServer4.Models.PersistedGrant Map(PersistedGrant source);
public override partial void Map(PersistedGrant source, IdentityServer4.Models.PersistedGrant destination);
public override PersistedGrant ReverseMap(IdentityServer4.Models.PersistedGrant source)
{
var entity = new PersistedGrant(System.Guid.Empty)
{
Key = source.Key,
Type = source.Type,
SubjectId = source.SubjectId,
SessionId = source.SessionId,
ClientId = source.ClientId,
Description = source.Description,
CreationTime = source.CreationTime,
Expiration = source.Expiration,
ConsumedTime = source.ConsumedTime,
Data = source.Data
};
return entity;
}
public override void ReverseMap(IdentityServer4.Models.PersistedGrant source, PersistedGrant destination)
{
destination.Key = source.Key;
destination.Type = source.Type;
destination.SubjectId = source.SubjectId;
destination.SessionId = source.SessionId;
destination.ClientId = source.ClientId;
destination.Description = source.Description;
destination.CreationTime = source.CreationTime;
destination.Expiration = source.Expiration;
destination.ConsumedTime = source.ConsumedTime;
destination.Data = source.Data;
}
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class PersistedGrantToPersistedGrantEtoMapper : MapperBase<PersistedGrant, PersistedGrantEto>
{
public override partial PersistedGrantEto Map(PersistedGrant source);
public override partial void Map(PersistedGrant source, PersistedGrantEto destination);
}
[Mapper(RequiredMappingStrategy = RequiredMappingStrategy.Target)]
public partial class DeviceFlowCodesToDeviceFlowCodesEtoMapper : MapperBase<DeviceFlowCodes, DeviceFlowCodesEto>
{
public override partial DeviceFlowCodesEto Map(DeviceFlowCodes source);
public override partial void Map(DeviceFlowCodes source, DeviceFlowCodesEto destination);
}