Beispiel #1
0
        public async Task <List <Oauth2ClientSubmit> > GetClientDefinitionsAsync()
        {
            logger.Debug($"Retrieving client security contract definition.");

            var contractClients = new List <Oauth2ClientSubmit>();
            List <IdentityServer4.EntityFramework.Entities.Client> clients = await identityClientRepository.GetListAsync();

            foreach (var client in clients.OrderBy(o => o.ClientName))
            {
                logger.Debug($"Retrieving client security contract definition for Client [{client.ClientName}].");

                var contractClient = new Oauth2ClientSubmit()
                {
                    ClientId               = client.ClientId,
                    Name                   = client.ClientName,
                    AllowedOfflineAccess   = client.AllowOfflineAccess,
                    AllowedCorsOrigins     = new List <string>(),
                    AllowedGrantTypes      = new List <string>(),
                    AllowedScopes          = new List <string>(),
                    HashedClientSecrets    = new List <string>(),
                    PostLogoutRedirectUris = new List <string>(),
                    RedirectUris           = new List <string>()
                };

                foreach (var origin in client.AllowedCorsOrigins.OrderBy(o => o.Origin))
                {
                    contractClient.AllowedCorsOrigins.Add(origin.Origin);
                }

                foreach (var origin in client.AllowedGrantTypes.OrderBy(o => o.GrantType))
                {
                    contractClient.AllowedGrantTypes.Add(origin.GrantType);
                }

                foreach (var origin in client.AllowedScopes.OrderBy(o => o.Scope))
                {
                    contractClient.AllowedScopes.Add(origin.Scope);
                }

                foreach (var origin in client.ClientSecrets.OrderBy(o => o.Value))
                {
                    contractClient.HashedClientSecrets.Add(origin.Value);
                }

                foreach (var origin in client.PostLogoutRedirectUris.OrderBy(o => o.PostLogoutRedirectUri))
                {
                    contractClient.PostLogoutRedirectUris.Add(origin.PostLogoutRedirectUri);
                }

                foreach (var origin in client.RedirectUris.OrderBy(o => o.RedirectUri))
                {
                    contractClient.RedirectUris.Add(origin.RedirectUri);
                }

                contractClients.Add(contractClient);
            }

            return(contractClients);
        }
Beispiel #2
0
 public async Task <List <Oauth2Client> > GetListAsync()
 {
     return(mapper.Map <List <Oauth2Client> >(await identityClientRepository.GetListAsync()));
 }