React to MVC/Auth changes
This commit is contained in:
parent
ad5cfb9e6e
commit
ef22f9fb30
|
|
@ -88,7 +88,7 @@ namespace MusicStore.Apis
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize("app-ManageStore", "Allowed")]
|
[Authorize("app-ManageStore")]
|
||||||
public async Task<ActionResult> CreateAlbum([FromBody]AlbumChangeDto album)
|
public async Task<ActionResult> CreateAlbum([FromBody]AlbumChangeDto album)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
|
|
@ -112,7 +112,7 @@ namespace MusicStore.Apis
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPut("{albumId:int}/update")]
|
[HttpPut("{albumId:int}/update")]
|
||||||
[Authorize("app-ManageStore", "Allowed")]
|
[Authorize("app-ManageStore")]
|
||||||
public async Task<ActionResult> UpdateAlbum(int albumId, [FromBody]AlbumChangeDto album)
|
public async Task<ActionResult> UpdateAlbum(int albumId, [FromBody]AlbumChangeDto album)
|
||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
|
|
@ -145,7 +145,7 @@ namespace MusicStore.Apis
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{albumId:int}")]
|
[HttpDelete("{albumId:int}")]
|
||||||
[Authorize("app-ManageStore", "Allowed")]
|
[Authorize("app-ManageStore")]
|
||||||
public async Task<ActionResult> DeleteAlbum(int albumId)
|
public async Task<ActionResult> DeleteAlbum(int albumId)
|
||||||
{
|
{
|
||||||
var album = await _storeContext.Albums.SingleOrDefaultAsync(a => a.AlbumId == albumId);
|
var album = await _storeContext.Albums.SingleOrDefaultAsync(a => a.AlbumId == albumId);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace MusicStore.Spa.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("admin")]
|
[HttpGet("admin")]
|
||||||
[Authorize("app-ManageStore", "Allowed")]
|
[Authorize("app-ManageStore")]
|
||||||
public IActionResult Admin()
|
public IActionResult Admin()
|
||||||
{
|
{
|
||||||
return View("/Pages/Admin.cshtml");
|
return View("/Pages/Admin.cshtml");
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using Microsoft.AspNet.Mvc;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNet.Mvc.Rendering;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
|
using Microsoft.AspNet.Security;
|
||||||
using Microsoft.AspNet.Security.Cookies;
|
using Microsoft.AspNet.Security.Cookies;
|
||||||
using Microsoft.AspNet.StaticFiles;
|
using Microsoft.AspNet.StaticFiles;
|
||||||
using Microsoft.Data.Entity;
|
using Microsoft.Data.Entity;
|
||||||
|
|
@ -61,6 +62,13 @@ namespace MusicStore.Spa
|
||||||
|
|
||||||
// Add application services to the service container
|
// Add application services to the service container
|
||||||
//services.AddTransient<IModelMetadataProvider, BuddyModelMetadataProvider>();
|
//services.AddTransient<IModelMetadataProvider, BuddyModelMetadataProvider>();
|
||||||
|
|
||||||
|
// Configure Auth
|
||||||
|
services.Configure<AuthorizationOptions>(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy("app-ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("Allowed").Build());
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(IApplicationBuilder app)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ using MusicStore.ViewModels;
|
||||||
namespace MusicStore.Areas.Admin.Controllers
|
namespace MusicStore.Areas.Admin.Controllers
|
||||||
{
|
{
|
||||||
[Area("Admin")]
|
[Area("Admin")]
|
||||||
[Microsoft.AspNet.Mvc.Authorize("ManageStore", "Allowed")]
|
[Microsoft.AspNet.Mvc.Authorize("ManageStore")]
|
||||||
public class StoreManagerController : Controller
|
public class StoreManagerController : Controller
|
||||||
{
|
{
|
||||||
private readonly MusicStoreContext _dbContext;
|
private readonly MusicStoreContext _dbContext;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using Microsoft.AspNet.Diagnostics;
|
||||||
using Microsoft.AspNet.Diagnostics.Entity;
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNet.Identity;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
|
using Microsoft.AspNet.Security;
|
||||||
using Microsoft.Framework.Cache.Memory;
|
using Microsoft.Framework.Cache.Memory;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Microsoft.Framework.ConfigurationModel;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
|
|
@ -85,6 +86,12 @@ namespace MusicStore
|
||||||
|
|
||||||
//Add InMemoryCache
|
//Add InMemoryCache
|
||||||
services.AddSingleton<IMemoryCache, MemoryCache>();
|
services.AddSingleton<IMemoryCache, MemoryCache>();
|
||||||
|
|
||||||
|
// Configure Auth
|
||||||
|
services.Configure<AuthorizationOptions>(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("Allowed").Build());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//This method is invoked when ASPNET_ENV is 'Development' or is not defined
|
//This method is invoked when ASPNET_ENV is 'Development' or is not defined
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Diagnostics;
|
using Microsoft.AspNet.Diagnostics;
|
||||||
using Microsoft.AspNet.Diagnostics.Entity;
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
|
using Microsoft.AspNet.Security;
|
||||||
using Microsoft.AspNet.Server.WebListener;
|
using Microsoft.AspNet.Server.WebListener;
|
||||||
using Microsoft.Framework.Cache.Memory;
|
using Microsoft.Framework.Cache.Memory;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Microsoft.Framework.ConfigurationModel;
|
||||||
|
|
@ -88,6 +89,12 @@ namespace MusicStore
|
||||||
|
|
||||||
//Add InMemoryCache
|
//Add InMemoryCache
|
||||||
services.AddSingleton<IMemoryCache, MemoryCache>();
|
services.AddSingleton<IMemoryCache, MemoryCache>();
|
||||||
|
|
||||||
|
// Configure Auth
|
||||||
|
services.Configure<AuthorizationOptions>(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("Allowed").Build());
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//Configure SignalR
|
//Configure SignalR
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using Microsoft.AspNet.Diagnostics;
|
||||||
using Microsoft.AspNet.Diagnostics.Entity;
|
using Microsoft.AspNet.Diagnostics.Entity;
|
||||||
using Microsoft.AspNet.Identity;
|
using Microsoft.AspNet.Identity;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
|
using Microsoft.AspNet.Security;
|
||||||
using Microsoft.Framework.Cache.Memory;
|
using Microsoft.Framework.Cache.Memory;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Microsoft.Framework.ConfigurationModel;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
|
|
@ -73,6 +74,12 @@ namespace MusicStore
|
||||||
|
|
||||||
//Add InMemoryCache
|
//Add InMemoryCache
|
||||||
services.AddSingleton<IMemoryCache, MemoryCache>();
|
services.AddSingleton<IMemoryCache, MemoryCache>();
|
||||||
|
|
||||||
|
// Configure Auth
|
||||||
|
services.Configure<AuthorizationOptions>(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy("ManageStore", new AuthorizationPolicyBuilder().RequiresClaim("Allowed").Build());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//This method is invoked when ASPNET_ENV is 'Development' or is not defined
|
//This method is invoked when ASPNET_ENV is 'Development' or is not defined
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue