Adding all the Social login middlewares to the pipeline
Still some of the identity helpers have not lighted up. So it will not work fully.
This commit is contained in:
parent
265a220142
commit
6cf7cbfa5b
|
|
@ -270,7 +270,7 @@ namespace MusicStore.Controllers
|
|||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult ExternalLogin(string provider, string returnUrl)
|
||||
public ActionResult ExternalLogin(string provider, string returnUrl = null)
|
||||
{
|
||||
// Request a redirect to the external login provider
|
||||
var redirectUri = Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl });
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@ using Microsoft.Data.Entity;
|
|||
using Microsoft.Framework.ConfigurationModel;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using MusicStore.Models;
|
||||
using Microsoft.AspNet.Security.Facebook;
|
||||
using Microsoft.AspNet.Security.Google;
|
||||
using Microsoft.AspNet.Security.Twitter;
|
||||
using Microsoft.AspNet.Security.MicrosoftAccount;
|
||||
using Microsoft.AspNet.Security;
|
||||
|
||||
namespace MusicStore
|
||||
{
|
||||
|
|
@ -26,6 +31,8 @@ namespace MusicStore
|
|||
//Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
|
||||
app.UseErrorPage(ErrorPageOptions.ShowAll);
|
||||
|
||||
app.SetDefaultSignInAsAuthenticationType("External");
|
||||
|
||||
app.UseServices(services =>
|
||||
{
|
||||
//If this type is present - we're on mono
|
||||
|
|
@ -77,6 +84,14 @@ namespace MusicStore
|
|||
// Add static files to the request pipeline
|
||||
app.UseStaticFiles();
|
||||
|
||||
// Add cookie-based authentication to the request pipeline
|
||||
app.UseCookieAuthentication(new CookieAuthenticationOptions
|
||||
{
|
||||
AuthenticationType = "External",
|
||||
AuthenticationMode = AuthenticationMode.Passive,
|
||||
ExpireTimeSpan = TimeSpan.FromMinutes(5)
|
||||
});
|
||||
|
||||
// Add cookie-based authentication to the request pipeline
|
||||
app.UseCookieAuthentication(new CookieAuthenticationOptions
|
||||
{
|
||||
|
|
@ -86,6 +101,31 @@ namespace MusicStore
|
|||
|
||||
app.UseTwoFactorSignInCookies();
|
||||
|
||||
app.UseFacebookAuthentication(new FacebookAuthenticationOptions()
|
||||
{
|
||||
AppId = "[AppId]",
|
||||
AppSecret = "[AppSecret]",
|
||||
});
|
||||
|
||||
app.UseGoogleAuthentication(new GoogleAuthenticationOptions()
|
||||
{
|
||||
ClientId = "[ClientId]",
|
||||
ClientSecret = "[ClientSecret]",
|
||||
});
|
||||
|
||||
app.UseTwitterAuthentication(new TwitterAuthenticationOptions()
|
||||
{
|
||||
ConsumerKey = "[ConsumerKey]",
|
||||
ConsumerSecret = "[ConsumerSecret]",
|
||||
});
|
||||
|
||||
app.UseMicrosoftAccountAuthentication(new MicrosoftAccountAuthenticationOptions()
|
||||
{
|
||||
Caption = "MicrosoftAccount - Requires project changes",
|
||||
ClientId = "[ClientId]",
|
||||
ClientSecret = "[ClientSecret]",
|
||||
});
|
||||
|
||||
// Add MVC to the request pipeline
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@
|
|||
}
|
||||
</section>
|
||||
</div>
|
||||
@*<div class="col-md-4">
|
||||
<section id="socialLoginForm">
|
||||
@Html.PartialAsync("_ExternalLoginsListPartial", new ExternalLoginListViewModel { ReturnUrl = ViewBag.ReturnUrl })
|
||||
</section>
|
||||
</div>*@
|
||||
<div class="col-md-4">
|
||||
<section id="socialLoginForm">
|
||||
@await Html.PartialAsync("_ExternalLoginsListPartial", new ExternalLoginListViewModel { ReturnUrl = ViewBag.ReturnUrl })
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
@section Scripts {
|
||||
@*TODO : Until script helpers are available, adding script references manually*@
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
<hr />
|
||||
@{
|
||||
var loginProviders = Context.GetAuthenticationTypes();
|
||||
if (loginProviders.Count() == 0) {
|
||||
if (loginProviders.Count() == 0)
|
||||
{
|
||||
<div>
|
||||
<p>
|
||||
There are no external authentication services configured. See <a href="http://go.microsoft.com/fwlink/?LinkId=313242">this article</a>
|
||||
|
|
@ -13,12 +14,16 @@
|
|||
</p>
|
||||
</div>
|
||||
}
|
||||
else {
|
||||
using (Html.BeginForm("ExternalLogin", "Account", new { ReturnUrl = Model.ReturnUrl })) {
|
||||
else
|
||||
{
|
||||
<p>asdfasdf</p>
|
||||
using (Html.BeginForm("ExternalLogin", "Account", new { ReturnUrl = Model.ReturnUrl }))
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
<div id="socialLoginList">
|
||||
<p>
|
||||
@foreach (AuthenticationDescription p in loginProviders) {
|
||||
@foreach (AuthenticationDescription p in loginProviders)
|
||||
{
|
||||
<button type="submit" class="btn btn-default" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Log in using your @p.Caption account">@p.AuthenticationType</button>
|
||||
}
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -14,6 +14,10 @@
|
|||
"Microsoft.AspNet.Identity.SqlServer": "3.0.0-*",
|
||||
"Microsoft.AspNet.Identity.Authentication": "3.0.0-*",
|
||||
"Microsoft.AspNet.Security.Cookies": "1.0.0-*",
|
||||
"Microsoft.AspNet.Security.Facebook": "1.0.0-*",
|
||||
"Microsoft.AspNet.Security.Google": "1.0.0-*",
|
||||
"Microsoft.AspNet.Security.MicrosoftAccount": "1.0.0-*",
|
||||
"Microsoft.AspNet.Security.Twitter": "1.0.0-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
||||
"EntityFramework.SqlServer": "7.0.0-*",
|
||||
/*For Mono*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue