public async Task <IdentityServer3.Core.Models.Client> FindClientByIdAsync(string clientId) { var query = context.Clients .AsNoTracking() .Include(x => x.ClientSecrets) .Include(x => x.RedirectUris) .Include(x => x.PostLogoutRedirectUris) .Include(x => x.AllowedScopes) .Include(x => x.IdentityProviderRestrictions) .Include(x => x.Claims) .Include(x => x.AllowedCustomGrantTypes) .Include(x => x.AllowedCorsOrigins); Client client = null; if (options != null && options.SynchronousReads) { client = query.SingleOrDefault(x => x.ClientId == clientId); } else { client = await query.SingleOrDefaultAsync(x => x.ClientId == clientId); } IdentityServer3.Core.Models.Client model = client.ToModel(); return(model); }
public async Task <IdentityServer3.Core.Models.Client> FindClientByIdAsync(string clientId) { var parameters = new Dictionary <string, object>(); var dynamicParameters = new DynamicParameters(); var sql = options.SqlGenerator.Select(new ClientMapper(options), Predicates.Field <Client>(s => s.ClientId, Operator.Eq, clientId), null, parameters); dynamicParameters = new DynamicParameters(); foreach (var parameter in parameters) { dynamicParameters.Add(parameter.Key, parameter.Value); } var client = await options.Connection.QueryFirstOrDefaultAsync <Client>(sql, dynamicParameters); if (client != null) { parameters = new Dictionary <string, object>(); sql = options.SqlGenerator.Select(new ClientSecretMapper(options), Predicates.Field <ClientSecret>(s => s.ClientId, Operator.Eq, client.Id), null, parameters) + " ; " + options.SqlGenerator.Select(new ClientRedirectUriMapper(options), Predicates.Field <ClientRedirectUri>(s => s.ClientId, Operator.Eq, client.Id), null, parameters) + " ; " + options.SqlGenerator.Select(new ClientPostLogoutRedirectUriMapper(options), Predicates.Field <ClientPostLogoutRedirectUri>(s => s.ClientId, Operator.Eq, client.Id), null, parameters) + " ; " + options.SqlGenerator.Select(new ClientScopeMapper(options), Predicates.Field <ClientScope>(s => s.ClientId, Operator.Eq, client.Id), null, parameters) + " ; " + options.SqlGenerator.Select(new ClientIdPRestrictionMapper(options), Predicates.Field <ClientIdPRestriction>(s => s.ClientId, Operator.Eq, client.Id), null, parameters) + " ; " + options.SqlGenerator.Select(new ClientClaimMapper(options), Predicates.Field <ClientClaim>(s => s.ClientId, Operator.Eq, client.Id), null, parameters) + " ; " + options.SqlGenerator.Select(new ClientCustomGrantTypeMapper(options), Predicates.Field <ClientCustomGrantType>(s => s.ClientId, Operator.Eq, client.Id), null, parameters) + " ; " + options.SqlGenerator.Select(new ClientCorsOriginMapper(options), Predicates.Field <ClientCorsOrigin>(s => s.ClientId, Operator.Eq, client.Id), null, parameters); dynamicParameters = new DynamicParameters(); foreach (var parameter in parameters) { dynamicParameters.Add(parameter.Key, parameter.Value); } using (var multi = await options.Connection.QueryMultipleAsync(sql, dynamicParameters)) { client.ClientSecrets = multi.Read <ClientSecret>().ToList(); client.RedirectUris = multi.Read <ClientRedirectUri>().ToList(); client.PostLogoutRedirectUris = multi.Read <ClientPostLogoutRedirectUri>().ToList(); client.AllowedScopes = multi.Read <ClientScope>().ToList(); client.IdentityProviderRestrictions = multi.Read <ClientIdPRestriction>().ToList(); client.AllowedCustomGrantTypes = multi.Read <ClientCustomGrantType>().ToList(); client.AllowedCorsOrigins = multi.Read <ClientCorsOrigin>().ToList(); } } IdentityServer3.Core.Models.Client model = client.ToModel(); return(model); }
public async Task <IdentityServer3.Core.Models.Client> FindClientByIdAsync(string clientId) { var client = await context.Clients .Include(x => x.ClientSecrets) .Include(x => x.RedirectUris) .Include(x => x.PostLogoutRedirectUris) .Include(x => x.AllowedScopes) .Include(x => x.IdentityProviderRestrictions) .Include(x => x.Claims) .Include(x => x.AllowedCustomGrantTypes) .Include(x => x.AllowedCorsOrigins) .SingleOrDefaultAsync(x => x.ClientId == clientId); IdentityServer3.Core.Models.Client model = client.ToModel(); return(model); }
public static Entities.Client ToEntity(this IdentityServer3.Core.Models.Client s) { if (s == null) { return(null); } if (s.ClientSecrets == null) { s.ClientSecrets = new List <IdentityServer3.Core.Models.Secret>(); } if (s.RedirectUris == null) { s.RedirectUris = new List <string>(); } if (s.PostLogoutRedirectUris == null) { s.PostLogoutRedirectUris = new List <string>(); } if (s.AllowedScopes == null) { s.AllowedScopes = new List <string>(); } if (s.IdentityProviderRestrictions == null) { s.IdentityProviderRestrictions = new List <string>(); } if (s.Claims == null) { s.Claims = new List <Claim>(); } if (s.AllowedCustomGrantTypes == null) { s.AllowedCustomGrantTypes = new List <string>(); } if (s.AllowedCorsOrigins == null) { s.AllowedCorsOrigins = new List <string>(); } return(Mapper.Map <IdentityServer3.Core.Models.Client, Entities.Client>(s)); }
public void AutomapperConfigurationIsValid() { IdentityServer3.Core.Models.Scope s = new IdentityServer3.Core.Models.Scope() { }; var e = s.ToEntity(); IdentityServer3.Core.Models.Client c = new IdentityServer3.Core.Models.Client() { }; var e2 = c.ToEntity(); IdentityScope s2 = new IdentityScope() { ScopeClaims = new HashSet <IdentityServer3.EntityFramework.Entities.ScopeClaim>(), ScopeSecrets = new HashSet <IdentityServer3.EntityFramework.Entities.ScopeSecret>(), }; var m = s2.ToModel(); EntitiesMap.Config.AssertConfigurationIsValid(); }
public void AutomapperConfigurationIsValid() { IdentityServer3.Core.Models.Scope s = new IdentityServer3.Core.Models.Scope() { }; var e = s.ToEntity(); IdentityServer3.Core.Models.Client c = new IdentityServer3.Core.Models.Client() { }; var e2 = c.ToEntity(); IdentityScope s2 = new IdentityScope() { ScopeClaims = new HashSet<IdentityServer3.EntityFramework.Entities.ScopeClaim>(), ScopeSecrets = new HashSet<IdentityServer3.EntityFramework.Entities.ScopeSecret>(), }; var m = s2.ToModel(); EntitiesMap.Config.AssertConfigurationIsValid(); }