omniauth-broadworks 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/Gemfile +11 -0
- data/Guardfile +11 -0
- data/LICENSE +19 -0
- data/README.rdoc +17 -0
- data/Rakefile +10 -0
- data/lib/omniauth-broadworks.rb +2 -0
- data/lib/omniauth-broadworks/version.rb +5 -0
- data/lib/omniauth/strategies/broadworks.rb +45 -0
- data/omniauth-broadworks.gemspec +26 -0
- data/spec/omniauth/strategies/broadworks_spec.rb +49 -0
- data/spec/spec_helper.rb +16 -0
- metadata +149 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011-2012 Jan Xie <jan.h.xie@gmail.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= OmniAuth::Broadworks
|
2
|
+
|
3
|
+
OmniAuth stratgies to pull user profile from Broadworks through XSI api.
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
Install manually or using Bundler:
|
8
|
+
|
9
|
+
gem 'omniauth-broadworks'
|
10
|
+
|
11
|
+
Add :broadworks provider to omniauth builder:
|
12
|
+
|
13
|
+
# configuration for xdp sandbox
|
14
|
+
use OmniAuth::Builder do
|
15
|
+
provider :broadworks, "http://xsp1.xdp.broadsoft.com/com.broadsoft.xsi-actions/v2.0", domain: 'xdp.broadsoft.com'
|
16
|
+
# provider ...
|
17
|
+
end
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'omniauth-http-basic'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Broadworks < OmniAuth::Strategies::HttpBasic
|
7
|
+
|
8
|
+
option :title, "Broadworks Login"
|
9
|
+
|
10
|
+
uid { content_of('Profile/details/userId') }
|
11
|
+
|
12
|
+
credentials { {:username => username, :password => password, :expires_days => content_of('Profile/passwordExpiresDays')} }
|
13
|
+
|
14
|
+
info do
|
15
|
+
{ :name => "#{content_of('Profile/details/firstName')} #{content_of('Profile/details/lastName')}",
|
16
|
+
:nickname => request['username'] }
|
17
|
+
end
|
18
|
+
|
19
|
+
extra do
|
20
|
+
{ :number => content_of('Profile/details/number'),
|
21
|
+
:extension => content_of('Profile/details/extension'),
|
22
|
+
:group => content_of('Profile/details/groupId'),
|
23
|
+
:provider => content_of('Profile/details/serviceProvider') }
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def api_uri
|
29
|
+
"#{options.endpoint}/user/#{username}/profile"
|
30
|
+
end
|
31
|
+
|
32
|
+
def username
|
33
|
+
"#{request['username']}@#{options.domain}" if request['username']
|
34
|
+
end
|
35
|
+
|
36
|
+
def xml_response
|
37
|
+
@xml_response ||= Nokogiri.XML(authentication_response.body)
|
38
|
+
end
|
39
|
+
|
40
|
+
def content_of(path)
|
41
|
+
xml_response.search(path).first.content
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path('../lib/omniauth-broadworks/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
6
|
+
gem.add_dependency 'omniauth-http-basic', '~> 1.0'
|
7
|
+
gem.add_dependency 'nokogiri'
|
8
|
+
|
9
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
10
|
+
gem.add_development_dependency 'rack-test'
|
11
|
+
gem.add_development_dependency 'simplecov'
|
12
|
+
gem.add_development_dependency 'webmock'
|
13
|
+
gem.add_development_dependency 'yard'
|
14
|
+
|
15
|
+
gem.authors = ['Jan Xie']
|
16
|
+
gem.email = ['jan.h.xie@gmail.com']
|
17
|
+
gem.description = %q{Broadworks strategy for OmniAuth.}
|
18
|
+
gem.summary = gem.description
|
19
|
+
gem.homepage = 'http://github.com/janx/omniauth-broadworks'
|
20
|
+
|
21
|
+
gem.name = 'omniauth-broadworks'
|
22
|
+
gem.require_paths = ['lib']
|
23
|
+
gem.files = `git ls-files`.split("\n")
|
24
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
gem.version = OmniAuth::Broadworks::VERSION
|
26
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
RESPONSE_XML = <<EOF
|
4
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
5
|
+
<Profile xmlns="http://schema.broadsoft.com/xsi">
|
6
|
+
<details>
|
7
|
+
<userId>Test1234User1@xdp.broadsoft.com</userId>
|
8
|
+
<firstName>Test1234</firstName>
|
9
|
+
<lastName>User1</lastName>
|
10
|
+
<groupId>Test1234Group</groupId>
|
11
|
+
<serviceProvider isEnterprise="true">Test1234Ent</serviceProvider>
|
12
|
+
<number>1234567890</number>
|
13
|
+
<extension>1234</extension>
|
14
|
+
</details>
|
15
|
+
<additionalDetails />
|
16
|
+
<passwordExpiresDays>2147483647</passwordExpiresDays>
|
17
|
+
<fac>/v2.0/user/Test1234User1@xdp.broadsoft.com/profile/Fac</fac>
|
18
|
+
<registrations>
|
19
|
+
/v2.0/user/Test1234User1@xdp.broadsoft.com/profile/Registrations</registrations>
|
20
|
+
<scheduleList>
|
21
|
+
/v2.0/user/Test1234User1@xdp.broadsoft.com/profile/Schedule</scheduleList>
|
22
|
+
<portalPasswordChange>
|
23
|
+
/v2.0/user/Test1234User1@xdp.broadsoft.com/profile/Password/Portal</portalPasswordChange>
|
24
|
+
<countryCode>1</countryCode>
|
25
|
+
</Profile>
|
26
|
+
EOF
|
27
|
+
|
28
|
+
describe OmniAuth::Strategies::Broadworks do
|
29
|
+
def app; lambda {|env| [200, {}, ["Hello HttpBasic!"]]}; end
|
30
|
+
|
31
|
+
let(:fresh_strategy) { Class.new OmniAuth::Strategies::Broadworks }
|
32
|
+
let(:instance) { subject.new(app, "http://www.example.com/xsi", :domain => "xdp.broadsoft.com") }
|
33
|
+
subject { fresh_strategy }
|
34
|
+
|
35
|
+
it 'should be initialized with XSI endpoint and sip domain' do
|
36
|
+
instance.options.endpoint.should == "http://www.example.com/xsi"
|
37
|
+
instance.options.domain.should == "xdp.broadsoft.com"
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should set auth hash' do
|
41
|
+
xml = Nokogiri.XML(RESPONSE_XML)
|
42
|
+
instance.stub!(:request).and_return({'username' => 'test1234', 'password' => '1234'})
|
43
|
+
instance.stub!(:xml_response).and_return(xml)
|
44
|
+
instance.uid.should == "Test1234User1@xdp.broadsoft.com"
|
45
|
+
instance.credentials[:username].should == 'test1234@xdp.broadsoft.com'
|
46
|
+
instance.info[:name].should == 'Test1234 User1'
|
47
|
+
instance.extra[:number].should == '1234567890'
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'simplecov'
|
5
|
+
SimpleCov.start
|
6
|
+
require 'rspec'
|
7
|
+
require 'rack/test'
|
8
|
+
require 'webmock/rspec'
|
9
|
+
require 'omniauth'
|
10
|
+
require 'omniauth-broadworks'
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.include WebMock::API
|
14
|
+
config.include Rack::Test::Methods
|
15
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-broadworks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jan Xie
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-21 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: &14544300 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *14544300
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: omniauth-http-basic
|
27
|
+
requirement: &14543800 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *14543800
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: nokogiri
|
38
|
+
requirement: &14543420 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *14543420
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &14542880 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.7'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *14542880
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rack-test
|
60
|
+
requirement: &14542460 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *14542460
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: &14542000 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *14542000
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: webmock
|
82
|
+
requirement: &14541580 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *14541580
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: yard
|
93
|
+
requirement: &14541160 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *14541160
|
102
|
+
description: Broadworks strategy for OmniAuth.
|
103
|
+
email:
|
104
|
+
- jan.h.xie@gmail.com
|
105
|
+
executables: []
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- .gitignore
|
110
|
+
- .rspec
|
111
|
+
- Gemfile
|
112
|
+
- Guardfile
|
113
|
+
- LICENSE
|
114
|
+
- README.rdoc
|
115
|
+
- Rakefile
|
116
|
+
- lib/omniauth-broadworks.rb
|
117
|
+
- lib/omniauth-broadworks/version.rb
|
118
|
+
- lib/omniauth/strategies/broadworks.rb
|
119
|
+
- omniauth-broadworks.gemspec
|
120
|
+
- spec/omniauth/strategies/broadworks_spec.rb
|
121
|
+
- spec/spec_helper.rb
|
122
|
+
homepage: http://github.com/janx/omniauth-broadworks
|
123
|
+
licenses: []
|
124
|
+
post_install_message:
|
125
|
+
rdoc_options: []
|
126
|
+
require_paths:
|
127
|
+
- lib
|
128
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ! '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 1.8.6
|
143
|
+
signing_key:
|
144
|
+
specification_version: 3
|
145
|
+
summary: Broadworks strategy for OmniAuth.
|
146
|
+
test_files:
|
147
|
+
- spec/omniauth/strategies/broadworks_spec.rb
|
148
|
+
- spec/spec_helper.rb
|
149
|
+
has_rdoc:
|