Browse Source

Remove unused external logins classes

pull/953/head
Miguel Veloso 6 years ago
parent
commit
0105808354
5 changed files with 6 additions and 61 deletions
  1. +3
    -26
      src/Services/Identity/Identity.API/Controllers/AccountController.cs
  2. +0
    -11
      src/Services/Identity/Identity.API/Models/AccountViewModels/ExternalLoginConfirmationViewModel.cs
  3. +0
    -13
      src/Services/Identity/Identity.API/Models/ManageViewModels/ManageLoginsViewModel.cs
  4. +0
    -8
      src/Services/Identity/Identity.API/Models/ManageViewModels/RemoveLoginViewModel.cs
  5. +3
    -3
      src/Web/WebMVC/Controllers/AccountController.cs

+ 3
- 26
src/Services/Identity/Identity.API/Controllers/AccountController.cs View File

@ -20,7 +20,7 @@ using Microsoft.Extensions.Logging;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
{ {
/// <summary> /// <summary>
/// This sample controller implements a typical login/logout/provision workflow for local and external accounts.
/// This sample controller implements a typical login/logout/provision workflow for local accounts.
/// The login service encapsulates the interactions with the user data store. This data store is in-memory only and cannot be used for production! /// The login service encapsulates the interactions with the user data store. This data store is in-memory only and cannot be used for production!
/// The interaction service provides a way for the UI to communicate with identityserver for validation and context retrieval /// The interaction service provides a way for the UI to communicate with identityserver for validation and context retrieval
/// </summary> /// </summary>
@ -58,8 +58,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
var context = await _interaction.GetAuthorizationContextAsync(returnUrl); var context = await _interaction.GetAuthorizationContextAsync(returnUrl);
if (context?.IdP != null) if (context?.IdP != null)
{ {
// if IdP is passed, then bypass showing the login screen
return ExternalLogin(context.IdP, returnUrl);
throw new NotImplementedException("External login is not implemented!");
} }
var vm = await BuildLoginViewModelAsync(returnUrl, context); var vm = await BuildLoginViewModelAsync(returnUrl, context);
@ -209,7 +208,7 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogCritical(ex.Message);
_logger.LogError(ex, "LOGOUT ERROR: {ExceptionMessage}", ex.Message);
} }
} }
@ -238,28 +237,6 @@ namespace Microsoft.eShopOnContainers.Services.Identity.API.Controllers
return Redirect(redirectUrl); return Redirect(redirectUrl);
} }
/// <summary>
/// initiate roundtrip to external authentication provider
/// </summary>
[HttpGet]
public IActionResult ExternalLogin(string provider, string returnUrl)
{
if (returnUrl != null)
{
returnUrl = UrlEncoder.Default.Encode(returnUrl);
}
returnUrl = "/account/externallogincallback?returnUrl=" + returnUrl;
// start challenge and roundtrip the return URL
var props = new AuthenticationProperties
{
RedirectUri = returnUrl,
Items = { { "scheme", provider } }
};
return new ChallengeResult(provider, props);
}
// GET: /Account/Register // GET: /Account/Register
[HttpGet] [HttpGet]
[AllowAnonymous] [AllowAnonymous]


+ 0
- 11
src/Services/Identity/Identity.API/Models/AccountViewModels/ExternalLoginConfirmationViewModel.cs View File

@ -1,11 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
{
public class ExternalLoginConfirmationViewModel
{
[Required]
[EmailAddress]
public string Email { get; set; }
}
}

+ 0
- 13
src/Services/Identity/Identity.API/Models/ManageViewModels/ManageLoginsViewModel.cs View File

@ -1,13 +0,0 @@
using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.AspNetCore.Identity;
using System.Collections.Generic;
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
{
public class ManageLoginsViewModel
{
public IList<UserLoginInfo> CurrentLogins { get; set; }
public IList<AuthenticationDescription> OtherLogins { get; set; }
}
}

+ 0
- 8
src/Services/Identity/Identity.API/Models/ManageViewModels/RemoveLoginViewModel.cs View File

@ -1,8 +0,0 @@
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.ManageViewModels
{
public class RemoveLoginViewModel
{
public string LoginProvider { get; set; }
public string ProviderKey { get; set; }
}
}

+ 3
- 3
src/Web/WebMVC/Controllers/AccountController.cs View File

@ -16,7 +16,7 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
public async Task<IActionResult> SignIn(string returnUrl) public async Task<IActionResult> SignIn(string returnUrl)
{ {
var user = User as ClaimsPrincipal; var user = User as ClaimsPrincipal;
var token = await HttpContext.GetTokenAsync("access_token"); var token = await HttpContext.GetTokenAsync("access_token");
if (token != null) if (token != null)
@ -33,11 +33,11 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
{ {
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
await HttpContext.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme); await HttpContext.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme);
// "Catalog" because UrlHelper doesn't support nameof() for controllers // "Catalog" because UrlHelper doesn't support nameof() for controllers
// https://github.com/aspnet/Mvc/issues/5853 // https://github.com/aspnet/Mvc/issues/5853
var homeUrl = Url.Action(nameof(CatalogController.Index), "Catalog"); var homeUrl = Url.Action(nameof(CatalogController.Index), "Catalog");
return new SignOutResult(OpenIdConnectDefaults.AuthenticationScheme,
return new SignOutResult(OpenIdConnectDefaults.AuthenticationScheme,
new AspNetCore.Authentication.AuthenticationProperties { RedirectUri = homeUrl }); new AspNetCore.Authentication.AuthenticationProperties { RedirectUri = homeUrl });
} }
} }


Loading…
Cancel
Save