omniauth-desk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ coverage
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.2-p290@omniauth-desk --create
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-flickr.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2012 Salesforce.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.md ADDED
@@ -0,0 +1,40 @@
1
+ # OmniAuth Desk
2
+
3
+ This gem contains the Desk.com strategy for OmniAuth.
4
+
5
+ Desk.com uses the OAuth 1.0a flow, you can read about it here: http://dev.desk.com/docs/api/oauth
6
+
7
+ ## How To Use It
8
+
9
+ Add the strategy to your `Gemfile`:
10
+
11
+ gem 'omniauth-desk'
12
+
13
+ Or you can pull it directly from github eg:
14
+
15
+ gem 'omniauth-desk', :git => 'https://github.com/tstachl/omniauth-desk.git'
16
+
17
+ For a Rails application you'd now create an initializer `config/initializers/omniauth.rb`:
18
+
19
+ Rails.application.config.middleware.use OmniAuth::Builder do
20
+ provider :desk, 'api_key', 'api_secret', :site => 'https://yoursite.desk.com'
21
+ end
22
+
23
+ For Sinatra you'd add this 4 lines:
24
+
25
+ use Rack::Session::Cookie
26
+ use OmniAuth::Builder do
27
+ provider :desk, 'api_key', 'api_secret', :site => 'https://yoursite.desk.com'
28
+ end
29
+
30
+ You can find the api_key and the api_secret in your desk.com administration area. Click on Settings -> API -> My Applications.
31
+
32
+ ## License
33
+
34
+ Copyright (c) 2011 by Salesforce.com, Thomas Stachl <tstachl@salesforce.com>
35
+
36
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
37
+
38
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
@@ -0,0 +1,54 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ # An omniauth 1.0 strategy for Desk.com authorization
7
+ class Desk < OmniAuth::Strategies::OAuth
8
+ option :name, 'desk'
9
+ option :client_options, {
10
+ :authorize_path => '/oauth/authorize',
11
+ :request_token_path => '/oauth/request_token',
12
+ :access_token_path => '/oauth/access_token',
13
+ }
14
+
15
+ uid {
16
+ user_info['id']
17
+ }
18
+
19
+ info do
20
+ {
21
+ :name => user_info['name'],
22
+ :name_public => user_info['name_public'],
23
+ :email => user_info['email'],
24
+ :user_level => user_info['user_level'],
25
+ :login_count => user_info['login_count'],
26
+ :time_zone => user_info['time_zone']
27
+ }
28
+ end
29
+
30
+ extra do
31
+ {
32
+ :raw_info => raw_info
33
+ }
34
+ end
35
+
36
+ # Return info gathered from the verify_credentials API call
37
+ def raw_info
38
+ @raw_info ||= MultiJson.decode(access_token.get('/api/v1/account/verify_credentials.json').body)
39
+ rescue ::Errno::ETIMEDOUT
40
+ raise ::Timeout::Error
41
+ end
42
+
43
+ # Provide the "user" portion of the raw_info
44
+ def user_info
45
+ @user_info ||= raw_info.nil? ? {} : raw_info['user']
46
+ end
47
+
48
+ def request_phase
49
+ options[:client_options][:site] = options[:site] if options[:site]
50
+ super
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Desk
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-desk/version'
2
+ require 'omniauth/strategies/desk'
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-desk/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-desk"
7
+ s.version = OmniAuth::Desk::VERSION
8
+ s.authors = ["Thomas Stachl"]
9
+ s.email = ["tstachl@salesforce.com"]
10
+ s.homepage = "https://github.com/tstachl/omniauth-desk"
11
+ s.summary = %q{OmniAuth strategy for Desk.com}
12
+ s.description = %q{OmniAuth strategy for Desk.com}
13
+
14
+ s.rubyforge_project = "omniauth-desk"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency 'omniauth', '~> 1.0'
22
+ s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
23
+ s.add_runtime_dependency 'multi_json', '~> 1.3.6'
24
+
25
+ s.add_development_dependency 'rspec', '~> 2.7'
26
+ s.add_development_dependency 'rake', '~> 0.9'
27
+ s.add_development_dependency 'rack-test'
28
+ s.add_development_dependency 'simplecov'
29
+ s.add_development_dependency 'webmock'
30
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Desk do
4
+ subject do
5
+ OmniAuth::Strategies::Desk.new({})
6
+ end
7
+
8
+ context "client options" do
9
+ it 'should have correct name' do
10
+ subject.options.name.should eq("desk")
11
+ end
12
+
13
+ it 'should have correct authorize path' do
14
+ subject.options.client_options.authorize_path.should eq('/oauth/authorize')
15
+ end
16
+
17
+ it 'should have correct request token path' do
18
+ subject.options.client_options.request_token_path.should eq('/oauth/request_token')
19
+ end
20
+
21
+ it 'should have correct access token path' do
22
+ subject.options.client_options.access_token_path.should eq('/oauth/access_token')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-desk'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-desk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thomas Stachl
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &2154477140 !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: *2154477140
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth
27
+ requirement: &2154476400 !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: *2154476400
36
+ - !ruby/object:Gem::Dependency
37
+ name: multi_json
38
+ requirement: &2154475620 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.3.6
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2154475620
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &2154475000 !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: *2154475000
58
+ - !ruby/object:Gem::Dependency
59
+ name: rake
60
+ requirement: &2154474440 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '0.9'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2154474440
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: &2154474000 !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: *2154474000
80
+ - !ruby/object:Gem::Dependency
81
+ name: simplecov
82
+ requirement: &2154473420 !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: *2154473420
91
+ - !ruby/object:Gem::Dependency
92
+ name: webmock
93
+ requirement: &2154472980 !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: *2154472980
102
+ description: OmniAuth strategy for Desk.com
103
+ email:
104
+ - tstachl@salesforce.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - .gitignore
110
+ - .rspec
111
+ - .rvmrc
112
+ - Gemfile
113
+ - LICENSE
114
+ - README.md
115
+ - Rakefile
116
+ - lib/omniauth-desk.rb
117
+ - lib/omniauth-desk/version.rb
118
+ - lib/omniauth/strategies/desk.rb
119
+ - omniauth-desk.gemspec
120
+ - spec/omniauth/strategies/desk_spec.rb
121
+ - spec/spec_helper.rb
122
+ homepage: https://github.com/tstachl/omniauth-desk
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
+ segments:
135
+ - 0
136
+ hash: 2036770633909583126
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ segments:
144
+ - 0
145
+ hash: 2036770633909583126
146
+ requirements: []
147
+ rubyforge_project: omniauth-desk
148
+ rubygems_version: 1.8.10
149
+ signing_key:
150
+ specification_version: 3
151
+ summary: OmniAuth strategy for Desk.com
152
+ test_files:
153
+ - spec/omniauth/strategies/desk_spec.rb
154
+ - spec/spec_helper.rb