コード例 #1
0
 public void Create(OpenIdConnectClient model)
 {
     if (model == null) throw new ArgumentNullException("model");
     var item = new OpenIdConnectClientEntity();
     model.UpdateEntity(item);
     using (var entities = IdentityServerConfigurationContext.Get())
     {
         entities.OpenIdConnectClients.Add(item);
         entities.SaveChanges();
     }
 }
コード例 #2
0
 public void Update(OpenIdConnectClient model)
 {
     if (model == null) throw new ArgumentNullException("model");
     using (var entities = IdentityServerConfigurationContext.Get())
     {
         var item = entities.OpenIdConnectClients.Find(model.ClientId);
         if (item != null)
         {
             model.UpdateEntity(item);
             entities.SaveChanges();
         }
     }
 }
コード例 #3
0
ファイル: Mappings.cs プロジェクト: azhuang88/IdentityServer
        public static OpenIdConnectClient ToDomainModel(this OpenIdConnectClientEntity client)
        {
            var ret = new OpenIdConnectClient
            {
                ClientId = client.ClientId,
                AccessTokenLifetime = client.AccessTokenLifetime,
                AllowRefreshToken = client.AllowRefreshToken,
                ClientSecretType = client.ClientSecretType,
                Flow = client.Flow,
                Name = client.Name,
                RefreshTokenLifetime = client.RefreshTokenLifetime,
                RequireConsent = client.RequireConsent
            };

            if (client.RedirectUris != null)
            {
                ret.RedirectUris =
                    (from item in client.RedirectUris
                        select item.RedirectUri).ToArray();
            }
            else
            {
                ret.RedirectUris = new string[0];
            }

            return ret;
        }
コード例 #4
0
        public bool ValidateClient(string clientId, string clientSecret, out OpenIdConnectClient client)
        {
            using (var entities = IdentityServerConfigurationContext.Get())
            {
                var record = entities.OpenIdConnectClients.Find(clientId);
                if (record != null)
                {
                    if (CryptoHelper.VerifyHashedPassword(record.ClientSecret, clientSecret))
                    {
                        client = record.ToDomainModel();
                        return true;
                    }
                }

                client = null;
                return false;
            }
        }
コード例 #5
0
 public OpenIdConnectClientViewModel(OpenIdConnectClient client)
 {
     Container.Current.SatisfyImportsOnce(this);
     Client = client;
     MapRedirectUris();
 }
コード例 #6
0
        public ActionResult Edit(string clientId)
        {
            OpenIdConnectClient client = null;
            if (!String.IsNullOrWhiteSpace(clientId))
            {
                client = this.repository.Get(clientId);
                if (client == null) return HttpNotFound();
            }
            else
            {
                client = new OpenIdConnectClient();
            }

            var vm = new OpenIdConnectClientViewModel(client);
            return View("Edit", vm);
        }