Class: Conjur::WebServer::ConjurInfo
- Inherits:
-
Object
- Object
- Conjur::WebServer::ConjurInfo
- Defined in:
- lib/conjur/webserver/conjur_info.rb
Overview
Middleware that adds some conjur info to the rack environment
Constant Summary collapse
- PROPERTIES =
%w(roleid account stack)
Instance Method Summary collapse
- #account ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app) ⇒ ConjurInfo
constructor
A new instance of ConjurInfo.
- #roleid ⇒ Object
- #stack ⇒ Object
- #update_env(env) ⇒ Object
Constructor Details
#initialize(app) ⇒ ConjurInfo
Returns a new instance of ConjurInfo.
5 6 7 |
# File 'lib/conjur/webserver/conjur_info.rb', line 5 def initialize app @app = app end |
Instance Method Details
#account ⇒ Object
24 25 26 |
# File 'lib/conjur/webserver/conjur_info.rb', line 24 def account Conjur.account end |
#call(env) ⇒ Object
9 10 11 12 |
# File 'lib/conjur/webserver/conjur_info.rb', line 9 def call env update_env env @app.call env end |
#roleid ⇒ Object
20 21 22 |
# File 'lib/conjur/webserver/conjur_info.rb', line 20 def roleid "#{account}:user:#{Conjur::Authn.get_credentials[0]}" end |
#stack ⇒ Object
28 29 30 |
# File 'lib/conjur/webserver/conjur_info.rb', line 28 def stack Conjur.stack end |
#update_env(env) ⇒ Object
14 15 16 |
# File 'lib/conjur/webserver/conjur_info.rb', line 14 def update_env env PROPERTIES.each{|name| env["conjur.#{name}"] = send(name)} end |