Class: GitDuplicator::Helpers::AuthorizationHeader
- Inherits:
-
Object
- Object
- GitDuplicator::Helpers::AuthorizationHeader
- Defined in:
- lib/git_duplicator/helpers/authorization_header.rb
Overview
Generates authentication header
Constant Summary collapse
- OAUTH2_KEYS =
[:oauth2_token]
- OAUTH_KEYS =
[:consumer_key, :consumer_secret, :token, :token_secret]
- BASIC_KEYS =
[:username, :password]
Instance Method Summary collapse
-
#generate ⇒ Object
Generate the header.
-
#initialize(credentials, request) ⇒ AuthorizationHeader
constructor
A new instance of AuthorizationHeader.
Constructor Details
#initialize(credentials, request) ⇒ AuthorizationHeader
Returns a new instance of AuthorizationHeader.
24 25 26 27 28 29 |
# File 'lib/git_duplicator/helpers/authorization_header.rb', line 24 def initialize(credentials, request) self.credentials = credentials self.request_method = request.fetch(:method) self.request_url = request.fetch(:url) self.request_params = request.fetch(:params) { [] } end |
Instance Method Details
#generate ⇒ Object
Generate the header
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/git_duplicator/helpers/authorization_header.rb', line 32 def generate if exists?(self.class::OAUTH2_KEYS) oauth2_header elsif exists?(self.class::OAUTH_KEYS) oauth_header elsif exists?(self.class::BASIC_KEYS) basic_authenticaion_header else fail ArgumentError, 'Proper authentication keys are missing' end end |