public async Task <IActionResult> Create(ApplicationViewModel model) { if (model.Type != OpenIddictConstants.ClientTypes.Confidential && model.Type != OpenIddictConstants.ClientTypes.Public) { //add model errors return(View("Edit", model)); } var application = new DynamoIdentityApplication { DisplayName = model.DisplayName, LogoutRedirectUri = model.LogoutRedirectUri, RedirectUri = model.RedirectUri, Type = model.Type }; if (application.Type == OpenIddictConstants.ClientTypes.Confidential) { await _applicationsManager.CreateAsync(application, Guid.NewGuid().ToString(), HttpContext.RequestAborted); } else { await _applicationsManager.CreateAsync(application, HttpContext.RequestAborted); } return(View(new ApplicationWithSecretViewModel(model, application.ClientSecret))); }
public ApplicationViewModel(DynamoIdentityApplication application) { Id = application.Id; CreatedOn = application.CreatedOn; ClientId = application.ClientId; DisplayName = application.DisplayName; RedirectUri = application.RedirectUri; LogoutRedirectUri = application.LogoutRedirectUri; Type = application.Type; }
private async Task CreateClientAsync( DynamoApplicationStore <DynamoIdentityApplication, DynamoIdentityToken> applicationsStore, string clientId, string clientSecret, string url) { var clientApp = applicationsStore.FindByClientIdAsync(clientId, default(CancellationToken)).Result; if (clientApp == null) { clientApp = new DynamoIdentityApplication { ClientId = clientId, DisplayName = "My client application", RedirectUri = url + "/signin-oidc", LogoutRedirectUri = url + "/signout-callback-oidc", ClientSecret = Crypto.HashPassword(clientSecret), Type = clientSecret == null ? OpenIddictConstants.ClientTypes.Public : OpenIddictConstants.ClientTypes.Confidential }; await applicationsStore.CreateAsync(clientApp, default(CancellationToken)); } }