oa-cadun 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module OACadun
2
2
  module VERSION
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY] * '.'
8
8
  end
@@ -1,14 +1,21 @@
1
+ require 'cadun/config'
2
+ require 'cadun/user'
3
+ require 'cadun/gateway'
4
+
1
5
  module OmniAuth
2
6
  module Strategies
3
7
  class Cadun
4
8
  include OmniAuth::Strategy
9
+ include ::Cadun
5
10
 
6
11
  def initialize(app, options = {})
12
+ Config.load_file(options[:config])
13
+
7
14
  super(app, :cadun, options)
8
15
  end
9
16
 
10
17
  def request_phase
11
- redirect "https://login.dev.globoi.com/login/#{service_id}?url=#{callback_url}"
18
+ redirect "#{Config.login_url}/#{service_id}?url=#{callback_url}"
12
19
  end
13
20
 
14
21
  def auth_hash
@@ -39,7 +46,7 @@ module OmniAuth
39
46
 
40
47
  protected
41
48
  def user
42
- @user ||= ::Cadun::User.new(request.params['GLBID'], env['REMOTE_ADDR'], service_id)
49
+ @user ||= User.new(request.params['GLBID'], env['REMOTE_ADDR'], service_id)
43
50
  end
44
51
 
45
52
  def service_id
@@ -47,10 +54,11 @@ module OmniAuth
47
54
  end
48
55
 
49
56
  def callback_url
50
- uri = URI.parse(request.referer)
51
- port = uri.port == 80 ? nil : ":#{uri.port}"
57
+ uri = request.env['HTTP_HOST']
58
+ port = request.env['SERVER_PORT'] == "80" ? nil : ":#{request.env['SERVER_PORT']}"
59
+ scheme = request.env['rack.url_scheme']
52
60
 
53
- callback_url = "http://#{uri.host}#{port}/auth/cadun/callback"
61
+ callback_url = "#{scheme}://#{uri}#{port}/auth/cadun/callback"
54
62
  URI.escape(callback_url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
55
63
  end
56
64
  end
@@ -4,12 +4,12 @@ require 'spec_helper'
4
4
  describe OmniAuth::Strategies::Cadun do
5
5
 
6
6
  let(:app) { lambda { |env| [200, {}, ['Hello']] } }
7
- let(:strategy) { OmniAuth::Strategies::Cadun.new(app, :service_id => 1) }
7
+ let(:strategy) { OmniAuth::Strategies::Cadun.new(app, :service_id => 1, :config => File.join(File.dirname(__FILE__), "..", "..", "support", "fixtures", "config.yml")) }
8
8
 
9
9
  describe "#request_phase" do
10
10
  context "when it has a referer" do
11
11
  before do
12
- strategy.call!(Rack::MockRequest.env_for("", "rack.session" => {}, "HTTP_REFERER" => "http://test.localhost/auth/cadun"))
12
+ strategy.call!(Rack::MockRequest.env_for("http://test.localhost/auth/cadun", "rack.session" => {}, "HTTP_HOST" => "test.localhost"))
13
13
 
14
14
  @status, @headers, @body = strategy.request_phase
15
15
  end
@@ -27,7 +27,7 @@ describe OmniAuth::Strategies::Cadun do
27
27
 
28
28
  context "when it has a referer and a different port" do
29
29
  before do
30
- strategy.call!(Rack::MockRequest.env_for("", "rack.session" => {}, "HTTP_REFERER" => "http://test.localhost:8080/auth/cadun"))
30
+ strategy.call!(Rack::MockRequest.env_for("http://test.localhost:8080/auth/cadun", "rack.session" => {}, "HTTP_HOST" => "test.localhost", "SERVER_PORT" => "8080"))
31
31
 
32
32
  @status, @headers, @body = strategy.request_phase
33
33
  end
@@ -0,0 +1,5 @@
1
+ cadun:
2
+ logout_url: https://login.dev.globoi.com/Servlet/do/logout
3
+ login_url: https://login.dev.globoi.com/login
4
+ auth_url: isp-authenticator.dev.globoi.com
5
+ auth_port: 8280
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: oa-cadun
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 3.0.2
5
+ version: 3.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Bruno Azisaka Maciel
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-23 00:00:00 -03:00
13
+ date: 2011-05-24 00:00:00 -03:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -103,6 +103,7 @@ files:
103
103
  - spec/omni_auth/strategies/cadun_spec.rb
104
104
  - spec/spec_helper.rb
105
105
  - spec/support/fixtures/autorizacao.xml
106
+ - spec/support/fixtures/config.yml
106
107
  - spec/support/fixtures/pessoa.xml
107
108
  has_rdoc: true
108
109
  homepage: ""
@@ -136,4 +137,5 @@ test_files:
136
137
  - spec/omni_auth/strategies/cadun_spec.rb
137
138
  - spec/spec_helper.rb
138
139
  - spec/support/fixtures/autorizacao.xml
140
+ - spec/support/fixtures/config.yml
139
141
  - spec/support/fixtures/pessoa.xml