-
-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1742 from PiranhaCMS/features/manager-security-up…
…date Updated manager security. Fixes #1741
- Loading branch information
Showing
73 changed files
with
1,051 additions
and
630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
core/Piranha.Manager/Areas/Manager/Shared/Partial/_ContentPickerModal.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
core/Piranha.Manager/Areas/Manager/Shared/Partial/_MediaPickerModal.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
core/Piranha.Manager/Areas/Manager/Shared/Partial/_PagePickerModal.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
core/Piranha.Manager/Areas/Manager/Shared/Partial/_PostPickerModal.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
core/Piranha.Manager/Areas/Manager/Shared/Partial/_PreviewModal.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright (c) .NET Foundation and Contributors | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE file for details. | ||
* | ||
* https://github.com/piranhacms/piranha.core | ||
* | ||
*/ | ||
|
||
using Microsoft.AspNetCore.Antiforgery; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Piranha.Manager.Controllers | ||
{ | ||
[Area("Manager")] | ||
[Route("manager/login/auth")] | ||
[Authorize(Policy = Permission.Admin)] | ||
[ApiController] | ||
public sealed class AuthController : Controller | ||
{ | ||
private readonly IAntiforgery _antiForgery; | ||
private readonly ManagerOptions _options; | ||
|
||
/// <summary> | ||
/// Default constructor. | ||
/// </summary> | ||
/// <param name="antiforgery">The antiforgery service</param> | ||
/// <param name="options">The manager options</param> | ||
public AuthController(IAntiforgery antiforgery, IOptions<ManagerOptions> options) | ||
{ | ||
_antiForgery = antiforgery; | ||
_options = options.Value; | ||
} | ||
|
||
[Route("{returnUrl?}")] | ||
[HttpGet] | ||
public IActionResult SetAuthCookie(string returnUrl = null) | ||
{ | ||
var tokens = _antiForgery.GetAndStoreTokens(HttpContext); | ||
Response.Cookies.Append(_options.XsrfCookieName, tokens.RequestToken, new CookieOptions | ||
{ | ||
HttpOnly = false | ||
}); | ||
if (!string.IsNullOrEmpty(returnUrl)) | ||
{ | ||
return LocalRedirect(returnUrl); | ||
} | ||
return LocalRedirect("~/manager"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.