Created Identity proxy service, a sample users controller.

pull/81/head
Halil İbrahim Kalkan 8 years ago
parent cbbb136834
commit 26cbd91de8

@ -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

@ -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<AbpIdentityHttpProxyOptions>(configuration.GetSection("AbpIdentity:HttpProxy"));
services.AddMvc();
services.AddAssemblyOf<AbpDeskWebMvcModule>();
}

@ -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<ActionResult> Index()
{
var result = await _userAppService.GetAll();
return View(result.Items);
}
}
}

@ -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(

@ -0,0 +1,12 @@
@model List<Volo.Abp.Identity.IdentityUserDto>
<h2>Users</h2>
<ul class="ticket-list">
@foreach (var user in Model)
{
<li data-entity-id="@user.Id">
@user.UserName / @user.Email
</li>
}
</ul>

@ -1,5 +1,10 @@
{
"ConnectionStrings": {
"Default": "Server=localhost;Database=AbpDesk;Trusted_Connection=True;"
},
"AbpIdentity": {
"HttpProxy": {
"ApiUrlBase": "http://localhost:63290/"
}
}
}

@ -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": {

@ -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<AbpIdentityApplicationContractsModule>();
}
}
}

@ -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)

@ -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")]

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>00b240b6-ec44-461a-9578-ef4f1be9c688</ProjectGuid>
<RootNamespace>
</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

@ -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<AbpIdentityHttpProxyModule>();
}
}
}

@ -0,0 +1,7 @@
namespace Volo.Abp.Identity
{
public class AbpIdentityHttpProxyOptions
{
public string ApiUrlBase { get; set; }
}
}

@ -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<AbpIdentityHttpProxyOptions> options)
{
_options = options.Value;
}
public async Task<ListResultDto<IdentityUserDto>> 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<ListResultDto<IdentityUserDto>>(
content,
new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
}
}
public async Task<IdentityUserDto> 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<IdentityUserDto>(
content,
new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
}
}
}
}

@ -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"
}
}
}

@ -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-*"
},

Loading…
Cancel
Save