diff --git a/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs b/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs index 83e8d314..6df54178 100644 --- a/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs +++ b/src/Yavsc/ApiControllers/Blogspot/BlogApiController.cs @@ -13,7 +13,6 @@ namespace Yavsc.Controllers { [Produces("application/json")] [Route("api/blog")] - [AllowAnonymous] public class BlogApiController : Controller { diff --git a/src/Yavsc/ApiControllers/Business/EstimateApiController.cs b/src/Yavsc/ApiControllers/Business/EstimateApiController.cs index 63e58da9..a85ece2a 100644 --- a/src/Yavsc/ApiControllers/Business/EstimateApiController.cs +++ b/src/Yavsc/ApiControllers/Business/EstimateApiController.cs @@ -14,7 +14,7 @@ using Yavsc.Models.Billing; namespace Yavsc.Controllers { [Produces("application/json")] - [Route("api/estimate"), Authorize()] + [Route("api/estimate"), Authorize] public class EstimateApiController : Controller { private readonly ApplicationDbContext _context; diff --git a/src/Yavsc/Extensions/HostingExtensions.cs b/src/Yavsc/Extensions/HostingExtensions.cs index 438310cd..2f88c5fd 100644 --- a/src/Yavsc/Extensions/HostingExtensions.cs +++ b/src/Yavsc/Extensions/HostingExtensions.cs @@ -135,6 +135,8 @@ internal static class HostingExtensions public static WebApplication ConfigureServices(this WebApplicationBuilder builder) { + + var siteSection = builder.Configuration.GetSection("Site"); var smtpSection = builder.Configuration.GetSection("Smtp"); var paypalSection = builder.Configuration.GetSection("Authentication:PayPal"); @@ -156,7 +158,10 @@ internal static class HostingExtensions string? googleClientId = builder.Configuration["Authentication:Google:ClientId"]; string? googleClientSecret = builder.Configuration["Authentication:Google:ClientSecret"]; var services = builder.Services; - + _ = services.AddControllersWithViews() + .AddNewtonsoftJson(); + LoadGoogleConfig(builder.Configuration); + services.Configure(siteSection); services.Configure(smtpSection); services.Configure(paypalSection); @@ -189,8 +194,11 @@ internal static class HostingExtensions .AddInMemoryIdentityResources(Config.IdentityResources) .AddInMemoryApiScopes(Config.ApiScopes) .AddInMemoryClients(Config.Clients) + .AddDeveloperSigningCredential() ; services.AddSession(); + + // TODO .AddServerSideSessionStore() @@ -315,9 +323,6 @@ internal static class HostingExtensions services.AddSingleton(); - _ = services.AddControllersWithViews() - .AddNewtonsoftJson(); - LoadGoogleConfig(builder.Configuration); return builder.Build(); } @@ -328,11 +333,14 @@ internal static class HostingExtensions { app.UseDeveloperExceptionPage(); } + else + { + app.UseExceptionHandler("/Home/Error"); + } app.UseStaticFiles(); app.UseRouting(); app.UseIdentityServer(); - //app.UseSignalR(); app.UseAuthorization(); app.MapControllerRoute( name: "default", diff --git a/src/Yavsc/Program.cs b/src/Yavsc/Program.cs index 93be79cb..a084d833 100644 --- a/src/Yavsc/Program.cs +++ b/src/Yavsc/Program.cs @@ -9,6 +9,7 @@ namespace Yavsc public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + builder.Configuration .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true) diff --git a/src/Yavsc/Views/Home/Index.cshtml b/src/Yavsc/Views/Home/Index.cshtml index 854e4d7b..aabfffb4 100755 --- a/src/Yavsc/Views/Home/Index.cshtml +++ b/src/Yavsc/Views/Home/Index.cshtml @@ -103,3 +103,21 @@ Hello !!! + diff --git a/src/Yavsc/tempkey.jwk b/src/Yavsc/tempkey.jwk new file mode 100644 index 00000000..a9efa73c --- /dev/null +++ b/src/Yavsc/tempkey.jwk @@ -0,0 +1 @@ +{"AdditionalData":{},"Alg":"RS256","Crv":null,"D":"BBXYWCFMOYOt4QTTDtjmvrbhj20p07lIjqZv6kdsEUdkrsc0p2stHYp6yT8SLxPAqMgSiFmr29jHdS56gVUa9FEe1H7DXDZszgZ8JRGWaIa2fe2_2vD-hPzFxJNmS5zlo7mFaH0lL40imi7qyzDt3lmvZnBEhwNpGeg2Ge5rmDsT9w5zeDAfLnOOC4ghUNFfQnmVZQfjsXPt46MDkj94ZInOwqJBxbjhNJSvJWkW9y3PG02bPriBx6bsHdc7yPilsqICnnLRWxb79n6XJHZ-gHO1l-eeXwAj5gJI-CX_V7INjBAuNFTMJrCbf-hpghVadsIKLLK6QOeRbdA_6JzGQQ","DP":"EaH8Zw1B6y4cJTb9EzzzPLW20YXihxB8a1ywnYOekqlRS0vUJI8hh9IayWu56PKnIwVYnWlyIn-YreBTBpRubuyc26cyEYsnqGi44K0nnN3n43LBl5BpenI_AE9gLNmP2TAngPD0vINpg9fqTXNutEsNBF_6BLkqzC52rGLMGNk","DQ":"BWlE0UknVFCZ99HL3170Vz7niIVf9zKTEZACjWfBephHjVgeFFOZCrd_3TRGvaG8FVebYJn_ARiFLYuJOXG7u_VafR5MpXxd6Qzty8B4MF3jPEiYyqAylxPh1Uwk2Dl20evd4UoCWHI6Klb8gAAL54hiqKyoYdR24uAZ8YxWB6k","E":"AQAB","K":null,"KeyId":"131338364F1631C3CFBD59BF8F32A4B0","KeyOps":[],"Kid":"131338364F1631C3CFBD59BF8F32A4B0","Kty":"RSA","N":"xymIJugCkRasJ1zA587Kq5GafxcnVXXNVU-kuwCCpAwNndgn2uXCT4WuEDkFK3gcSQKZT_SdM9rMIeJcQjHybtgJs8A-AwGG2JKpppMJ3EkxD_p_-Q1q9D-_QcsZhRU_yP8i-jO8FgYfez4z0TqJWj3nxo3c83u8tkzO1UC4FBEKGlDG993AeqpmaEeycf5bBWitQQu-xy9NgsqzmtVMZtChMtC50fzmbbKkwuOc7506Lw6vzRkBCI8DpqqN50-yL3t7mbfqwxm0OIQ4mzN-n87gaCAJRzqxFj1nQSzmJSmQ7_-nGPSLH_BR3SaPRBQBrArzZyzU7FsMYdAjrTRGoQ","Oth":[],"P":"8RnoBTdVG4Igi3a_ps36pAX09N_nDeM8uG9Oyt5NWr1k0dv4iwtGSV4W8QTTHf5m9ZxQsQIPDxncSwr_WpwfKGGfxGVcESgtDkf10dq8Ajex4NefjnKtGSRX8dAQCRDcoN_v0k32kj90PImzseYM6S4p81dZLkOX0DX9sf3IU5k","Q":"03gsWqv7Vtlr_YWGXFQ4gyq1kew6tNMCAWLIzYTKeN1evYuXCsoEUoP7OPYRsZvQ13_hgEk2qfvEeZ8HoTIY_PXXKS8iUHNQXAaKaHSeRtfKmO7qDUd5jeMihvE2295FNf3VIM24oK3QJ0FPrt8qOIarcGa-lgj2llyiEId98Ek","QI":"OAdgkRIwrQ4X_91WW7bjC37Atn7yH8YBnjHHLSwmeaXkc4JOhdeXLVYIyVKoWqdRIhaT8q4liGA5F7Lbwg4cFQ8tUEjmIbacaRxpcFYYvhQcKGA-q1MxFK2ZwNUxMjc_20ZcH7ohneGNr63im_cUGT78fMzE_YBTbAp1Sxkd0fk","Use":null,"X":null,"X5c":[],"X5t":null,"X5tS256":null,"X5u":null,"Y":null,"KeySize":2048,"HasPrivateKey":true,"CryptoProviderFactory":{"CryptoProviderCache":{},"CustomCryptoProvider":null,"CacheSignatureProviders":true,"SignatureProviderObjectPoolCacheSize":16}} \ No newline at end of file diff --git a/src/sampleWebAsWebApiClient/Controllers/AuthenticationController.cs b/src/sampleWebAsWebApiClient/Controllers/AuthenticationController.cs index b480dcfe..627f4be2 100644 --- a/src/sampleWebAsWebApiClient/Controllers/AuthenticationController.cs +++ b/src/sampleWebAsWebApiClient/Controllers/AuthenticationController.cs @@ -1,9 +1,8 @@  using System.Threading.Tasks; -using Microsoft.AspNetCore.Http.Authentication; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Mvc; -namespace Mvc.Client.Controllers { public class AuthenticationController : Controller { [HttpGet("~/signin")] @@ -13,14 +12,13 @@ namespace Mvc.Client.Controllers { // But, this redirect URI doesn't need to match the OAuth parameter, it's serialized in the query state, // to be used once the identification ends. var properties = new AuthenticationProperties { RedirectUri = returnUrl }; - return new ChallengeResult("Yavsc", properties); + return new ChallengeResult("Bearer", properties); } [HttpGet("~/signout")] public async Task SignOut(string returnUrl="/") { - await HttpContext.Authentication.SignOutAsync("Bearer"); + await HttpContext.SignOutAsync("Bearer"); return Redirect(returnUrl); } } -} diff --git a/src/sampleWebAsWebApiClient/Controllers/HomeController.cs b/src/sampleWebAsWebApiClient/Controllers/HomeController.cs index b5b8fcff..37cdbe2f 100755 --- a/src/sampleWebAsWebApiClient/Controllers/HomeController.cs +++ b/src/sampleWebAsWebApiClient/Controllers/HomeController.cs @@ -1,14 +1,15 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Net.Http; using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; -using Yavsc.Server.Helpers; -using Yavsc.Server.Model; +using Newtonsoft.Json.Linq; namespace testOauthClient.Controllers { @@ -52,6 +53,7 @@ namespace testOauthClient.Controllers } +#if FALSECODE [HttpPost] public async Task PostFiles(string subdir) { @@ -77,11 +79,10 @@ namespace testOauthClient.Controllers } memStream.Seek(0, SeekOrigin.Begin); args.Add( - new FormFile + new FormFile(memStream, 0, formFile.Length, formFile.Name, formFile.Name ) { ContentDisposition = formFile.ContentDisposition, - ContentType = formFile.ContentType, - Stream = memStream + ContentType = formFile.ContentType }); } string uri = "http://dev.pschneider.fr/api/fs/" + System.Uri.EscapeDataString(subdir); @@ -137,6 +138,7 @@ namespace testOauthClient.Controllers } return View("Index", model: result?.ToString()); } +#endif protected string AccessToken { @@ -165,9 +167,27 @@ namespace testOauthClient.Controllers return View(); } + public async Task CallApi() + { + var accessToken = await HttpContext.GetTokenAsync("access_token"); + + var client = new HttpClient(); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); + var content = await client.GetStringAsync("https://localhost:6001/identity"); + + ViewBag.Json = JArray.Parse(content).ToString(); + return View("json"); + } + + public IActionResult Logout() + { + return SignOut("Cookies", "oidc"); + } + + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { - return View(); + return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); } } } diff --git a/src/sampleWebAsWebApiClient/Dockerfile b/src/sampleWebAsWebApiClient/Dockerfile deleted file mode 100644 index 199f9d9c..00000000 --- a/src/sampleWebAsWebApiClient/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM microsoft/aspnet:1.0.0-rc1-update2 - -RUN printf "deb http://ftp2.fr.debian.org/debian/ stable main contrib non-free\n" >> /etc/apt/sources.list -# RUN apt-get -qq update && apt-get install -qqy sqlite3 libsqlite3-dev && rm -rf /var/lib/apt/lists/* -RUN apt-get -qq update && apt-get install -qqy postgresql-9.5 postgresql-client-9.5 && rm -rf /var/lib/apt/lists/* -COPY . /app -WORKDIR /app -RUN ["dnu", "restore"] - -EXPOSE 5000/tcp -ENTRYPOINT ["dnx", "-p", "project.json", "web"] diff --git a/src/sampleWebAsWebApiClient/Makefile b/src/sampleWebAsWebApiClient/Makefile deleted file mode 100644 index 118c9bf8..00000000 --- a/src/sampleWebAsWebApiClient/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -CONFIGURATION=Debug -BINTARGET=bin/$(CONFIGURATION)/dnx451/test.dll -SOURCE_DIR=../.. -MAKEFILE_DIR=$(SOURCE_DIR)/scripts/make -MSBUILD=msbuild -YAVSCSRC=../../src - -include $(MAKEFILE_DIR)/dnx.mk - -$(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll: - make -C $(YAVSCSRC)/Yavsc - -$(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll: - make -C $(YAVSCSRC)/Yavsc.Abstract - -$(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll: - make -C $(YAVSCSRC)/Yavsc.Server - -$(BINTARGET): project.lock.json $(YAVSCSRC)/Yavsc/bin/$(CONFIGURATION)/dnx451/Yavsc.dll $(YAVSCSRC)/Yavsc.Abstract/bin/$(CONFIGURATION)/dnx451/Yavsc.Abstract.dll $(YAVSCSRC)/Yavsc.Server/bin/$(CONFIGURATION)/dnx451/Yavsc.Server.dll - dnu build --configuration $(CONFIGURATION) diff --git a/src/sampleWebAsWebApiClient/Model/Error.cs b/src/sampleWebAsWebApiClient/Model/Error.cs new file mode 100644 index 00000000..c1fe990b --- /dev/null +++ b/src/sampleWebAsWebApiClient/Model/Error.cs @@ -0,0 +1,9 @@ +using System; + + public class ErrorViewModel + { + public string RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + } + diff --git a/src/sampleWebAsWebApiClient/Program.cs b/src/sampleWebAsWebApiClient/Program.cs new file mode 100644 index 00000000..966579dd --- /dev/null +++ b/src/sampleWebAsWebApiClient/Program.cs @@ -0,0 +1,19 @@ +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Identity; +using Microsoft.AspNetCore.Mvc; + + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } diff --git a/src/sampleWebAsWebApiClient/Properties/launchSettings.json b/src/sampleWebAsWebApiClient/Properties/launchSettings.json new file mode 100644 index 00000000..9add1af2 --- /dev/null +++ b/src/sampleWebAsWebApiClient/Properties/launchSettings.json @@ -0,0 +1,38 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:16967", + "sslPort": 44387 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5164", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7055;http://localhost:5164", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/sampleWebAsWebApiClient/Startup.cs b/src/sampleWebAsWebApiClient/Startup.cs old mode 100755 new mode 100644 index 30bc3c19..e997d5d4 --- a/src/sampleWebAsWebApiClient/Startup.cs +++ b/src/sampleWebAsWebApiClient/Startup.cs @@ -1,57 +1,39 @@ -using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.Extensions.WebEncoders; -using Microsoft.AspNetCore.Authentication.OAuth; -using System.Net.Http; -using System.Net.Http.Headers; -using Newtonsoft.Json.Linq; -using System.Security.Claims; +using Microsoft.Extensions.Hosting; +using System.IdentityModel.Tokens.Jwt; -namespace testOauthClient -{ public class Startup { - public Startup(IHostingEnvironment env) - { - // Set up configuration sources. - var builder = new ConfigurationBuilder() - .AddJsonFile("appsettings.json") - .AddEnvironmentVariables(); - Configuration = builder.Build(); - } - - public IConfigurationRoot Configuration { get; set; } - - // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { + services.AddControllersWithViews(); - services.Configure(options => - { - options.SignInScheme = "Bearer"; - }); - - services.AddTransient(); + JwtSecurityTokenHandler.DefaultMapInboundClaims = false; - services.AddAuthentication(); + services.AddAuthentication(options => + { + options.DefaultScheme = "Cookies"; + options.DefaultChallengeScheme = "Yavsc"; + }) + .AddCookie("Cookies") + .AddOpenIdConnect("Yavsc", options => + { + options.Authority = "https://localhost:5001"; - services.AddMvc(); + options.ClientId = "interactive"; + options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0"; + options.ResponseType = "code"; + + options.Scope.Add("scope2"); + options.SaveTokens = true; + }); } - // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { - loggerFactory.AddConsole(Configuration.GetSection("Logging")); - loggerFactory.AddDebug(); - if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); @@ -60,83 +42,17 @@ namespace testOauthClient { app.UseExceptionHandler("/Home/Error"); } - app.UseIISPlatformHandler(options => - { - options.AuthenticationDescriptions.Clear(); - }); - app.UseStaticFiles(); - var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc"); - var clientId = authConf.GetSection("ClientId").Value; - var clientSecret = authConf.GetSection("ClientSecret").Value; - var logger = loggerFactory.CreateLogger(); - logger.LogInformation($"## ClientId: {clientId} ClientSecret: {clientSecret}"); - app.UseCookieAuthentication(new CookieAuthenticationOptions - { - AutomaticAuthenticate = true, - AutomaticChallenge = true, - AuthenticationScheme = "Bearer", - CookieName = CookieAuthenticationDefaults.CookiePrefix + "Bearer", - ExpireTimeSpan = TimeSpan.FromMinutes(5), - LoginPath = new PathString("/signin"), - LogoutPath = new PathString("/signout") - }); - var host = "http://dev.pschneider.fr"; - app.UseOAuthAuthentication( - options => - { - options.AuthenticationScheme = "Yavsc"; - options.AuthorizationEndpoint = $"{host}/authorize"; - options.TokenEndpoint = $"{host}/token"; - options.CallbackPath = new PathString("/signin-yavsc"); - options.DisplayName = "Yavsc dev"; - options.ClientId = clientId; - options.ClientSecret = clientSecret; - options.Scope.Add("profile"); - options.SaveTokensAsClaims = true; - options.UserInformationEndpoint = $"{host}/api/me"; - - options.Events = new OAuthEvents - { - OnCreatingTicket = async context => - { - var request = new HttpRequestMessage(HttpMethod.Get, options.UserInformationEndpoint); - request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", context.AccessToken); - var response = await context.Backchannel.SendAsync(request); - response.EnsureSuccessStatusCode(); - var payload = JObject.Parse(await response.Content.ReadAsStringAsync()); - var identifier = payload.Value("Id"); - var givenName = payload.Value("UserName"); - var emails = payload.Value("EMails"); - var roles = payload.Value("Roles"); - string email = null; - if (emails !=null) - email = emails.First?.Value(); - if (identifier!=null) - context.Identity.AddClaim( - new Claim( ClaimTypes.NameIdentifier,identifier)); - if (givenName!=null) - context.Identity.AddClaim( - new Claim( ClaimTypes.Name,givenName)); - if (email!=null) - context.Identity.AddClaim( - new Claim( ClaimTypes.Email,email)); - // TODO add all emails and roles + app.UseStaticFiles(); - } - }; - } - ); + app.UseRouting(); + app.UseAuthentication(); + app.UseAuthorization(); - app.UseMvc(routes => + app.UseEndpoints(endpoints => { - routes.MapRoute( - name: "default", - template: "{controller=Home}/{action=Index}/{id?}"); + endpoints.MapDefaultControllerRoute() + .RequireAuthorization(); }); } - - // Entry point for the application. - public static void Main(string[] args) => Microsoft.AspNet.Hosting.WebApplication.Run(args); } -} diff --git a/src/sampleWebAsWebApiClient/Views/Home/Contact.cshtml b/src/sampleWebAsWebApiClient/Views/Home/Contact.cshtml index d5e35e02..f02cca11 100755 --- a/src/sampleWebAsWebApiClient/Views/Home/Contact.cshtml +++ b/src/sampleWebAsWebApiClient/Views/Home/Contact.cshtml @@ -4,13 +4,3 @@

@ViewData["Title"].

@ViewData["Message"]

-
- Paul Schneider
- A: Boulevard Aristide Briand - 92150 Suresnes - M: 336 51 14 15 64 -
- -
- Support: contact@pschneider.fr
- Marketing: paul@pschneider.fr -
diff --git a/src/sampleWebAsWebApiClient/Views/Home/Index.cshtml b/src/sampleWebAsWebApiClient/Views/Home/Index.cshtml index 2bb743a4..fda9951d 100755 --- a/src/sampleWebAsWebApiClient/Views/Home/Index.cshtml +++ b/src/sampleWebAsWebApiClient/Views/Home/Index.cshtml @@ -1,3 +1,4 @@ +@using Microsoft.AspNetCore.Authentication @{ ViewData["Title"] = "Home Page"; } @@ -35,3 +36,25 @@ Sign in } + + + +

Claims

+ +
+ @foreach (var claim in User.Claims) + { +
@claim.Type
+
@claim.Value
+ } +
+ +

Properties

+ +
+ @foreach (var prop in (await Context.AuthenticateAsync()).Properties.Items) + { +
@prop.Key
+
@prop.Value
+ } +
diff --git a/src/sampleWebAsWebApiClient/appsettings.json b/src/sampleWebAsWebApiClient/appsettings.json index 8109d7a8..adb68b50 100755 --- a/src/sampleWebAsWebApiClient/appsettings.json +++ b/src/sampleWebAsWebApiClient/appsettings.json @@ -1,16 +1,25 @@ { - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Verbose", - "System": "Information", - "Microsoft": "Information" - } - }, - "Authentication": {  - "Yavsc": { - "ClientId": "2a3faf86-26e9-49f5-9473-6e6efaeeeac6", - "ClientSecret": "blahblah" - } + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" } -} \ No newline at end of file + }, + "AllowedHosts": "*", + "Authentication": { + "Yavsc" : { + "TokenEndpoint": "http://dev.pschneider.fr/connect/token", + "AuthorizationEndpoint": "http://dev.pschneider.fr/connect/authorize", + "ClientId": "interactive", + "ClientSecret": "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0" + } + }, + "Kestrel": { + "Endpoints": + { + "http": { + "Url": "https://localhost:5003" + } + } + } +} diff --git a/src/sampleWebAsWebApiClient/bower.json b/src/sampleWebAsWebApiClient/bower.json deleted file mode 100755 index fb3440bb..00000000 --- a/src/sampleWebAsWebApiClient/bower.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "testOauthClient", - "private": true, - "dependencies": { - "bootstrap": "3.3.5", - "jquery": "2.1.4", - "jquery-validation": "1.14.0", - "jquery-validation-unobtrusive": "3.2.4" - } -} diff --git a/src/sampleWebAsWebApiClient/gulpfile.js b/src/sampleWebAsWebApiClient/gulpfile.js deleted file mode 100755 index 82a0ead8..00000000 --- a/src/sampleWebAsWebApiClient/gulpfile.js +++ /dev/null @@ -1,64 +0,0 @@ -/// -"use strict"; - -var gulp = require("gulp"), - rimraf = require("rimraf"), - concat = require("gulp-concat"), - cssmin = require("gulp-cssmin"), - shell = require("gulp-shell"), - uglify = require("gulp-uglify"); - -var webroot = "./wwwroot/"; - -var paths = { - js: webroot + "js/**/*.js", - minJs: webroot + "js/**/*.min.js", - css: webroot + "css/**/*.css", - minCss: webroot + "css/**/*.min.css", - concatJsDest: webroot + "js/site.min.js", - concatCssDest: webroot + "css/site.min.css" -}; - -gulp.task("clean:js", function (cb) { - rimraf(paths.concatJsDest, cb); -}); - -gulp.task("clean:css", function (cb) { - rimraf(paths.concatCssDest, cb); -}); - -gulp.task("clean", ["clean:js", "clean:css"]); - -gulp.task("min:js", function () { - return gulp.src([paths.js, "!" + paths.minJs], { - base: "." - }) - .pipe(concat(paths.concatJsDest)) - .pipe(uglify()) - .pipe(gulp.dest(".")); -}); - -gulp.task("min:css", function () { - return gulp.src([paths.css, "!" + paths.minCss]) - .pipe(concat(paths.concatCssDest)) - .pipe(cssmin()) - .pipe(gulp.dest(".")); -}); - -gulp.task("min", ["min:js", "min:css"]); -gulp.task('watch', shell.task(['MONO_OPTIONS=--debug ASPNET_ENV=Development dnx-watch web --configuration=Debug --server.urls=http://*:5002'])) - -var program = "testOauthClient"; -var port = 55555; - -gulp.task('default', ['debug']); - -gulp.task('build', function() { - return gulp - .src('./**/*.cs') - .pipe(msc(['-fullpaths', '-debug', '-target:exe', '-out:' + program])); -}); - -gulp.task('debug', ['build'], function(done) { - return mono.debug({ port: port, program: program}, done); -}); \ No newline at end of file diff --git a/src/sampleWebAsWebApiClient/package.json b/src/sampleWebAsWebApiClient/package.json deleted file mode 100755 index f7ec97f4..00000000 --- a/src/sampleWebAsWebApiClient/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "licence": "GNU GPL v3", - "name": "test-oauth-client", - "version": "0.0.0", - "devDependencies": { - "gulp": "^3.9.1", - "gulp-concat": "^2.6.1", - "gulp-cssmin": "^0.2.0", - "gulp-uglify": "^3.0.0", - "rimraf": "^2.6.2" - } -} \ No newline at end of file diff --git a/src/sampleWebAsWebApiClient/project.json b/src/sampleWebAsWebApiClient/project.json deleted file mode 100755 index 731c76e7..00000000 --- a/src/sampleWebAsWebApiClient/project.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "emitEntryPoint": true - }, - "tooling": { - "defaultNamespace": "testOauthClient" - }, - "dependencies": { - "Yavsc.Abstract": { - "target": "project", - "type": "build" - }, - "Yavsc.Server": { - "target": "project", - "type": "build" - }, - "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final", - "Microsoft.AspNet.Authentication.OAuth": "1.0.0-rc1-final", - "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final", - "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final", - "Microsoft.AspNet.Mvc": "6.0.0-rc1-final", - "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final", - "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final", - "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final", - "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final", - "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final", - "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final", - "Microsoft.Extensions.Logging": "1.0.0-rc1-final", - "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final", - "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final", - "Newtonsoft.Json": "7.0.1" - }, - "commands": { - "web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:5002" - }, - "frameworks": { - "dnx451": { - "dependencies": { - "System.Json": "4.0.20126.16343" - } - } - }, - "exclude": [ - "wwwroot", - "node_modules", - "bower_components" - ], - "publishExclude": [ - "node_modules", - "bower_components", - "**.xproj", - "**.user", - "**.vspscc" - ], - "scripts": { - "prepublish": [ - "npm install", - "bower install", - "gulp clean", - "gulp min" - ], - "postrestore": [ - "grep -v '\\.\\.dll' project.lock.json > new.project.lock.json", - "mv new.project.lock.json project.lock.json" - ] - } -} diff --git a/src/sampleWebAsWebApiClient/sampleWebAsWebApiClient.csproj b/src/sampleWebAsWebApiClient/sampleWebAsWebApiClient.csproj new file mode 100644 index 00000000..0785b0d4 --- /dev/null +++ b/src/sampleWebAsWebApiClient/sampleWebAsWebApiClient.csproj @@ -0,0 +1,13 @@ + + + + + + + + + net8.0 + enable + enable + + \ No newline at end of file diff --git a/yavsc.sln b/yavsc.sln index b90a29f9..6aeb11cb 100644 --- a/yavsc.sln +++ b/yavsc.sln @@ -4,6 +4,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{503DDD6B-BE10-4235-9EBD-E9B1FA6067DF}" + ProjectSection(SolutionItems) = preProject + EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yavsc.Abstract", "src\Yavsc.Abstract\Yavsc.Abstract.csproj", "{5AFB6255-CF1B-4660-BB35-F24C8C75FECE}" EndProject @@ -11,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yavsc.Server", "src\Yavsc.S EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yavsc", "src\Yavsc\Yavsc.csproj", "{87DABC88-C38C-45DB-8F72-53B7C95ABC89}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sampleWebAsWebApiClient", "src\sampleWebAsWebApiClient\sampleWebAsWebApiClient.csproj", "{38AA74FE-3932-49C3-A382-338E7C861BB1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -32,10 +36,15 @@ Global {87DABC88-C38C-45DB-8F72-53B7C95ABC89}.Debug|Any CPU.Build.0 = Debug|Any CPU {87DABC88-C38C-45DB-8F72-53B7C95ABC89}.Release|Any CPU.ActiveCfg = Release|Any CPU {87DABC88-C38C-45DB-8F72-53B7C95ABC89}.Release|Any CPU.Build.0 = Release|Any CPU + {38AA74FE-3932-49C3-A382-338E7C861BB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38AA74FE-3932-49C3-A382-338E7C861BB1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38AA74FE-3932-49C3-A382-338E7C861BB1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38AA74FE-3932-49C3-A382-338E7C861BB1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {5AFB6255-CF1B-4660-BB35-F24C8C75FECE} = {503DDD6B-BE10-4235-9EBD-E9B1FA6067DF} {830F5A71-0192-4288-9F4D-D7849D958970} = {503DDD6B-BE10-4235-9EBD-E9B1FA6067DF} {87DABC88-C38C-45DB-8F72-53B7C95ABC89} = {503DDD6B-BE10-4235-9EBD-E9B1FA6067DF} + {38AA74FE-3932-49C3-A382-338E7C861BB1} = {503DDD6B-BE10-4235-9EBD-E9B1FA6067DF} EndGlobalSection EndGlobal