Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-232 feature flag addition of the oauth_token parameter #378

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 34 additions & 32 deletions lib/jira/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,39 @@ module JIRA
# The client must be initialized with an options hash containing
# configuration options. The available options are:
#
# :site => 'http://localhost:2990',
# :context_path => '/jira',
# :signature_method => 'RSA-SHA1',
# :request_token_path => "/plugins/servlet/oauth/request-token",
# :authorize_path => "/plugins/servlet/oauth/authorize",
# :access_token_path => "/plugins/servlet/oauth/access-token",
# :private_key => nil,
# :private_key_file => "rsakey.pem",
# :rest_base_path => "/rest/api/2",
# :consumer_key => nil,
# :consumer_secret => nil,
# :ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER,
# :ssl_version => nil,
# :use_ssl => true,
# :username => nil,
# :password => nil,
# :auth_type => :oauth,
# :proxy_address => nil,
# :proxy_port => nil,
# :proxy_username => nil,
# :proxy_password => nil,
# :use_cookies => nil,
# :additional_cookies => nil,
# :default_headers => {},
# :use_client_cert => false,
# :read_timeout => nil,
# :http_debug => false,
# :shared_secret => nil,
# :cert_path => nil,
# :key_path => nil,
# :ssl_client_cert => nil,
# :ssl_client_key => nil
# :site => 'http://localhost:2990',
# :context_path => '/jira',
# :signature_method => 'RSA-SHA1',
# :request_token_path => "/plugins/servlet/oauth/request-token",
# :authorize_path => "/plugins/servlet/oauth/authorize",
# :access_token_path => "/plugins/servlet/oauth/access-token",
# :append_explicit_oauth_token_parameter => false,
# :private_key => nil,
# :private_key_file => "rsakey.pem",
# :rest_base_path => "/rest/api/2",
# :consumer_key => nil,
# :consumer_secret => nil,
# :ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER,
# :ssl_version => nil,
# :use_ssl => true,
# :username => nil,
# :password => nil,
# :auth_type => :oauth,
# :proxy_address => nil,
# :proxy_port => nil,
# :proxy_username => nil,
# :proxy_password => nil,
# :use_cookies => nil,
# :additional_cookies => nil,
# :default_headers => {},
# :use_client_cert => false,
# :read_timeout => nil,
# :http_debug => false,
# :shared_secret => nil,
# :cert_path => nil,
# :key_path => nil,
# :ssl_client_cert => nil,
# :ssl_client_key => nil
#
# See the JIRA::Base class methods for all of the available methods on these accessor
# objects.
Expand All @@ -65,6 +66,7 @@ class Client
:request_token_path,
:authorize_path,
:access_token_path,
:append_explicit_oauth_token_parameter,
:private_key,
:private_key_file,
:rest_base_path,
Expand Down
8 changes: 5 additions & 3 deletions lib/jira/oauth_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class OauthClient < RequestClient
access_token_path: '/plugins/servlet/oauth/access-token',
private_key_file: 'rsakey.pem',
consumer_key: nil,
consumer_secret: nil
consumer_secret: nil,
append_explicit_oauth_token_parameter: true
}.freeze

# This exception is thrown when the client is used before the OAuth access token
Expand Down Expand Up @@ -75,8 +76,9 @@ def access_token
end

def make_request(http_method, url, body = '', headers = {})
# When using oauth_2legged we need to add an empty oauth_token parameter to every request.
if @options[:auth_type] == :oauth_2legged
# Apparently we don't need to add an empty oauth_token parameter to every request; feature flagged here
# with :append_explicit_oauth_token_parameter to allow backwards compatibility
if @options[:auth_type] == :oauth_2legged && @options[:append_explicit_oauth_token_parameter]
oauth_params_str = 'oauth_token='
uri = URI.parse(url)
uri.query = if uri.query.to_s == ''
Expand Down