<commit_before>﻿namespace Nancy.Security
{
    using System;
    using Cookies;
    using Nancy.Bootstrapper;
    using Nancy.Helpers;

    /// <summary>
    /// Csrf protection methods
    /// </summary>
    public static class Csrf
    {
        private const string CsrfHookName = "CsrfPostHook";

        /// <summary>
        /// Enables Csrf token generation.
        /// This is enabled automatically so there should be no reason to call this manually.
        /// </summary>
        /// <param name="pipelines">Application pipelines</param>
        public static void Enable(IPipelines pipelines)
        {
            var postHook = new PipelineItem<Action<NancyContext>>(
                CsrfHookName,
                context =>
                {
                    if (context.Response == null || context.Response.Cookies == null || context.Request.Method.Equals("OPTIONS", StringComparison.OrdinalIgnoreCase))
                    {
                        return;<commit_msg>Fixed documentation about Csrf being disabled by default.<commit_after>﻿namespace Nancy.Security
{
    using System;
    using Cookies;
    using Nancy.Bootstrapper;
    using Nancy.Helpers;

    /// <summary>
    /// Csrf protection methods
    /// </summary>
    public static class Csrf
    {
        private const string CsrfHookName = "CsrfPostHook";

        /// <summary>
        /// Enables Csrf token generation.
        /// This is disabled by default. Enabling it is just a single line in the bootstrapp app startup:
        /// Csrf.Enable(pipelines);
        /// </summary>
        /// <param name="pipelines">Application pipelines</param>
        public static void Enable(IPipelines pipelines)
        {
            var postHook = new PipelineItem<Action<NancyContext>>(
                CsrfHookName,
                context =>
                {
                    if (context.Response == null || context.Response.Cookies == null || context.Request.Method.Equals("OPTIONS", StringComparison.OrdinalIgnoreCase))
                    {
                        return;
{'fraction_non_alphanumeric': 0.09912959381044488, 'fraction_numerical': 0.0, 'mean_word_length': 1.8498622589531681, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1176883', 'n_tokens_mistral': 534, 'n_tokens_neox': 503, 'n_words': 142}