Class: Gitlab::Jira::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/jira/middleware.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.


10
11
12
# File 'lib/gitlab/jira/middleware.rb', line 10

def initialize(app)
  @app = app
end

Class Method Details

.jira_dvcs_connector?(env) ⇒ Boolean

Returns:

  • (Boolean)

6
7
8
# File 'lib/gitlab/jira/middleware.rb', line 6

def self.jira_dvcs_connector?(env)
  env['HTTP_USER_AGENT']&.downcase&.start_with?('jira dvcs connector')
end

Instance Method Details

#call(env) ⇒ Object


14
15
16
17
18
19
20
# File 'lib/gitlab/jira/middleware.rb', line 14

def call(env)
  if self.class.jira_dvcs_connector?(env)
    env['HTTP_AUTHORIZATION'] = env['HTTP_AUTHORIZATION']&.sub('token', 'Bearer')
  end

  @app.call(env)
end