more services from Web API
This commit is contained in:
@ -11,9 +11,12 @@
|
||||
*/
|
||||
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Yavsc.Interface;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Services;
|
||||
|
||||
internal class Program
|
||||
{
|
||||
@ -61,13 +64,18 @@ internal class Program
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
options.UseNpgsql(builder.Configuration.GetConnectionString("Default")));
|
||||
services.AddScoped<UserManager<ApplicationUser>>();
|
||||
|
||||
services.AddSingleton<IConnexionManager, HubConnectionManager>();
|
||||
services.AddSingleton<ILiveProcessor, LiveProcessor>();
|
||||
services.AddTransient<IFileSystemAuthManager, FileSystemAuthManager>();
|
||||
services.AddIdentityApiEndpoints<ApplicationUser>();
|
||||
builder.Services.AddSession();
|
||||
|
||||
/*services.AddTransient<ITrueEmailSender, MailSender>()
|
||||
.AddTransient<IYavscMessageSender, YavscMessageSender>()
|
||||
services.AddTransient<ITrueEmailSender, MailSender>()
|
||||
.AddTransient<IBillingService, BillingService>()
|
||||
.AddTransient<ICalendarManager, CalendarManager>();*/
|
||||
.AddTransient<ICalendarManager, CalendarManager>()
|
||||
.AddTransient<IUserStore<ApplicationUser>, UserStore<ApplicationUser>>()
|
||||
.AddTransient<DbContext>();
|
||||
|
||||
using (var app = builder.Build())
|
||||
{
|
||||
if (app.Environment.IsDevelopment())
|
||||
@ -82,11 +90,7 @@ internal class Program
|
||||
endpoints.MapDefaultControllerRoute()
|
||||
.RequireAuthorization();
|
||||
});
|
||||
|
||||
app.MapGet("/identity", (HttpContext context) =>
|
||||
new JsonResult(context?.User?.Claims.Select(c => new { c.Type, c.Value }))
|
||||
).RequireAuthorization("ApiScope");
|
||||
|
||||
app.MapIdentityApi<ApplicationUser>().RequireAuthorization("ApiScope");
|
||||
app.UseSession();
|
||||
await app.RunAsync();
|
||||
};
|
||||
|
@ -16,6 +16,7 @@ using Yavsc.Abstract.Templates;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using RazorEngine.Configuration;
|
||||
using Yavsc.Interface;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Yavsc.Lib
|
||||
{
|
@ -27,6 +27,7 @@ using Google.Apis.Auth.OAuth2.Responses;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Yavsc.Models.Calendar;
|
||||
using Yavsc.Server.Helpers;
|
@ -3,6 +3,8 @@ using System.Net.WebSockets;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.ViewModels.Streaming;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
@ -4,6 +4,7 @@ using IdentityServer8.Models;
|
||||
using IdentityServer8.Services;
|
||||
using IdentityServer8.Stores;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yavsc.Models;
|
||||
|
||||
namespace Yavsc.Services
|
||||
@ -71,14 +72,14 @@ namespace Yavsc.Services
|
||||
return claims;
|
||||
}
|
||||
|
||||
public async Task GetProfileDataAsync(ProfileDataRequestContext context)
|
||||
override public async Task GetProfileDataAsync(ProfileDataRequestContext context)
|
||||
{
|
||||
var subjectId = context.Subject.Claims.FirstOrDefault(c => c.Type == "sub").Value;
|
||||
var user = await _userManager.FindByIdAsync(subjectId);
|
||||
context.IssuedClaims = await GetClaimsFromUserAsync(context, user);
|
||||
}
|
||||
|
||||
public async Task IsActiveAsync(IsActiveContext context)
|
||||
override public async Task IsActiveAsync(IsActiveContext context)
|
||||
{
|
||||
var subjectId = context.Subject.Claims.FirstOrDefault(c => c.Type == "sub").Value;
|
||||
var user = await _userManager.FindByIdAsync(subjectId);
|
@ -21,6 +21,10 @@
|
||||
<PackageReference Include="Google.Apis.Calendar.v3" Version="1.60.0.2993" />
|
||||
<PackageReference Include="PayPalMerchantSDK" Version="2.16.250" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.6" />
|
||||
<PackageReference Include="RazorEngine.NetCore" Version="3.1.0" />
|
||||
<PackageReference Include="MailKit" Version="4.3.0" />
|
||||
<PackageReference Include="MimeKit" Version="4.3.0" />
|
||||
<PackageReference Include="pazof.rules" Version="1.1.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
|
@ -1,5 +1,5 @@
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Interface;
|
||||
|
@ -33,10 +33,6 @@
|
||||
<PackageReference Include="Google.Apis.Compute.v1" Version="1.54.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor" Version="2.2.0" />
|
||||
<PackageReference Include="MailKit" Version="4.3.0" />
|
||||
<PackageReference Include="MimeKit" Version="4.3.0" />
|
||||
<PackageReference Include="pazof.rules" Version="1.1.3" />
|
||||
<PackageReference Include="RazorEngine.NetCore" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.7" />
|
||||
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.2.0" />
|
||||
|
@ -1,20 +0,0 @@
|
||||
0 info it worked if it ends with ok
|
||||
1 verbose cli [ 'C:\\Programs\\nodejs\\node.exe',
|
||||
1 verbose cli 'C:\\Programs\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
|
||||
1 verbose cli 'install' ]
|
||||
2 info using npm@1.4.9
|
||||
3 info using node@v8.11.3
|
||||
4 error install Couldn't read dependencies
|
||||
5 error package.json ENOENT: no such file or directory, open 'C:\Users\paul\Documents\GitHub\yavsc\test\package.json'
|
||||
5 error package.json This is most likely not a problem with npm itself.
|
||||
5 error package.json npm can't find a package.json file in your current directory.
|
||||
6 error System Windows_NT 6.1.7601
|
||||
7 error command "C:\\Programs\\nodejs\\node.exe" "C:\\Programs\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
|
||||
8 error cwd C:\Users\paul\Documents\GitHub\yavsc\test
|
||||
9 error node -v v8.11.3
|
||||
10 error npm -v 1.4.9
|
||||
11 error path C:\Users\paul\Documents\GitHub\yavsc\test\package.json
|
||||
12 error syscall open
|
||||
13 error code ENOPACKAGEJSON
|
||||
14 error errno -4058
|
||||
15 verbose exit [ -4058, true ]
|
@ -1,95 +0,0 @@
|
||||
{
|
||||
"version": "1.0.5-*",
|
||||
"title": "Yavsc - les tests",
|
||||
"description": "Yavsc xUnit testing",
|
||||
"authors": [
|
||||
"Paul Schneider <paul@pschneider.fr>"
|
||||
],
|
||||
"resource": "Resources/**/*.resx",
|
||||
"buildOptions": {
|
||||
"debugType": "full",
|
||||
"emitEntryPoint": true,
|
||||
"compile": {
|
||||
"include": "*.cs",
|
||||
"exclude": [
|
||||
"contrib"
|
||||
]
|
||||
},
|
||||
"embed": [
|
||||
"Resources/**/*.resx"
|
||||
],
|
||||
"define": ["USERMANAGER"]
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {}
|
||||
},
|
||||
"commands": {
|
||||
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls https://*:5001",
|
||||
"test": "xunit.runner.dnx"
|
||||
},
|
||||
"packOptions": {
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pazof/yavsc"
|
||||
},
|
||||
"licenseUrl": "https://github.com/pazof/yavsc/blob/vnext/LICENSE",
|
||||
"requireLicenseAcceptance": true,
|
||||
"owners": [
|
||||
"Paul Schneider <paul@pschneider.fr>"
|
||||
],
|
||||
"summary": "Yet another very small company",
|
||||
"projectUrl": "http://yavsc.pschneider.fr",
|
||||
"tags": [
|
||||
"Blog",
|
||||
"PoS",
|
||||
"Chat"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"bin",
|
||||
"wwwroot",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"contrib",
|
||||
"testingrepo"
|
||||
],
|
||||
"tooling": {
|
||||
"defaultNamespace": "test"
|
||||
},
|
||||
"dependencies": {
|
||||
"EntityFramework.Commands": "7.0.0-rc1-final",
|
||||
"EntityFramework7.Npgsql": "3.1.0-rc1-3",
|
||||
"EntityFramework7.Npgsql.Design": "3.1.0-rc1-5",
|
||||
"Newtonsoft.Json": "7.0.1",
|
||||
"Microsoft.AspNet.Mvc": "6.0.0-rc1-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-*",
|
||||
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-*",
|
||||
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-*",
|
||||
"xunit": "2.1.0",
|
||||
"xunit.analyzers": "0.9.0",
|
||||
"xunit.assert": "2.1.0",
|
||||
"xunit.runner.console": "2.4.0-rc.2.build4045",
|
||||
"Microsoft.Dnx.TestHost": "1.0.0-rc1-final",
|
||||
"Microsoft.Dnx.Runtime": "1.0.0-rc1-final",
|
||||
"xunit.runner.dnx": "2.1.0-rc1-build204",
|
||||
"Yavsc.Server": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
},
|
||||
"Yavsc.Abstract": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
},
|
||||
"Yavsc": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
}
|
||||
},
|
||||
"userSecretsId": "aspnet5-YavscWeb-a0dadd21-2ced-43d3-96f9-7e504345102f",
|
||||
"scripts": {
|
||||
"postrestore": [
|
||||
"grep -v '\\.\\.dll' project.lock.json > new.project.lock.json",
|
||||
"mv new.project.lock.json project.lock.json"
|
||||
]
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
1.0.8
|
Reference in New Issue
Block a user