Sha256: 74e941a8fa57f407c2decce88c9ebe6e9fdb9c795143c3198300189e185c6de1

Contents?: true

Size: 595 Bytes

Versions: 2

Compression:

Stored size: 595 Bytes

Contents

module RapidRack
  class TestAuthenticator < Authenticator
    class <<self
      attr_accessor :jwt
    end

    def call(env)
      return login if env['PATH_INFO'] == '/login'
      super
    end

    private

    def login
      jwt = TestAuthenticator.jwt || fail('No login JWT was set')
      out = [] << <<-EOF
        <html><body>
          <form action="/auth/jwt" method="post">
            <input type="hidden" name="assertion" value="#{jwt}"/>
            <button type="submit">Login</button>
          </form>
        </body></html>
      EOF
      [200, {}, out]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rapid-rack-0.3.0 lib/rapid_rack/test_authenticator.rb
rapid-rack-0.2.0 lib/rapid_rack/test_authenticator.rb