2018-06-15 02:57:03 +02:00
|
|
|
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
|
|
|
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
|
|
|
|
|
2018-10-26 07:22:53 +02:00
|
|
|
|
namespace Teknik.Utilities.TagHelpers
|
2018-06-15 02:57:03 +02:00
|
|
|
|
{
|
|
|
|
|
[HtmlTargetElement("script")]
|
|
|
|
|
public class NonceTagHelper : TagHelper
|
|
|
|
|
{
|
|
|
|
|
[HtmlAttributeNotBound]
|
|
|
|
|
[ViewContext]
|
|
|
|
|
public ViewContext ViewContext { get; set; }
|
|
|
|
|
|
|
|
|
|
public override void Process(TagHelperContext context, TagHelperOutput output)
|
|
|
|
|
{
|
|
|
|
|
output.Attributes.SetAttribute("nonce", ViewContext.HttpContext.Items[Constants.NONCE_KEY]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|