diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 71badf6b..00000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,67 +0,0 @@ -# Please find the full example project here: -# https://gitlab.com/tobiaskoch/gitlab-ci-example-mono - -# see https://hub.docker.com/_/mono/ -image: mono:4.6.2.7 - -stages: - - build - - test - - deploy - -before_script: - - . /opt/mono-4.6/mono-env - - export GIT_SSL_NO_VERIFY=true - - curl --insecure -sSL https://lua.pschneider.fr/files/Paul/pub/dnx-install.sh | bash - - DNX_USER_HOME=`pwd -P`/dnx . ./dnx/dnvm/dnvm.sh - - cd src/OAuth.AspNet.Token && dnu restore --ignore-failed-sources - - cd ../OAuth.AspNet.AuthServer && dnu restore --ignore-failed-sources - - cd ../Yavsc.Abstract && dnu restore --ignore-failed-sources - - cd ../Yavsc.Server && dnu restore --ignore-failed-sources - - cd ../Yavsc && dnu restore --ignore-failed-sources - - cd ../cli && dnu restore --ignore-failed-sources - - cd ../../test/yavscTests && dnu restore --ignore-failed-sources - - cd ../.. - -after_script: - -debug: - stage: build - artifacts: - paths: - - test/yavscTests/bin - script: - - cd test/yavscTests - - dnu build - -non_reg: - stage: test - artifacts: - paths: - - test/yavscTests/test-results.xml - when: always - script: - - cd test/yavscTests - - cp $yavsc_client_secret_json yavsc-client-secret.json - - ASPNET_ENV=Development dnx test -trait ategory=non_reg -maxthreads 1 -xml test-results.xml - -release: - stage: deploy - only: - - vnext - artifacts: - paths: - - binaries/Debug - script: - - make packages - -deploy_staging: - stage: deploy - script: - - echo "Deploy to staging server" - - make strip_yavscd - - make packages - - isn push -s $ISNSOURCE -k $NUGETSOURCEAPIKEY src/Yavsc.Abstract/bin/*/*.nupkg - environment: - name: staging - url: https://yavscpre.pschneider.fr diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config deleted file mode 100644 index 3082130d..00000000 --- a/.nuget/NuGet.Config +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/.nuget/packages.config b/.nuget/packages.config deleted file mode 100644 index eaeeed58..00000000 --- a/.nuget/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2a523d6b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: csharp -os: linux -mono: -- beta -sudo: false -install: -- curl --insecure -sSL https://lua.pschneider.fr/files/Paul/pub/dnx-install.sh | bash -- DNX_USER_HOME=`pwd -P`/dnx . ./dnx/dnvm/dnvm.sh -- cd src/OAuth.AspNet.Token && dnu restore --ignore-failed-sources -- cd ../OAuth.AspNet.AuthServer && dnu restore --ignore-failed-sources -- cd ../Yavsc.Abstract && dnu restore --ignore-failed-sources -- cd ../Yavsc.Server && dnu restore --ignore-failed-sources -- cd ../Yavsc && dnu restore --ignore-failed-sources -- cd ../test -- make restore -- make -- cd ../.. -- make - -script: -- "dnu build" - diff --git a/global.json b/global.json index f2fb072c..030b02f6 100644 --- a/global.json +++ b/global.json @@ -1,11 +1,6 @@ { - "projects": [ - "src", - "test" - ], "sdk": { "runtime": "dotnet", "version": "8.0.405" - }, - "packages": "packages" + } } diff --git a/src/Api/Program.cs b/src/Api/Program.cs index b997878c..a638add4 100644 --- a/src/Api/Program.cs +++ b/src/Api/Program.cs @@ -87,17 +87,19 @@ internal class Program app .UseRouting() .UseAuthentication() - .UseAuthorization().UseCors("default") + .UseAuthorization() + .UseCors("default") .UseEndpoints(endpoints => { endpoints.MapDefaultControllerRoute() .RequireAuthorization(); }); - app.MapIdentityApi().RequireAuthorization("ApiScope"); + app.MapIdentityApi().RequireAuthorization("ApiScope"); - app.MapGet("/identity", (HttpContext context) => - new JsonResult(context?.User?.Claims.Select(c => new { c.Type, c.Value })) - ).RequireAuthorization("ApiScope"); + app.MapGet("/identity", (HttpContext context) => + new JsonResult(context?.User?.Claims.Select(c => new { c.Type, c.Value })) + ); + app.UseSession(); await app.RunAsync(); }; diff --git a/src/Api/Properties/launchSettings.json b/src/Api/Properties/launchSettings.json new file mode 100644 index 00000000..c419c2c8 --- /dev/null +++ b/src/Api/Properties/launchSettings.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "https://localhost:5001", + "sslPort": 6001 + } + }, + "profiles": { + + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:6001;", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Yavsc/Extensions/HostingExtensions.cs b/src/Yavsc/Extensions/HostingExtensions.cs index 1158b8d2..251d9e3f 100644 --- a/src/Yavsc/Extensions/HostingExtensions.cs +++ b/src/Yavsc/Extensions/HostingExtensions.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using System.Globalization; using System.Security.Cryptography.X509Certificates; using Google.Apis.Util.Store; @@ -144,11 +145,9 @@ public static class HostingExtensions o.EnableDetailedErrors = true; }); - AddIdentityDBAndStores(builder).AddDefaultTokenProviders();; - - AddIdentityServer(builder).AddProfileService(); - //services.AddScoped(); - + AddIdentityDBAndStores(builder).AddDefaultTokenProviders(); + AddIdentityServer(builder); + services.AddSession(); // TODO .AddServerSideSessionStore() @@ -329,14 +328,17 @@ public static class HostingExtensions .AddInMemoryClients(Config.Clients) .AddInMemoryApiScopes(Config.ApiScopes) .AddAspNetIdentity() - .AddJwtBearerClientAuthentication(); + // .AddProfileService() + .AddJwtBearerClientAuthentication() + ; if (builder.Environment.IsDevelopment()) { identityServerBuilder.AddDeveloperSigningCredential(); } else { - var key = builder.Configuration["YOUR-KEY-NAME"]; + var key = builder.Configuration["YavscSigningCert"]; + Debug.Assert(key != null); var pfxBytes = Convert.FromBase64String(key); var cert = new X509Certificate2(pfxBytes, (string)null, X509KeyStorageFlags.MachineKeySet); identityServerBuilder.AddSigningCredential(cert); diff --git a/src/Yavsc/Properties/launchSettings.json b/src/Yavsc/Properties/launchSettings.json index c7aa64d5..a78ff8ae 100644 --- a/src/Yavsc/Properties/launchSettings.json +++ b/src/Yavsc/Properties/launchSettings.json @@ -1,27 +1,19 @@ -{ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", "iisSettings": { "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:30089", - "sslPort": 44391 + "applicationUrl": "https://localhost:5001", + "sslPort": 5001 } }, "profiles": { - "http": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "applicationUrl": "http://localhost:5172", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, "https": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:7062;http://localhost:5172", + "applicationUrl": "https://localhost:5001;", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Yavsc/ScaffoldingReadMe.txt b/src/Yavsc/ScaffoldingReadMe.txt deleted file mode 100644 index 6e6208dc..00000000 --- a/src/Yavsc/ScaffoldingReadMe.txt +++ /dev/null @@ -1,3 +0,0 @@ -Support for ASP.NET Core Identity was added to your project. - -For setup and configuration information, see https://go.microsoft.com/fwlink/?linkid=2116645. diff --git a/src/Yavsc/Views/Shared/Error.cshtml b/src/Yavsc/Views/Shared/Error.cshtml index d5a8de36..3bfd9196 100644 --- a/src/Yavsc/Views/Shared/Error.cshtml +++ b/src/Yavsc/Views/Shared/Error.cshtml @@ -12,14 +12,3 @@ Request ID: @Model.RequestId

} - -

Development Mode

-

- Swapping to Development environment will display more detailed information about the error that occurred. -

-

- The Development environment shouldn't be enabled for deployed applications. - It can result in displaying sensitive information from exceptions to end users. - For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development - and restarting the app. -

diff --git a/src/Yavsc/package.json b/src/Yavsc/package.json deleted file mode 100644 index 545fc0a6..00000000 --- a/src/Yavsc/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "yavsc", - "version": "1.0.7", - "description": "Yet Another Very Small Company", - "repository": { - "type": "Git", - "url": "https://github.com/pazof/yavsc" - }, - "license": "GPL-3.0", - "devDependencies": {}, - "dependencies": { - "paypal-permissions-sdk": "^1.0.10" - } -} diff --git a/src/sampleWebAsWebApiClient/Controllers/HomeController.cs b/src/sampleWebAsWebApiClient/Controllers/HomeController.cs index 46ea870b..70d64c58 100755 --- a/src/sampleWebAsWebApiClient/Controllers/HomeController.cs +++ b/src/sampleWebAsWebApiClient/Controllers/HomeController.cs @@ -71,7 +71,7 @@ namespace testOauthClient.Controllers var accessToken = await HttpContext.GetTokenAsync("access_token"); var client = new HttpClient(new HttpClientHandler(){ AllowAutoRedirect=false }); client.DefaultRequestHeaders.Add("Accept", "application/json"); - client.SetBearerToken(accessToken); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); var content = await client.GetAsync("https://localhost:6001/identity"); content.EnsureSuccessStatusCode(); var json = await content.Content.ReadAsStreamAsync(); diff --git a/src/sampleWebAsWebApiClient/Program.cs b/src/sampleWebAsWebApiClient/Program.cs index 966579dd..2aab156a 100644 --- a/src/sampleWebAsWebApiClient/Program.cs +++ b/src/sampleWebAsWebApiClient/Program.cs @@ -1,19 +1,56 @@ -using Microsoft.AspNetCore.Authentication.OAuth; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; +/* + Copyright (c) 2024 HigginsSoft, Alexander Higgins - https://github.com/alexhiggins732/ - public class Program + Copyright (c) 2018, Brock Allen & Dominick Baier. All rights reserved. + + Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. + Source code and license this software can be found + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. +*/ + +using System.IdentityModel.Tokens.Jwt; + +JwtSecurityTokenHandler.DefaultMapInboundClaims = false; + + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddControllersWithViews(); +builder.Services + .AddAuthentication(options => { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); - } + options.DefaultScheme = "Cookies"; + options.DefaultChallengeScheme = "oidc"; + }) + .AddCookie("Cookies") + .AddOpenIdConnect("oidc", options => + { + options.Authority = "https://localhost:5001"; + + options.ClientId = "mvc"; + options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0"; + options.ResponseType = "code"; + + options.Scope.Add("scope2"); + + options.SaveTokens = true; + }); + + +using (var app = builder.Build()) +{ + if (app.Environment.IsDevelopment()) + app.UseDeveloperExceptionPage(); + else + app.UseExceptionHandler("/Home/Error"); + + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); + app.UseAuthorization(); + app.MapDefaultControllerRoute().RequireAuthorization(); + + await app.RunAsync(); +} diff --git a/src/sampleWebAsWebApiClient/Startup.cs b/src/sampleWebAsWebApiClient/Startup.cs deleted file mode 100644 index deb2a39c..00000000 --- a/src/sampleWebAsWebApiClient/Startup.cs +++ /dev/null @@ -1,76 +0,0 @@ -using IdentityModel; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.IdentityModel.Tokens; -using System.IdentityModel.Tokens.Jwt; -using Yavsc; - -public class Startup -{ - public void ConfigureServices(IServiceCollection services) - { - - services.AddControllersWithViews(); - services - .AddAuthentication(options => - { - options.DefaultScheme = "Cookies"; - options.DefaultChallengeScheme = "oidc"; - }) - .AddCookie("Cookies") - .AddOpenIdConnect("oidc", options => - { - options.Authority = "https://localhost:5001"; - - options.ClientId = "mvc"; - options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0"; - options.ResponseType = "code"; - - options.Scope.Add("scope2"); - - options.SaveTokens = true; - - options.GetClaimsFromUserInfoEndpoint = true; - options.SaveTokens = true; - options.ClaimActions.MapUniqueJsonKey( - Constants.RoleClaimName, - Constants.RoleClaimName); - options.ClaimActions.MapUniqueJsonKey( - JwtClaimTypes.Scope, - JwtClaimTypes.Scope); - options.TokenValidationParameters = new TokenValidationParameters - { - NameClaimType = "name", - RoleClaimType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role" - }; - }); - - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Home/Error"); - } - - app.UseStaticFiles(); - - app.UseRouting(); - app.UseAuthentication(); - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapDefaultControllerRoute() - .RequireAuthorization(); - }); - } -} diff --git a/yavsc.code-workspace b/yavsc.code-workspace deleted file mode 100644 index 29367081..00000000 --- a/yavsc.code-workspace +++ /dev/null @@ -1,38 +0,0 @@ -{ - "folders": [ - { - "path": ".vscode" - }, - { - "path": "." - }, - { - "path": "src/test" - }, - { - "path": "src/Yavsc" - }, - { - "path": "src/cli" - }, - { - "path": "src/GoogleCode" - }, - { - "path": "src/OAuth.AspNet.AuthServer" - }, - { - "path": "src/OAuth.AspNet.Token" - }, - { - "path": "src/Yavsc.Abstract" - }, - { - "path": "src/Yavsc.Server" - } - ], - "settings": { - "mocha.enabled": true, - "git.ignoreLimitWarning": true - } -} \ No newline at end of file diff --git a/yavsc.mdw b/yavsc.mdw deleted file mode 100644 index 45b134a7..00000000 --- a/yavsc.mdw +++ /dev/null @@ -1,6 +0,0 @@ - - - ZicMoove.sln - yagui/yagui.sln - - \ No newline at end of file