Skip to content

Commit e8d5fc6

Browse files
committed
feat: dynamicallly add authentication provider
1 parent 558bed2 commit e8d5fc6

File tree

65 files changed

+36125
-36
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+36125
-36
lines changed

.releaserc.json

+5-28
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,9 @@
11
{
22
"tagFormat": "${version}",
33
"noCi": true,
4-
"verifyConditions": [ "@semantic-release/changelog", "@semantic-release/git" ],
5-
"analyzeCommits": {
6-
"path": "@sien/commit-analyzer",
7-
"preset": "angular",
8-
"parserOpts": {
9-
"noteKeywords": [ "BREAKING CHANGE", "BREAKING CHANGES", "BREAKING" ]
10-
}
11-
},
12-
"verifyRelease": "@sien/verify-release",
13-
"prepare": [
14-
"@semantic-release/changelog",
15-
{
16-
"path": "@semantic-release/git",
17-
"assets": [ "CHANGELOG.md" ],
18-
"message": "chore(release): ${nextRelease.version} ***NO_CI***\n\n${nextRelease.notes}"
19-
}
20-
],
21-
"generateNotes": "@sien/release-note-generator",
22-
"publish": [],
23-
"success": [],
24-
"fail": [],
25-
"plugins": [
26-
["@semantic-release/commit-analyzer", {
27-
"preset": "angular",
28-
"parserOpts": {
29-
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]
30-
}
31-
}]]
4+
"verifyConditions": [ "@semantic-release/github", "@semantic-release/changelog", "@semantic-release/git" ],
5+
"analyzeCommits": "@semantic-release/commit-analyzer",
6+
"publish": "@semantic-release/github",
7+
"success": "@semantic-release/github",
8+
"fail": "@semantic-release/github"
329
}

DymamicAuthProviders.sln

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26124.0
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{245AA4AB-ECF4-4C69-B63D-C59D4B3F918C}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{8DE53FA4-6C58-4FE4-840C-8CD5D5370324}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{2925DB42-26E1-4584-952E-928CDC0473DB}"
11+
EndProject
12+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FDEACC74-E649-4B5B-8C44-F9E713C89B18}"
13+
ProjectSection(SolutionItems) = preProject
14+
.commitlintrc.json = .commitlintrc.json
15+
.npmrc = .npmrc
16+
.releaserc.json = .releaserc.json
17+
GitVersion.yml = GitVersion.yml
18+
README.md = README.md
19+
EndProjectSection
20+
EndProject
21+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aguacongas.AspNetCore.Authentication", "src\Aguacongas.AspNetCore.Authentication\Aguacongas.AspNetCore.Authentication.csproj", "{1A94B6E3-5AE2-4EF2-B023-11B8F8840742}"
22+
EndProject
23+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aguacongas.AspNetCore.Authentication.Test", "test\Aguacongas.AspNetCore.Authentication.Test\Aguacongas.AspNetCore.Authentication.Test.csproj", "{62FC7AE9-E522-4C65-9954-D3EC4C84B35E}"
24+
EndProject
25+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aguacongas.AspNetCore.Authentication.Sample", "sample\Aguacongas.AspNetCore.Authentication.Sample\Aguacongas.AspNetCore.Authentication.Sample.csproj", "{B5A1BB45-B621-4EE9-A409-306F4768D597}"
26+
EndProject
27+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aguacongas.AspNetCore.Authentication.EntityFramework", "src\Aguacongas.AspNetCore.Authentication.EntityFramework\Aguacongas.AspNetCore.Authentication.EntityFramework.csproj", "{8CC87457-C579-4E39-A1C4-BAADADF500DE}"
28+
EndProject
29+
Global
30+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
31+
Debug|Any CPU = Debug|Any CPU
32+
Release|Any CPU = Release|Any CPU
33+
EndGlobalSection
34+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
35+
{1A94B6E3-5AE2-4EF2-B023-11B8F8840742}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{1A94B6E3-5AE2-4EF2-B023-11B8F8840742}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{1A94B6E3-5AE2-4EF2-B023-11B8F8840742}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{1A94B6E3-5AE2-4EF2-B023-11B8F8840742}.Release|Any CPU.Build.0 = Release|Any CPU
39+
{62FC7AE9-E522-4C65-9954-D3EC4C84B35E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
40+
{62FC7AE9-E522-4C65-9954-D3EC4C84B35E}.Debug|Any CPU.Build.0 = Debug|Any CPU
41+
{62FC7AE9-E522-4C65-9954-D3EC4C84B35E}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{62FC7AE9-E522-4C65-9954-D3EC4C84B35E}.Release|Any CPU.Build.0 = Release|Any CPU
43+
{B5A1BB45-B621-4EE9-A409-306F4768D597}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
44+
{B5A1BB45-B621-4EE9-A409-306F4768D597}.Debug|Any CPU.Build.0 = Debug|Any CPU
45+
{B5A1BB45-B621-4EE9-A409-306F4768D597}.Release|Any CPU.ActiveCfg = Release|Any CPU
46+
{B5A1BB45-B621-4EE9-A409-306F4768D597}.Release|Any CPU.Build.0 = Release|Any CPU
47+
{8CC87457-C579-4E39-A1C4-BAADADF500DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
48+
{8CC87457-C579-4E39-A1C4-BAADADF500DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
49+
{8CC87457-C579-4E39-A1C4-BAADADF500DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
50+
{8CC87457-C579-4E39-A1C4-BAADADF500DE}.Release|Any CPU.Build.0 = Release|Any CPU
51+
EndGlobalSection
52+
GlobalSection(SolutionProperties) = preSolution
53+
HideSolutionNode = FALSE
54+
EndGlobalSection
55+
GlobalSection(NestedProjects) = preSolution
56+
{1A94B6E3-5AE2-4EF2-B023-11B8F8840742} = {245AA4AB-ECF4-4C69-B63D-C59D4B3F918C}
57+
{62FC7AE9-E522-4C65-9954-D3EC4C84B35E} = {8DE53FA4-6C58-4FE4-840C-8CD5D5370324}
58+
{B5A1BB45-B621-4EE9-A409-306F4768D597} = {2925DB42-26E1-4584-952E-928CDC0473DB}
59+
{8CC87457-C579-4E39-A1C4-BAADADF500DE} = {245AA4AB-ECF4-4C69-B63D-C59D4B3F918C}
60+
EndGlobalSection
61+
GlobalSection(ExtensibilityGlobals) = postSolution
62+
SolutionGuid = {823D9407-93C0-443E-89EC-D9DBB006A195}
63+
EndGlobalSection
64+
EndGlobal

create-git-hook.cmd

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
6+
</PropertyGroup>
7+
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.App" />
11+
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
12+
</ItemGroup>
13+
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\..\src\Aguacongas.AspNetCore.Authentication\Aguacongas.AspNetCore.Authentication.csproj" />
17+
</ItemGroup>
18+
19+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Mvc;
7+
using Aguacongas.AspNetCore.Authentication.Sample.Models;
8+
9+
namespace Aguacongas.AspNetCore.Authentication.Sample.Controllers
10+
{
11+
public class HomeController : Controller
12+
{
13+
public IActionResult Index()
14+
{
15+
return View();
16+
}
17+
18+
public IActionResult Privacy()
19+
{
20+
return View();
21+
}
22+
23+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
24+
public IActionResult Error()
25+
{
26+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace Aguacongas.AspNetCore.Authentication.Sample.Models
4+
{
5+
public class ErrorViewModel
6+
{
7+
public string RequestId { get; set; }
8+
9+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Logging;
10+
11+
namespace Aguacongas.AspNetCore.Authentication.Sample
12+
{
13+
public class Program
14+
{
15+
public static void Main(string[] args)
16+
{
17+
CreateWebHostBuilder(args).Build().Run();
18+
}
19+
20+
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
21+
WebHost.CreateDefaultBuilder(args)
22+
.UseStartup<Startup>();
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.AspNetCore.Http;
8+
using Microsoft.AspNetCore.HttpsPolicy;
9+
using Microsoft.AspNetCore.Mvc;
10+
using Microsoft.Extensions.Configuration;
11+
using Microsoft.Extensions.DependencyInjection;
12+
13+
namespace Aguacongas.AspNetCore.Authentication.Sample
14+
{
15+
public class Startup
16+
{
17+
public Startup(IConfiguration configuration)
18+
{
19+
Configuration = configuration;
20+
}
21+
22+
public IConfiguration Configuration { get; }
23+
24+
// This method gets called by the runtime. Use this method to add services to the container.
25+
public void ConfigureServices(IServiceCollection services)
26+
{
27+
services.Configure<CookiePolicyOptions>(options =>
28+
{
29+
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
30+
options.CheckConsentNeeded = context => true;
31+
options.MinimumSameSitePolicy = SameSiteMode.None;
32+
});
33+
34+
35+
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
36+
}
37+
38+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
39+
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
40+
{
41+
if (env.IsDevelopment())
42+
{
43+
app.UseDeveloperExceptionPage();
44+
}
45+
else
46+
{
47+
app.UseExceptionHandler("/Home/Error");
48+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
49+
app.UseHsts();
50+
}
51+
52+
app.UseHttpsRedirection();
53+
app.UseStaticFiles();
54+
app.UseCookiePolicy();
55+
56+
app.UseMvc(routes =>
57+
{
58+
routes.MapRoute(
59+
name: "default",
60+
template: "{controller=Home}/{action=Index}/{id?}");
61+
});
62+
}
63+
}
64+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@{
2+
ViewData["Title"] = "Home Page";
3+
}
4+
5+
<div class="text-center">
6+
<h1 class="display-4">Welcome</h1>
7+
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
8+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@{
2+
ViewData["Title"] = "Privacy Policy";
3+
}
4+
<h1>@ViewData["Title"]</h1>
5+
6+
<p>Use this page to detail your site's privacy policy.</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@model ErrorViewModel
2+
@{
3+
ViewData["Title"] = "Error";
4+
}
5+
6+
<h1 class="text-danger">Error.</h1>
7+
<h2 class="text-danger">An error occurred while processing your request.</h2>
8+
9+
@if (Model.ShowRequestId)
10+
{
11+
<p>
12+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
13+
</p>
14+
}
15+
16+
<h3>Development Mode</h3>
17+
<p>
18+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
19+
</p>
20+
<p>
21+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
22+
It can result in displaying sensitive information from exceptions to end users.
23+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
24+
and restarting the app.
25+
</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@using Microsoft.AspNetCore.Http.Features
2+
3+
@{
4+
var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
5+
var showBanner = !consentFeature?.CanTrack ?? false;
6+
var cookieString = consentFeature?.CreateConsentCookie();
7+
}
8+
9+
@if (showBanner)
10+
{
11+
<div id="cookieConsent" class="alert alert-info alert-dismissible fade show" role="alert">
12+
Use this space to summarize your privacy and cookie use policy. <a asp-area="" asp-controller="Home" asp-action="Privacy">Learn More</a>.
13+
<button type="button" class="accept-policy close" data-dismiss="alert" aria-label="Close" data-cookie-string="@cookieString">
14+
<span aria-hidden="true">Accept</span>
15+
</button>
16+
</div>
17+
<script>
18+
(function () {
19+
var button = document.querySelector("#cookieConsent button[data-cookie-string]");
20+
button.addEventListener("click", function (event) {
21+
document.cookie = button.dataset.cookieString;
22+
}, false);
23+
})();
24+
</script>
25+
}

0 commit comments

Comments
 (0)