1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true
require_relative "proxy_auth"
module RankKing
# Rack middleware that writes a fixed login to Remote-User, the way the
# proxy in front of a deployment does. Only demo.ru uses it (the dev server
# and the Fly apps); config.ru must not, or every anonymous caller would be
# that user. A request that already carries the header keeps its own, so
# `curl -H` can still ask as someone else.
class StubLogin
# @rbs @app: untyped
LOGIN = "alpha@example.com" #: String
#: (untyped app) -> void
def initialize(app)
@app = app
end
#: (Hash[String, untyped] env) -> untyped
def call(env)
env[ProxyAuth::ENV_KEY] ||= LOGIN
@app.call(env)
end
end
end