Merge remote-tracking branch 'upstream/master'
Conflicts: OwinOAuthProvidersDemo/App_Start/Startup.Auth.cs
This commit is contained in:
@@ -30,6 +30,7 @@ using Owin.Security.Providers.SoundCloud;
|
||||
using Owin.Security.Providers.Spotify;
|
||||
using Owin.Security.Providers.StackExchange;
|
||||
using Owin.Security.Providers.Steam;
|
||||
using Owin.Security.Providers.Shopify;
|
||||
using Owin.Security.Providers.TripIt;
|
||||
using Owin.Security.Providers.Twitch;
|
||||
using Owin.Security.Providers.Untappd;
|
||||
@@ -54,7 +55,7 @@ namespace OwinOAuthProvidersDemo
|
||||
});
|
||||
// Use a cookie to temporarily store information about a user logging in with a third party login provider
|
||||
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
|
||||
//app.UseDeviantArtAuthentication("id", "secret");
|
||||
//app.UseDeviantArtAuthentication("id", "secret");
|
||||
//app.UseUntappdAuthentication("id", "secret");
|
||||
// Uncomment the following lines to enable logging in with third party login providers
|
||||
//app.UseMicrosoftAccountAuthentication(
|
||||
@@ -186,6 +187,8 @@ namespace OwinOAuthProvidersDemo
|
||||
//};
|
||||
//app.UseSalesforceAuthentication(salesforceOptions);
|
||||
|
||||
////app.UseShopifyAuthentication("", "");
|
||||
|
||||
//app.UseArcGISOnlineAuthentication(
|
||||
// clientId: "",
|
||||
// clientSecret: "");
|
||||
@@ -202,7 +205,6 @@ namespace OwinOAuthProvidersDemo
|
||||
// clientId: "",
|
||||
// clientSecret: "");
|
||||
|
||||
|
||||
//app.UseBattleNetAuthentication(new BattleNetAuthenticationOptions
|
||||
//{
|
||||
// ClientId = "",
|
||||
@@ -273,11 +275,22 @@ namespace OwinOAuthProvidersDemo
|
||||
|
||||
//app.UseBacklogAuthentication(options);
|
||||
|
||||
// app.UseFitbitAuthentication(new FitbitAuthenticationOptions
|
||||
// {
|
||||
// ClientId = "",
|
||||
// ClientSecret = ""
|
||||
// });
|
||||
//var cosignOptions = new CosignAuthenticationOptions
|
||||
//{
|
||||
// AuthenticationType = "Cosign",
|
||||
// SignInAsAuthenticationType = signInAsType,
|
||||
// CosignServer = "weblogin.umich.edu",
|
||||
// CosignServicePort = 6663,
|
||||
// IdentityServerHostInstance = "core1",
|
||||
// ClientServer = "cosignservername"
|
||||
//};
|
||||
//app.UseCosignAuthentication(cosignOptions);
|
||||
|
||||
//app.UseFitbitAuthentication(new FitbitAuthenticationOptions
|
||||
//{
|
||||
// ClientId = "",
|
||||
// ClientSecret = ""
|
||||
//});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,15 +182,26 @@ namespace OwinOAuthProvidersDemo.Controllers
|
||||
return View(model);
|
||||
}
|
||||
|
||||
//////
|
||||
////// POST: /Account/ExternalLogin
|
||||
////[HttpPost]
|
||||
////[AllowAnonymous]
|
||||
////[ValidateAntiForgeryToken]
|
||||
////public ActionResult ExternalLogin(string provider, string returnUrl)
|
||||
////{
|
||||
//// // Request a redirect to the external login provider
|
||||
//// return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }));
|
||||
////}
|
||||
|
||||
//
|
||||
// POST: /Account/ExternalLogin
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult ExternalLogin(string provider, string returnUrl)
|
||||
public ActionResult ExternalLogin(string provider, string returnUrl, string shopName = "")
|
||||
{
|
||||
// Request a redirect to the external login provider
|
||||
return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }));
|
||||
return new ChallengeResult(provider, Url.Action("ExternalLoginCallback", "Account", new { ReturnUrl = returnUrl }), null, shopName);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -224,10 +235,10 @@ namespace OwinOAuthProvidersDemo.Controllers
|
||||
// POST: /Account/LinkLogin
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult LinkLogin(string provider)
|
||||
public ActionResult LinkLogin(string provider, string shopName)
|
||||
{
|
||||
// Request a redirect to the external login provider to link a login for the current user
|
||||
return new ChallengeResult(provider, Url.Action("LinkLoginCallback", "Account"), User.Identity.GetUserId());
|
||||
return new ChallengeResult(provider, Url.Action("LinkLoginCallback", "Account"), User.Identity.GetUserId(), shopName);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -324,6 +335,8 @@ namespace OwinOAuthProvidersDemo.Controllers
|
||||
#region Helpers
|
||||
// Used for XSRF protection when adding external logins
|
||||
private const string XsrfKey = "XsrfId";
|
||||
// Used for Shopify external login to provide shopname while building endpoints.
|
||||
private const string ShopNameKey = "ShopName";
|
||||
|
||||
private IAuthenticationManager AuthenticationManager
|
||||
{
|
||||
@@ -380,28 +393,36 @@ namespace OwinOAuthProvidersDemo.Controllers
|
||||
|
||||
private class ChallengeResult : HttpUnauthorizedResult
|
||||
{
|
||||
public ChallengeResult(string provider, string redirectUri) : this(provider, redirectUri, null)
|
||||
public ChallengeResult(string provider, string redirectUri) : this(provider, redirectUri, null, null)
|
||||
{
|
||||
}
|
||||
|
||||
public ChallengeResult(string provider, string redirectUri, string userId)
|
||||
public ChallengeResult(string provider, string redirectUri, string userId, string shopName)
|
||||
{
|
||||
LoginProvider = provider;
|
||||
RedirectUri = redirectUri;
|
||||
UserId = userId;
|
||||
ShopName = shopName;
|
||||
}
|
||||
|
||||
public string LoginProvider { get; set; }
|
||||
public string RedirectUri { get; set; }
|
||||
public string UserId { get; set; }
|
||||
public string ShopName { get; set; }
|
||||
|
||||
public override void ExecuteResult(ControllerContext context)
|
||||
{
|
||||
var properties = new AuthenticationProperties() { RedirectUri = RedirectUri };
|
||||
if (UserId != null)
|
||||
{
|
||||
properties.Dictionary[XsrfKey] = UserId;
|
||||
properties.Dictionary[XsrfKey] = this.UserId;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(this.ShopName))
|
||||
{
|
||||
properties.Dictionary[ShopNameKey] = this.ShopName;
|
||||
}
|
||||
|
||||
context.HttpContext.GetOwinContext().Authentication.Challenge(properties, LoginProvider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
<p>
|
||||
@foreach (AuthenticationDescription p in loginProviders)
|
||||
{
|
||||
if (p.AuthenticationType.Equals("Shopify"))
|
||||
{
|
||||
@Html.TextBox("shopName")
|
||||
}
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user