Skip to content

Commit

Permalink
Merge pull request #3 from alexs0ff/3-add-google-external-login
Browse files Browse the repository at this point in the history
Added external login from google support.
  • Loading branch information
alexs0ff committed Jul 25, 2019
2 parents 36ce262 + f67be1b commit 6795d09
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/IdentityServer4WebApp.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
Expand All @@ -8,14 +8,12 @@
<SpaRoot>ClientApp\</SpaRoot>
<DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
<BuildServerSideRenderer>false</BuildServerSideRenderer>
<UserSecretsId>a6e26090-54a1-4110-af78-c5a7be611c2b</UserSecretsId>
</PropertyGroup>


<ItemGroup>
<Folder Include="Data\" />
<Folder Include="Models\" />
</ItemGroup>

<Target Name="DebugEnsureNodeEnv" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('$(SpaRoot)node_modules') ">
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
Expand All @@ -29,9 +27,9 @@
<None Remove="$(SpaRoot)**" />
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.ApiAuthorization.IdentityServer" Version="3.0.0-preview7.19365.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="3.0.0-preview7.19365.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview7.19365.7" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.0.0-preview7.19365.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.0-preview7.19362.6" />
Expand All @@ -40,5 +38,4 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
</Project>
12 changes: 12 additions & 0 deletions src/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;

namespace IdentityServer4WebApp
{
Expand All @@ -37,6 +38,17 @@ public void ConfigureServices(IServiceCollection services)
.AddApiAuthorization<ApplicationUser, ApplicationDbContext>();

services.AddAuthentication()
.AddOpenIdConnect("Google", "Google",
o =>
{
IConfigurationSection googleAuthNSection =
Configuration.GetSection("Authentication:Google");
o.ClientId = googleAuthNSection["ClientId"];
o.ClientSecret = googleAuthNSection["ClientSecret"];
o.Authority = "https://accounts.google.com";
o.ResponseType = OpenIdConnectResponseType.Code;
o.CallbackPath = "/signin-google";
})
.AddIdentityServerJwt();

services.AddSpaStaticFiles(configuration =>
Expand Down
Binary file modified src/data.db
Binary file not shown.

0 comments on commit 6795d09

Please sign in to comment.