diff --git a/Volo.Abp.sln b/Volo.Abp.sln index cd0e911ec8..145ac79b5c 100644 --- a/Volo.Abp.sln +++ b/Volo.Abp.sln @@ -100,6 +100,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.Identity.HttpApi", EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.Identity.HttpApi.Host", "src\Volo.Abp.Identity.HttpApi.Host\Volo.Abp.Identity.HttpApi.Host.xproj", "{EB902D57-C047-4CDF-828B-FDC204AC7398}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.Identity.HttpProxy", "src\Volo.Abp.Identity.HttpProxy\Volo.Abp.Identity.HttpProxy.xproj", "{00B240B6-EC44-461A-9578-EF4F1BE9C688}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -238,6 +240,10 @@ Global {EB902D57-C047-4CDF-828B-FDC204AC7398}.Debug|Any CPU.Build.0 = Debug|Any CPU {EB902D57-C047-4CDF-828B-FDC204AC7398}.Release|Any CPU.ActiveCfg = Release|Any CPU {EB902D57-C047-4CDF-828B-FDC204AC7398}.Release|Any CPU.Build.0 = Release|Any CPU + {00B240B6-EC44-461A-9578-EF4F1BE9C688}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {00B240B6-EC44-461A-9578-EF4F1BE9C688}.Debug|Any CPU.Build.0 = Debug|Any CPU + {00B240B6-EC44-461A-9578-EF4F1BE9C688}.Release|Any CPU.ActiveCfg = Release|Any CPU + {00B240B6-EC44-461A-9578-EF4F1BE9C688}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -284,5 +290,6 @@ Global {54592671-9CB6-48AE-9AE0-84CD016E87FF} = {1895A5C9-50D4-4568-9A3A-14657E615A5E} {57FCA6CB-9D99-411E-8ABF-20ACFBD61D61} = {1895A5C9-50D4-4568-9A3A-14657E615A5E} {EB902D57-C047-4CDF-828B-FDC204AC7398} = {1895A5C9-50D4-4568-9A3A-14657E615A5E} + {00B240B6-EC44-461A-9578-EF4F1BE9C688} = {1895A5C9-50D4-4568-9A3A-14657E615A5E} EndGlobalSection EndGlobal diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs index 2b725ccd1c..458724b924 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/AbpDeskWebMvcModule.cs @@ -9,6 +9,7 @@ using Volo.Abp; using Volo.Abp.AspNetCore.EmbeddedFiles; using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; +using Volo.Abp.Identity; using Volo.Abp.Modularity; using Volo.Abp.UI.Navigation; @@ -18,7 +19,9 @@ namespace AbpDesk.Web.Mvc typeof(AbpAspNetCoreEmbeddedFilesModule), typeof(AbpAspNetCoreMvcUiBootstrapModule), typeof(AbpDeskApplicationModule), - typeof(AbpDeskEntityFrameworkCoreModule))] + typeof(AbpDeskEntityFrameworkCoreModule), + typeof(AbpIdentityHttpProxyModule) + )] public class AbpDeskWebMvcModule : AbpModule { public override void ConfigureServices(IServiceCollection services) @@ -33,6 +36,8 @@ namespace AbpDesk.Web.Mvc options.MenuContributors.Add(new MainMenuContributor()); }); + services.Configure(configuration.GetSection("AbpIdentity:HttpProxy")); + services.AddMvc(); services.AddAssemblyOf(); } diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/Controllers/UsersController.cs b/src/AbpDesk/AbpDesk.Web.Mvc/Controllers/UsersController.cs new file mode 100644 index 0000000000..1e96f37462 --- /dev/null +++ b/src/AbpDesk/AbpDesk.Web.Mvc/Controllers/UsersController.cs @@ -0,0 +1,24 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Identity; + +namespace AbpDesk.Web.Mvc.Controllers +{ + //TODO: Move to Volo.Abp.Identity.AspNetCore.Mvc or a similar module as a seperated area! + public class UsersController : AbpController + { + private readonly IUserAppService _userAppService; + + public UsersController(IUserAppService userAppService) + { + _userAppService = userAppService; + } + + public async Task Index() + { + var result = await _userAppService.GetAll(); + return View(result.Items); + } + } +} diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/Navigation/MainMenuContributor.cs b/src/AbpDesk/AbpDesk.Web.Mvc/Navigation/MainMenuContributor.cs index 1df5245c7e..d366158885 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/Navigation/MainMenuContributor.cs +++ b/src/AbpDesk/AbpDesk.Web.Mvc/Navigation/MainMenuContributor.cs @@ -18,6 +18,9 @@ namespace AbpDesk.Web.Mvc.Navigation .AddItem( new ApplicationMenuItem("Home", "Home", url: "/") ) + .AddItem( + new ApplicationMenuItem("Users", "Users", url: "/Users") + ) .AddItem( new ApplicationMenuItem("TicketManagement", "Ticket Management") .AddItem( diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/Views/Users/Index.cshtml b/src/AbpDesk/AbpDesk.Web.Mvc/Views/Users/Index.cshtml new file mode 100644 index 0000000000..f993aff148 --- /dev/null +++ b/src/AbpDesk/AbpDesk.Web.Mvc/Views/Users/Index.cshtml @@ -0,0 +1,12 @@ +@model List + +

Users

+ +
    + @foreach (var user in Model) + { +
  • + @user.UserName / @user.Email +
  • + } +
\ No newline at end of file diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json index 0f39b1b157..41ba6612ea 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json +++ b/src/AbpDesk/AbpDesk.Web.Mvc/appsettings.json @@ -1,5 +1,10 @@ { "ConnectionStrings": { "Default": "Server=localhost;Database=AbpDesk;Trusted_Connection=True;" + }, + "AbpIdentity": { + "HttpProxy": { + "ApiUrlBase": "http://localhost:63290/" + } } } diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/project.json b/src/AbpDesk/AbpDesk.Web.Mvc/project.json index 30b40f1ff4..2e5f4f9cb8 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/project.json +++ b/src/AbpDesk/AbpDesk.Web.Mvc/project.json @@ -12,7 +12,6 @@ "Microsoft.AspNetCore.StaticFiles": "1.1.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0", - "AbpDesk.Application.Contracts": "1.0.0-*", "Microsoft.EntityFrameworkCore.Tools": { "type": "build", @@ -26,7 +25,8 @@ "AbpDesk.EntityFrameworkCore": "1.0.0-*", "AbpDesk.Application": "1.0.0-*", "Volo.Abp.AspNetCore.Mvc.UI.Bootstrap": "1.0.0-*", - "Volo.Abp.AspNetCore.EmbeddedFiles": "1.0.0-*" + "Volo.Abp.AspNetCore.EmbeddedFiles": "1.0.0-*", + "Volo.Abp.Identity.HttpProxy": "1.0.0-*" }, "tools": { diff --git a/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/AbpIdentityApplicationContractsModule.cs b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/AbpIdentityApplicationContractsModule.cs new file mode 100644 index 0000000000..19548f2171 --- /dev/null +++ b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/AbpIdentityApplicationContractsModule.cs @@ -0,0 +1,13 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Identity +{ + public class AbpIdentityApplicationContractsModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs b/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs index 977357bc2a..dd4e11ba47 100644 --- a/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs +++ b/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs @@ -3,7 +3,7 @@ using Volo.Abp.Modularity; namespace Volo.Abp.Identity { - [DependsOn(typeof(AbpIdentityModule))] + [DependsOn(typeof(AbpIdentityModule), typeof(AbpIdentityApplicationContractsModule))] public class AbpIdentityApplicationModule : AbpModule { public override void ConfigureServices(IServiceCollection services) diff --git a/src/Volo.Abp.Identity.HttpProxy/Properties/AssemblyInfo.cs b/src/Volo.Abp.Identity.HttpProxy/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..041f958cf5 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpProxy/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Volo.Abp.Identity.HttpProxy")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("00b240b6-ec44-461a-9578-ef4f1be9c688")] diff --git a/src/Volo.Abp.Identity.HttpProxy/Volo.Abp.Identity.HttpProxy.xproj b/src/Volo.Abp.Identity.HttpProxy/Volo.Abp.Identity.HttpProxy.xproj new file mode 100644 index 0000000000..c03a788be0 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpProxy/Volo.Abp.Identity.HttpProxy.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 00b240b6-ec44-461a-9578-ef4f1be9c688 + + + .\obj + .\bin\ + v4.6.1 + + + 2.0 + + + \ No newline at end of file diff --git a/src/Volo.Abp.Identity.HttpProxy/Volo/Abp/Identity/AbpIdentityHttpProxyModule.cs b/src/Volo.Abp.Identity.HttpProxy/Volo/Abp/Identity/AbpIdentityHttpProxyModule.cs new file mode 100644 index 0000000000..185fce931a --- /dev/null +++ b/src/Volo.Abp.Identity.HttpProxy/Volo/Abp/Identity/AbpIdentityHttpProxyModule.cs @@ -0,0 +1,14 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Identity +{ + [DependsOn(typeof(AbpIdentityApplicationContractsModule))] + public class AbpIdentityHttpProxyModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Identity.HttpProxy/Volo/Abp/Identity/AbpIdentityHttpProxyOptions.cs b/src/Volo.Abp.Identity.HttpProxy/Volo/Abp/Identity/AbpIdentityHttpProxyOptions.cs new file mode 100644 index 0000000000..15afa46653 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpProxy/Volo/Abp/Identity/AbpIdentityHttpProxyOptions.cs @@ -0,0 +1,7 @@ +namespace Volo.Abp.Identity +{ + public class AbpIdentityHttpProxyOptions + { + public string ApiUrlBase { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Identity.HttpProxy/Volo/Abp/Identity/HttpProxyUserAppService.cs b/src/Volo.Abp.Identity.HttpProxy/Volo/Abp/Identity/HttpProxyUserAppService.cs new file mode 100644 index 0000000000..d6b83a5e20 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpProxy/Volo/Abp/Identity/HttpProxyUserAppService.cs @@ -0,0 +1,62 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using Microsoft.Extensions.Options; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using Volo.Abp.Application.Services.Dtos; + +namespace Volo.Abp.Identity +{ + public class HttpProxyUserAppService : IUserAppService + { + private readonly AbpIdentityHttpProxyOptions _options; + + public HttpProxyUserAppService(IOptionsSnapshot options) + { + _options = options.Value; + } + + public async Task> GetAll() + { + using (var client = new HttpClient()) + { + var response = await client.GetAsync(_options.ApiUrlBase + "api/identity/users"); + if (!response.IsSuccessStatusCode) + { + throw new AbpException("Remote service returns error!"); + } + + var content = await response.Content.ReadAsStringAsync(); + + return JsonConvert.DeserializeObject>( + content, + new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver() + }); + } + } + + public async Task Get(Guid id) + { + using (var client = new HttpClient()) + { + var response = await client.GetAsync(_options.ApiUrlBase + "api/identity/users/" + id); + if (!response.IsSuccessStatusCode) + { + throw new AbpException("Remote service returns error!"); + } + + var content = await response.Content.ReadAsStringAsync(); + + return JsonConvert.DeserializeObject( + content, + new JsonSerializerSettings + { + ContractResolver = new CamelCasePropertyNamesContractResolver() + }); + } + } + } +} diff --git a/src/Volo.Abp.Identity.HttpProxy/project.json b/src/Volo.Abp.Identity.HttpProxy/project.json new file mode 100644 index 0000000000..c490a0429a --- /dev/null +++ b/src/Volo.Abp.Identity.HttpProxy/project.json @@ -0,0 +1,14 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "Volo.Abp.Identity.Application.Contracts": "1.0.0-*", + "System.Net.Http": "4.3.1" + }, + + "frameworks": { + "netstandard1.6": { + "imports": "dnxcore50" + } + } +} diff --git a/src/Volo.Abp.Identity/project.json b/src/Volo.Abp.Identity/project.json index 3e8b95a12e..ada96865ef 100644 --- a/src/Volo.Abp.Identity/project.json +++ b/src/Volo.Abp.Identity/project.json @@ -2,7 +2,6 @@ "version": "1.0.0-*", "dependencies": { - "NETStandard.Library": "1.6.1", "Microsoft.AspNetCore.Identity": "1.1.0", "Volo.Abp": "1.0.0-*" },