Skip to content

Commit

Permalink
Merge pull request #17 from jkmu/Upgrade-to-Net5.0
Browse files Browse the repository at this point in the history
Upgrade to net5.0
  • Loading branch information
jkmu authored May 21, 2021
2 parents 010b8e5 + 0a7c6d6 commit 23b6dc9
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 172 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("Id");

b.HasIndex("NormalizedName")
.HasName("RoleNameIndex");
.HasDatabaseName("RoleNameIndex");

b.ToTable("AspNetRoles");
});
Expand Down Expand Up @@ -165,11 +165,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasKey("Id");

b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
.HasDatabaseName("EmailIndex");

b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
.HasDatabaseName("UserNameIndex");

b.ToTable("AspNetUsers");
});
Expand Down
12 changes: 6 additions & 6 deletions Source/DemoWebApp/DemoWebApp.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>aspnet-DemoWebApp-C260B8F3-E5A3-4A4D-B57A-771F079933AA</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.6" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 0 additions & 7 deletions Source/DemoWebApp/Views/Home/About.cshtml

This file was deleted.

17 changes: 0 additions & 17 deletions Source/DemoWebApp/Views/Home/Contact.cshtml

This file was deleted.

118 changes: 18 additions & 100 deletions Source/DemoWebApp/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,106 +1,24 @@
@{
@using System.Security.Claims
@{
ViewData["Title"] = "Home Page";
}

<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
<li data-target="#myCarousel" data-slide-to="3"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="~/images/banner1.svg" alt="ASP.NET" class="img-responsive" />
<div class="carousel-caption" role="option">
<p>
Learn how to build ASP.NET apps that can run anywhere.
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525028&clcid=0x409">
Learn More
</a>
</p>
</div>
</div>
<div class="item">
<img src="~/images/banner2.svg" alt="Visual Studio" class="img-responsive" />
<div class="carousel-caption" role="option">
<p>
There are powerful new features in Visual Studio for building modern web apps.
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525030&clcid=0x409">
Learn More
</a>
</p>
</div>
</div>
<div class="item">
<img src="~/images/banner3.svg" alt="Package Management" class="img-responsive" />
<div class="carousel-caption" role="option">
<p>
Bring in libraries from NuGet and npm, and automate tasks using Grunt or Gulp.
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525029&clcid=0x409">
Learn More
</a>
</p>
</div>
</div>
<div class="item">
<img src="~/images/banner4.svg" alt="Microsoft Azure" class="img-responsive" />
<div class="carousel-caption" role="option">
<p>
Learn how Microsoft's Azure cloud platform allows you to build, deploy, and scale web apps.
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525027&clcid=0x409">
Learn More
</a>
</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>

<div class="row">
<div class="col-md-3">
<h2>Application uses</h2>
<ul>
<li>Sample pages using ASP.NET Core MVC</li>
<li>Theming using <a href="https://go.microsoft.com/fwlink/?LinkID=398939">Bootstrap</a></li>
</ul>
</div>
<div class="col-md-3">
<h2>How to</h2>
<ul>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li>
</ul>
</div>
<div class="col-md-3">
<h2>Overview</h2>
<ul>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li>
</ul>
</div>
<div class="col-md-3">
<h2>Run &amp; Deploy</h2>
<hr/>
@if (Context.User.Identities.Any(i => i.IsAuthenticated))
{
<p>User is logged in as <strong>@Context.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Name)?.Value</strong></p>
<p>Claims:</p>
<ul>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a></li>
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li>
@foreach (var claim in Context.User.Claims)
{
<li>@claim.Type: <strong>@claim.Value</strong></li>
}
</ul>
</div>
</div>
}
else
{
<p>User is not logged in</p>
}

</div>
2 changes: 1 addition & 1 deletion Source/DemoWebApp/Views/Manage/ChangePassword.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}

<h4>@ViewData["Title"]</h4>
@Html.Partial("_StatusMessage", Model.StatusMessage)
@Html.PartialAsync("_StatusMessage", Model.StatusMessage)
<div class="row">
<div class="col-md-6">
<form method="post">
Expand Down
2 changes: 1 addition & 1 deletion Source/DemoWebApp/Views/Manage/ExternalLogins.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
ViewData.AddActivePage(ManageNavPages.ExternalLogins);
}

@Html.Partial("_StatusMessage", Model.StatusMessage)
@Html.PartialAsync("_StatusMessage", Model.StatusMessage)
@if (Model.CurrentLogins?.Count > 0)
{
<h4>Registered Logins</h4>
Expand Down
2 changes: 1 addition & 1 deletion Source/DemoWebApp/Views/Manage/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}

<h4>@ViewData["Title"]</h4>
@Html.Partial("_StatusMessage", Model.StatusMessage)
@Html.PartialAsync("_StatusMessage", Model.StatusMessage)
<div class="row">
<div class="col-md-6">
<form method="post">
Expand Down
2 changes: 1 addition & 1 deletion Source/DemoWebApp/Views/Manage/SetPassword.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
}

<h4>Set your password</h4>
@Html.Partial("_StatusMessage", Model.StatusMessage)
@Html.PartialAsync("_StatusMessage", Model.StatusMessage)
<p class="text-info">
You do not have a local username/password for this site. Add a local
account so you can log in without an external login.
Expand Down
5 changes: 0 additions & 5 deletions Source/DemoWebApp/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@
<a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand">DemoWebApp</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a asp-area="" asp-controller="Home" asp-action="Index">Home</a></li>
<li><a asp-area="" asp-controller="Home" asp-action="About">About</a></li>
<li><a asp-area="" asp-controller="Home" asp-action="Contact">Contact</a></li>
</ul>
@await Html.PartialAsync("_LoginPartial")
</div>
</div>
Expand Down
17 changes: 8 additions & 9 deletions Source/Saml2.Authentication.Core/Authentication/Saml2Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task SignOutAsync(AuthenticationProperties properties)
_logger.LogDebug($"Entering {nameof(SignOutAsync)}", properties);

var logoutRequestId = CreateUniqueId();
properties = properties ?? new AuthenticationProperties();
properties ??= new AuthenticationProperties();

properties.Items.Add(LogoutRequestIdKey, logoutRequestId);
properties.Items.Add(nameof(Options.SignOutScheme), Options.SignOutScheme);
Expand All @@ -88,7 +88,7 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop
{
_logger.LogDebug($"Entering {nameof(HandleChallengeAsync)}", properties);

properties = properties ?? new AuthenticationProperties();
properties ??= new AuthenticationProperties();

var authnRequestId = CreateUniqueId();
properties.Items.Add(AuthnRequestIdKey, authnRequestId);
Expand All @@ -103,9 +103,9 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop

private async Task<bool> HandleSignOut()
{
if (!Request.Path.Value.EndsWith(ServiceProviderConfiguration.SingleLogoutServiceUrl, StringComparison.OrdinalIgnoreCase)
|| !Request.Path.Value.EndsWith(ServiceProviderConfiguration.SingleLogoutResponseServiceUrl, StringComparison.OrdinalIgnoreCase)
|| !_httpRedirectBinding.IsValid())
if (Request.Path.Value != null && (!Request.Path.Value.EndsWith(ServiceProviderConfiguration.SingleLogoutServiceUrl, StringComparison.OrdinalIgnoreCase)
|| !Request.Path.Value.EndsWith(ServiceProviderConfiguration.SingleLogoutResponseServiceUrl, StringComparison.OrdinalIgnoreCase)
|| !_httpRedirectBinding.IsValid()))
{
return false;
}
Expand Down Expand Up @@ -146,8 +146,7 @@ private async Task<bool> HandleSignOut()

private async Task<bool> HandleSignIn()
{
if (!Request.Path.Value.EndsWith(ServiceProviderConfiguration.AssertionConsumerServiceUrl, StringComparison.OrdinalIgnoreCase)
|| !_httpRedirectBinding.IsValid())
if (Request.Path.Value != null && (!Request.Path.Value.EndsWith(ServiceProviderConfiguration.AssertionConsumerServiceUrl, StringComparison.OrdinalIgnoreCase) || !_httpRedirectBinding.IsValid()))
{
return false;
}
Expand All @@ -172,8 +171,8 @@ private async Task<bool> HandleSignIn()

private async Task<bool> HandleHttpArtifact(string providerName)
{
if (!Request.Path.Value.EndsWith(ServiceProviderConfiguration.AssertionConsumerServiceUrl, StringComparison.OrdinalIgnoreCase)
|| !_httpArtifactBinding.IsValid())
if (Request.Path.Value != null && (!Request.Path.Value.EndsWith(ServiceProviderConfiguration.AssertionConsumerServiceUrl, StringComparison.OrdinalIgnoreCase)
|| !_httpArtifactBinding.IsValid()))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System;
using System.IO;
using System.Xml;
using Configuration;
using dk.nita.saml20.Utils;
using Extensions;
using Microsoft.AspNetCore.Http;
Expand All @@ -20,7 +19,6 @@ internal class HttpArtifactBinding : HttpSoapBinding, IHttpArtifactBinding

public HttpArtifactBinding(
IHttpContextAccessor httpContextAccessor,
Saml2Configuration configuration,
IConfigurationProvider configurationProvider)
{
_httpContextAccessor = httpContextAccessor;
Expand Down
15 changes: 3 additions & 12 deletions Source/Saml2.Authentication.Core/Bindings/HttpRedirectBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ public bool IsValid()
return false;
}

var form = Request.Form;
return form != null && form.ContainsKey(SamlResponseQueryKey);
return Request.Form.ContainsKey(SamlResponseQueryKey);
}

public bool IsLogoutRequest()
Expand All @@ -85,8 +84,7 @@ public bool IsLogoutRequest()
return false;
}

var form = Request.Form;
return form != null && form.ContainsKey(SamlRequestQueryKey);
return Request.Form.ContainsKey(SamlRequestQueryKey);
}

public Saml2Response GetResponse()
Expand All @@ -106,11 +104,6 @@ public Saml2Response GetResponse()
}

var form = Request.Form;
if (form == null)
{
return null;
}

return new Saml2Response
{
Response = form[SamlResponseQueryKey],
Expand All @@ -130,9 +123,7 @@ public string GetCompressedRelayState()
return null;
}

var form = Request.Form;

return form?[SamlRelayStateQueryKey].ToString();
return Request.Form?[SamlRelayStateQueryKey].ToString();
}

public string BuildAuthnRequestUrl(string providerName, Saml2AuthnRequest saml2AuthnRequest, string relayState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public Saml2PostConfigureOptions(IDataProtectionProvider dataProtectionProvider)

public void PostConfigure(string name, Saml2Options options)
{
options.DataProtectionProvider = options.DataProtectionProvider ?? _dataProtectionProvider;
options.DataProtectionProvider ??= _dataProtectionProvider;

if (string.IsNullOrEmpty(options.SignOutScheme))
{
Expand Down
Loading

0 comments on commit 23b6dc9

Please sign in to comment.