casual 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/casual.gemspec +2 -2
  3. data/lib/casual.rb +9 -14
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{casual}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Zach Holman"]
12
- s.date = %q{2010-08-06}
12
+ s.date = %q{2010-08-10}
13
13
  s.description = %q{A tiny CAS client for Ruby}
14
14
  s.email = %q{github.com@zachholman.com}
15
15
  s.extra_rdoc_files = [
@@ -3,7 +3,7 @@ require 'hpricot'
3
3
 
4
4
  module Casual
5
5
  class Client
6
- attr_accessor :hostname, :path, :https, :port, :callback_url, :jasig
6
+ attr_accessor :hostname, :path, :https, :port, :callback_url
7
7
 
8
8
  def initialize(config)
9
9
  @hostname = config[:hostname]
@@ -18,32 +18,27 @@ module Casual
18
18
  end
19
19
 
20
20
  def authenticate(username,password)
21
- ticket = acquire_ticket
21
+ login_page = connection.get("/#{no_slash_path}/login")
22
+ headers = { 'Cookie' => login_page.response["set-cookie"] }
23
+ ticket = acquire_ticket(login_page)
22
24
  params = "username=#{username}&password=#{password}&lt=#{ticket}"
23
- params << '&_eventId=submit&submit=LOGIN' if jasig
25
+ params << '&_eventId=submit&submit=LOGIN'
26
+
24
27
  status,response =
25
- connection.post("/#{no_slash_path}/login#{jasig}", params)
28
+ connection.post("/#{no_slash_path}/login", params, headers)
26
29
 
27
- if jasig
30
+ if response =~ /JA-SIG/
28
31
  (response =~ /Log In Successful/) ? username : nil
29
32
  else
30
33
  status.code == '200' ? username : nil
31
34
  end
32
35
  end
33
36
 
34
- def acquire_ticket
35
- login_page = connection.get("/#{no_slash_path}/login")
37
+ def acquire_ticket(login_page)
36
38
  ticket = Hpricot(login_page.body).search('input[@name=lt]').first
37
- jasig_eats_babies(login_page.body)
38
39
  ticket ? ticket['value'] : nil
39
40
  end
40
41
 
41
- def jasig_eats_babies(body)
42
- @jasig = ';'
43
- @jasig << Hpricot(body).search('form[@id=fm1]').
44
- first['action'].split(';').last
45
- end
46
-
47
42
  def connection
48
43
  http = Net::HTTP.new(hostname, port)
49
44
  http.use_ssl = @https
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: casual
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zach Holman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-06 00:00:00 -07:00
18
+ date: 2010-08-10 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency