From eb4c854d810fdee9513a7af7b99072ea2eb86a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 30 Jul 2020 17:57:22 +0300 Subject: [PATCH] Resolved #4927: Document social logins. --- .../Authentication/Social-External-Logins.md | 30 +++++++++++++++++++ docs/en/Startup-Templates/Application.md | 8 +++-- docs/en/docs-nav.json | 9 ++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 docs/en/Authentication/Social-External-Logins.md diff --git a/docs/en/Authentication/Social-External-Logins.md b/docs/en/Authentication/Social-External-Logins.md new file mode 100644 index 0000000000..c48763a92a --- /dev/null +++ b/docs/en/Authentication/Social-External-Logins.md @@ -0,0 +1,30 @@ +# Social/External Logins + +## ASP.NET Core MVC / Razor Pages UI + +The [Account Module](../Modules/Account.md) has already configured to handle social or external logins out of the box. You can follow the ASP.NET Core documentation to add a social/external login provider to your application. + +### Example: Facebook Authentication + +Follow the [ASP.NET Core Facebook integration document](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins) to support the Facebook login for your application. + +#### Add the NuGet Package + +Add the [Microsoft.AspNetCore.Authentication.Facebook](https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.Facebook) package to your project. Based on your architecture, this can be `.Web`, `.IdentityServer` (for tiered setup) or `.Host` project. + +#### Configure the Provider + +Use the `.AddFacebook(...)` extension method in the `ConfigureServices` method of your [module](../Module-Development-Basics.md), to configure the client: + +````csharp +context.Services.AddAuthentication() + .AddFacebook(facebook => + { + facebook.AppId = "..."; + facebook.AppSecret = "..."; + facebook.Scope.Add("email"); + facebook.Scope.Add("public_profile"); + }); +```` + +> It would be a better practice to use the `appsettings.json` or the ASP.NET Core User Secrets system to store your credentials, instead of a hard-coded value like that. Follow the [Microsoft's document](https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins) to learn the user secrets usage. \ No newline at end of file diff --git a/docs/en/Startup-Templates/Application.md b/docs/en/Startup-Templates/Application.md index af76bb14ff..7495b8f006 100644 --- a/docs/en/Startup-Templates/Application.md +++ b/docs/en/Startup-Templates/Application.md @@ -437,7 +437,11 @@ See the [Testing Overview](https://reactjs.org/docs/testing.html) document. * [Formik](https://github.com/jaredpalmer/formik) is used to build forms. * [Yup](https://github.com/jquense/yup) is used for form validations. +## Social / External Logins + +If you want to configure social/external logins for your application, please follow the [Social/External Logins](../Authentication/Social-External-Logins.md) document. + ## What's Next? -- [The getting started document](../Getting-Started-With-Startup-Templates.md) explains how to create a new application in a few minutes. -- [The application development tutorial](../Tutorials/Part-1) explains step by step application development. +- [The getting started document](../Getting-Started.md) explains how to create a new application in a few minutes. +- [The application development tutorial](../Tutorials/Part-1.md) explains step by step application development. diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 09288e013b..b586f3aff4 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -107,6 +107,15 @@ "text": "CLI", "path": "CLI.md" }, + { + "text": "Authentication", + "items": [ + { + "text": "Social/External Logins", + "path": "Authentication/Social-External-Logins.md" + } + ] + }, { "text": "Fundamentals", "items": [