Class: MingleAccess::BasicAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/basic_auth.rb

Constant Summary collapse

BASIC_AUTH_HTTP_WARNING =
%{     
WARNING!!!
It looks like you are using basic authentication over a plain-text HTTP connection. 
We HIGHLY recommend AGAINST this practice. You should only use basic authentication over
a secure HTTPS connection. Instructions for enabling HTTPS/SSL in Mingle can be found at
<http://www.thoughtworks-studios.com/mingle/3.4/help/advanced_mingle_configuration.html>
WARNING!!
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_url, username, password) ⇒ BasicAuth

Returns a new instance of BasicAuth.



16
17
18
19
20
# File 'lib/basic_auth.rb', line 16

def initialize(base_url, username, password)
  @base_url = base_url
  @username = username
  @password = password
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



5
6
7
# File 'lib/basic_auth.rb', line 5

def base_url
  @base_url
end

Instance Method Details

#fetch_page(location) ⇒ Object

Fetch the content at location via HTTP. Throws error if non-200 response.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/basic_auth.rb', line 23

def fetch_page(location) 
  rsp = fetch_page_response(location)    
  case rsp
  when Net::HTTPSuccess
    rsp.body
  when Net::HTTPUnauthorized
    raise HttpError.new(rsp, location, %{
    If you think you are passing correct credentials, please check 
    that you have enabled Mingle for basic authentication. 
    See <http://www.thoughtworks-studios.com/mingle/3.4/help/configuring_mingle_authentication.html>.})
  else
    raise HttpError.new(rsp, location) 
  end
end