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 => var consoleTestApp = appSettings.FirstOrDefault(x =>
x.Name.Equals("/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/appsettings.json", StringComparison.InvariantCultureIgnoreCase)); 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")); 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;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -42,7 +43,7 @@ namespace Volo.Abp.Http.Client.DynamicProxying
{ {
using (var client = _httpClientFactory.Create()) 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) if (!response.IsSuccessStatusCode)
{ {
throw new AbpException("Remote service returns error!"); 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 action = await ApiDescriptionFinder.FindActionAsync(remoteServiceConfig.BaseUrl, typeof(TService), invocation.Method);
var apiVersion = GetApiVersionInfo(action); 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) var requestMessage = new HttpRequestMessage(action.GetHttpMethod(), url)
{ {

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

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

Loading…
Cancel
Save