class RapidRack::TestAuthenticator

Attributes

jwt[RW]

Public Instance Methods

call(env) click to toggle source
Calls superclass method RapidRack::Authenticator#call
# File lib/rapid_rack/test_authenticator.rb, line 7
def call(env)
  return login if env['PATH_INFO'] == '/login'
  super
end

Private Instance Methods

login() click to toggle source
# File lib/rapid_rack/test_authenticator.rb, line 14
    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