Sha256: d27455eccfdd603d0fd27db5f98d356934dd62a1291dc196141cd6e1da89ed6b

Contents?: true

Size: 1.01 KB

Versions: 41

Compression:

Stored size: 1.01 KB

Contents

module Locomotive
  module Steam
    module Liquid
      module Tags
        module Csrf

          class Base < ::Liquid::Tag
            def render(context)
              service  = context.registers[:services].csrf_protection

              if service.enabled?
                render_csrf(service)

              else
                ''
              end
            end
          end

          class Param < Base
            def render_csrf(service)
              %(<input type="hidden" name="#{service.field}" value="#{service.token}" />)
            end
          end

          class Meta < Base
            def render_csrf(service)
              %{
                <meta name="csrf-param" content="#{service.field}" />
                <meta name="csrf-token" content="#{service.token}" />
              }
            end
          end

        end

        ::Liquid::Template.register_tag('csrf_param'.freeze, Csrf::Param)
        ::Liquid::Template.register_tag('csrf_meta'.freeze, Csrf::Meta)

      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
locomotivecms_steam-1.5.0.rc0 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.5.0.beta3 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.5.0.beta2 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.5.0.beta1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.4.1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.4.0 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.4.0.rc2 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.4.0.rc1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.4.0.pre.rc.1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.3.0 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.3.0.rc2 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.1.2 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.2.1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.3.0.rc1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.2.0 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.2.0.rc3 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.2.0.rc2 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.2.0.rc1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.2.0.beta1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.1.1 lib/locomotive/steam/liquid/tags/csrf.rb