Sha256: 5f7e31b9c54ed57d8d678ac1a7546735b3b47c291d733116a531af718abf9d12

Contents?: true

Size: 1.01 KB

Versions: 13

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

13 entries across 13 versions & 1 rubygems

Version Path
locomotivecms_steam-1.8.0.alpha2 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.8.0.alpha1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.7.1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.7.0 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.6.1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.6.0 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.6.0.rc1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.6.0.beta1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.5.3 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.5.2 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.5.1 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.5.0 lib/locomotive/steam/liquid/tags/csrf.rb
locomotivecms_steam-1.5.0.rc1 lib/locomotive/steam/liquid/tags/csrf.rb