Class: RemoteWorkplaceAuth

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

Overview

ActiveDirectory-Exchange-Blaggh authentication guerilla-style. Will take the give username and password and try to authenticate them against the give Remote Web Workplace server. This assumes that the user on a domain also has an email address with OWA of course. If the user is found RWW will give us a specific response. No credentials or user information is retrieved. Please go and make OpenID frontends from that, I dare you!

Usage:

rww_servr = RemoteWebWorkplaceAuth.new("intranet.bigenterprise.com" use_ssl = true)
if rww_servr.authenticate("julik", "topsecret")
  puts "Yuppie!"
else
  puts "No donut"
end

Constant Summary collapse

VERSION =
"1.0.1"
VIEW_STATE_PAT =
/name="__VIEWSTATE" value="([^"]+)"/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, use_ssl = true) ⇒ RemoteWorkplaceAuth

Returns a new instance of RemoteWorkplaceAuth.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rww_auth.rb', line 28

def initialize(hostname, use_ssl = true)
  @server = hostname
  @base_login_url = '/Remote/logon.aspx?ReturnUrl=%2fRemote%2fDefault.aspx'
  @outlook = if use_ssl
    o = Net::HTTP.new(@server, 443)
    o.use_ssl = true
    o.verify_mode = OpenSSL::SSL::VERIFY_NONE
    o
  else
    Net::HTTP.new(@server)
  end
end

Instance Attribute Details

#serverObject

Returns the value of attribute server.



26
27
28
# File 'lib/rww_auth.rb', line 26

def server
  @server
end

#use_sslObject

Returns the value of attribute use_ssl.



26
27
28
# File 'lib/rww_auth.rb', line 26

def use_ssl
  @use_ssl
end

Instance Method Details

#auth(user, password) ⇒ Object

Will run the auth



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rww_auth.rb', line 42

def auth(user, password)
  with_viewstate do | payload |
      = {
      "txtUserName" => user.to_s,
      "txtUserPass" => password.to_s,
      "cmdLogin" => "cmdLogin",
      "listSpeed" => "Broadband",
      "__VIEWSTATE" => payload,
    }
    
    begin
      @outlook.start do |http|
        form_post = Net::HTTP::Post.new("/Remote/logon.aspx")
        form_post.set_form_data(, '&')
        response = http.request(form_post); response.value
      end
    rescue Net::HTTPRetriableError => e
      if e.message =~ /302/ # RWW will return a redirect if the user is found
        return true
      end
    end
    
    return false
  end
end