Skip to content

Commit

Permalink
Fixing the Web template: (#118)
Browse files Browse the repository at this point in the history
- added references to Microsoft.Identity.Web.UI in the **Startup.cs** (using Microsoft.Identity.Web.UI and call to AddMicrosoftIdentityUI())
- added package reference to  Microsoft.Identity.Web.UI in the web app project
- changed the metadata of the template (mvc2) to mention Microsof identity platform and explicit Microsoft.Identity.Web

Fixing the Web API (reference to Microsoft.Identity.Web)

Renaming the generated NuGet package for the templates so that it starts with Microsoft.Identity.Web (Microsoft.Identity.Web.ProjectTemplates)
  • Loading branch information
jmprieur authored Apr 22, 2020
1 parent 7a4ab81 commit 15c468c
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 55 deletions.
14 changes: 7 additions & 7 deletions Microsoft.Identity.Web.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Test
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DotNet Core Templates", "DotNet Core Templates", "{D845507B-00E8-4506-954E-519CBC0B9F83}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreMicrosoftIdentityPlatformTemplates", "ProjectTemplates\AspNetCoreMicrosoftIdentityPlatformTemplates.csproj", "{257F7E59-326F-4749-9019-4384DDEBCD3A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2B919DEC-2539-4357-8E89-8C0CC9889FB4}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreMicrosoftIdentityWebProjectTemplates", "ProjectTemplates\AspNetCoreMicrosoftIdentityWebProjectTemplates.csproj", "{893905EA-94D6-4F71-957A-43B194751DC7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -87,10 +87,10 @@ Global
{A9F4539F-51AB-4D98-9204-D76B336E0BE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9F4539F-51AB-4D98-9204-D76B336E0BE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9F4539F-51AB-4D98-9204-D76B336E0BE8}.Release|Any CPU.Build.0 = Release|Any CPU
{257F7E59-326F-4749-9019-4384DDEBCD3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{257F7E59-326F-4749-9019-4384DDEBCD3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{257F7E59-326F-4749-9019-4384DDEBCD3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{257F7E59-326F-4749-9019-4384DDEBCD3A}.Release|Any CPU.Build.0 = Release|Any CPU
{893905EA-94D6-4F71-957A-43B194751DC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{893905EA-94D6-4F71-957A-43B194751DC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{893905EA-94D6-4F71-957A-43B194751DC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{893905EA-94D6-4F71-957A-43B194751DC7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -106,7 +106,7 @@ Global
{24DE8503-90EB-4788-A603-681DD4D7DB50} = {79310504-1334-4F14-93C4-1240913224BA}
{F37646FF-C346-4FF5-A111-2269952AB376} = {79310504-1334-4F14-93C4-1240913224BA}
{A9F4539F-51AB-4D98-9204-D76B336E0BE8} = {79310504-1334-4F14-93C4-1240913224BA}
{257F7E59-326F-4749-9019-4384DDEBCD3A} = {D845507B-00E8-4506-954E-519CBC0B9F83}
{893905EA-94D6-4F71-957A-43B194751DC7} = {D845507B-00E8-4506-954E-519CBC0B9F83}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F4FA8C4C-3251-41CC-939B-7892F5798549}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<PackageType>Template</PackageType>
<PackageVersion>0.1.0</PackageVersion>
<PackageId>Microsoft.IdentityPlatform.Templates</PackageId>
<PackageId>Microsoft.Identity.Web.ProjectTemplates</PackageId>
<Title>ASP.NET Core Web app and Web API templates with Microsoft identity platform</Title>
<Authors>Microsoft</Authors>
<Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"Web",
"MVC"
],
"name": "ASP.NET Core Web App (Model-View-Controller)",
"name": "ASP.NET Core Web App (Model-View-Controller, Microsoft identity platform)",
"generatorVersions": "[1.0.0.0-*)",
"description": "A project template for creating an ASP.NET Core application with example ASP.NET Core MVC Views and Controllers. This template can also be used for RESTful HTTP services.",
"groupIdentity": "Microsoft.Web.Mvc",
"groupIdentity": "Microsoft.Identity.Web.Mvc",
"precedence": "7000",
"identity": "Microsoft.Web.Mvc.CSharp.5.0",
"identity": "Microsoft.Identity.Web.Mvc.CSharp.5.0",
"shortName": "mvc2",
"thirdPartyNotices": "https://aka.ms/aspnetcore/5.0-third-party-notices",
"tags": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Identity.Web" Version="0.1.0-localbuild" />
<PackageReference Include="Microsoft.Identity.Web" Version="0.1.0-preview" />
<PackageReference Include="Microsoft.Identity.Web.UI" Version="0.1.0-preview" />
</ItemGroup>
</Project>
5 changes: 4 additions & 1 deletion ProjectTemplates/templates/StarterWeb-CSharp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#endif
#if (OrganizationalAuth)
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;
using Microsoft.Identity.Web.TokenCacheProviders.InMemory;
#if (MultiOrgAuth)
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
Expand All @@ -15,6 +16,7 @@
#endif
#if (IndividualB2CAuth)
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;
using Microsoft.Identity.Web.TokenCacheProviders.InMemory;
#endif
using Microsoft.AspNetCore.Builder;
Expand Down Expand Up @@ -89,7 +91,8 @@ public void ConfigureServices(IServiceCollection services)
services.AddControllersWithViews();
#endif
#if (OrganizationalAuth || IndividualAuth)
services.AddRazorPages();
services.AddRazorPages()
.AddMicrosoftIdentityUI();
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,49 @@
#endif *@

<ul class="navbar-nav">
@*#if (IndividualB2CAuth)
@if (User.Identity.IsAuthenticated)
{
@if (!string.IsNullOrEmpty(options.EditProfilePolicyId))
<ul class="navbar-nav">
@*#if (IndividualB2CAuth)
@if (User.Identity.IsAuthenticated)
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureADB2C" asp-controller="Account" asp-action="EditProfile">
<span class="text-dark">Hello @User.Identity.Name!</span>
</a>
</li>
@if (!string.IsNullOrEmpty(options.EditProfilePolicyId))
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="EditProfile">
<span class="text-dark">Hello @User.Identity.Name!</span>
</a>
</li>
}
else
{
<li class="nav-item">
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
</li>
}
<li class="nav-item">
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign out</a>
</li>
}
else
{
<li class="nav-item">
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignIn">Sign in</a>
</li>
}
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureADB2C" asp-controller="Account" asp-action="SignOut">Sign out</a>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureADB2C" asp-controller="Account" asp-action="SignIn">Sign in</a>
</li>
}
#else
@if (User.Identity.IsAuthenticated)
{
<li class="nav-item">
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignOut">Sign out</a>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="AzureAD" asp-controller="Account" asp-action="SignIn">Sign in</a>
</li>
}
#endif *@
</ul>
#else
@if (User.Identity.IsAuthenticated)
{
<li class="nav-item">
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign out</a>
</li>
}
else
{
<li class="nav-item">
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignIn">Sign in</a>
</li>
}
#endif *@
</ul>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Identity.Web" Version="0.1.0-localbuild" />
<PackageReference Include="Microsoft.Identity.Web" Version="0.1.0-preview" />
</ItemGroup>
</Project>

0 comments on commit 15c468c

Please sign in to comment.