Browse Source

Resolved #1370: Get ClientSecret from appsettings.json for MVC template DbMigration application.

pull/1375/head
Halil İbrahim Kalkan 7 years ago
parent
commit
2f39d2a15b
  1. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/TemplateRandomSslPortStep.cs
  2. 5
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionCache.cs
  3. 2
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs
  4. 4
      templates/mvc/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json
  5. 9
      templates/mvc/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs
  6. 2
      templates/mvc/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/appsettings.json

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/TemplateRandomSslPortStep.cs

@ -49,7 +49,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates
var consoleTestApp = appSettings.FirstOrDefault(x =>
x.Name.Equals("/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/appsettings.json", StringComparison.InvariantCultureIgnoreCase));
consoleTestApp?.SetContent(consoleTestApp.Content.Replace("https://localhost:44302", "https://localhost:44303"));
consoleTestApp?.SetContent(consoleTestApp.Content.Replace("https://localhost:44300", "https://localhost:44303"));
consoleTestApp?.SetContent(consoleTestApp.Content.Replace("https://localhost:44301", "https://localhost:44303"));
}
}

5
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionCache.cs

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
@ -42,7 +43,7 @@ namespace Volo.Abp.Http.Client.DynamicProxying
{
using (var client = _httpClientFactory.Create())
{
var response = await client.GetAsync(baseUrl + "api/abp/api-definition");
var response = await client.GetAsync(baseUrl.EnsureEndsWith('/') + "api/abp/api-definition");
if (!response.IsSuccessStatusCode)
{
throw new AbpException("Remote service returns error!");

2
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs

@ -135,7 +135,7 @@ namespace Volo.Abp.Http.Client.DynamicProxying
var action = await ApiDescriptionFinder.FindActionAsync(remoteServiceConfig.BaseUrl, typeof(TService), invocation.Method);
var apiVersion = GetApiVersionInfo(action);
var url = remoteServiceConfig.BaseUrl + UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary, apiVersion);
var url = remoteServiceConfig.BaseUrl.EnsureEndsWith('/') + UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary, apiVersion);
var requestMessage = new HttpRequestMessage(action.GetHttpMethod(), url)
{

4
templates/mvc/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json

@ -6,10 +6,12 @@
"Clients": {
"MyProjectName_Web": {
"ClientId": "MyProjectName_Web",
"ClientSecret": "1q2w3e*",
"RootUrl": "https://localhost:44302"
},
"MyProjectName_ConsoleTestApp": {
"ClientId": "MyProjectName_ConsoleTestApp"
"ClientId": "MyProjectName_ConsoleTestApp",
"ClientSecret": "1q2w3e*"
}
}
}

9
templates/mvc/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using IdentityServer4.Models;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Configuration;
using Volo.Abp.Data;
@ -11,6 +12,8 @@ using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.IdentityResources;
using Volo.Abp.PermissionManagement;
using Volo.Abp.Uow;
using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource;
using Client = Volo.Abp.IdentityServer.Clients.Client;
namespace MyCompanyName.MyProjectName.IdentityServer
{
@ -90,8 +93,6 @@ namespace MyCompanyName.MyProjectName.IdentityServer
private async Task CreateClientsAsync()
{
const string commonSecret = "E5Xd4yMqjP5kjWFKrYgySBju6JVfCzMyFp7n2QmMrME=";
var commonScopes = new[]
{
"email",
@ -118,7 +119,7 @@ namespace MyCompanyName.MyProjectName.IdentityServer
webClientId,
commonScopes,
new[] { "hybrid" },
commonSecret,
(configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(),
redirectUri: $"{webClientRootUrl}signin-oidc",
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc"
);
@ -132,7 +133,7 @@ namespace MyCompanyName.MyProjectName.IdentityServer
consoleClientId,
commonScopes,
new[] { "password", "client_credentials" },
commonSecret
(configurationSection["MyProjectName_ConsoleTestApp:ClientSecret"] ?? "1q2w3e*").Sha256()
);
}
}

2
templates/mvc/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/appsettings.json

@ -1,7 +1,7 @@
{
"RemoteServices": {
"Default": {
"BaseUrl": "https://localhost:44302"
"BaseUrl": "https://localhost:44300"
}
},
"IdentityClients": {

Loading…
Cancel
Save