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(); } }
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(); } } }
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; }
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; } }
public OpenIdConnectClientViewModel(OpenIdConnectClient client) { Container.Current.SatisfyImportsOnce(this); Client = client; MapRedirectUris(); }
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); }