omniauth-zendesk-oauth2 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3745a07b89e2248bdc3d2d46ba8413d7b80f539d
4
+ data.tar.gz: d62dd6ea014b7e3ff249177b3d6ae33d089482fa
5
+ SHA512:
6
+ metadata.gz: 0df36567ad7f57b5aa089ad3a1af78a0e90d02cefa880880f440a12c9dfd980d2e4a55489bfc4e5bfc145e21a6c7592cd1b6498242b4fe32e36d3abcd5d7620a
7
+ data.tar.gz: e4b432561debc57f349c35e5b12c763b97ce1d43a63c8e97fa15103571892541bd35890741f260a61c9e682eb47699bc336eadd9e94d54423d55fc03ac889c48
@@ -0,0 +1,5 @@
1
+ Gemfile.lock
2
+ .bundle
3
+ *.gem
4
+ .config
5
+ .yardoc
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
4
+ - 1.9.3
5
+ - jruby-19mode
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rake'
7
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Jonas Oberschweiber
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # OmniAuth Zendesk via OAuth2
2
+
3
+ This strategy authenticates against Zendesk via OAuth2. You'll need an OAuth2
4
+ Application ID and Secret. See the [Zendesk help page][1] for details.
5
+
6
+ ## Usage
7
+
8
+ ```ruby
9
+ use OmniAuth::Builder.do
10
+ provider :zendesk, ENV['ZD_CLIENT'], ENV['ZD_SECRET'], client_options: {
11
+ site: 'https://yours.zendesk.com'
12
+ }, scope: 'read'
13
+ end
14
+ ```
15
+
16
+ Scope can be either `read`, `write` or `read write`.
17
+
18
+ [1]: https://support.zendesk.com/hc/en-us/articles/203663836-Using-OAuth-authentication-with-your-application#topic_pvr_ncl_1l
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Run specs'
8
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require 'omniauth-zendesk-oauth2/version'
2
+ require 'omniauth/strategies/zendesk'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Zendesk
3
+ VERSION = "0.1"
4
+ end
5
+ end
@@ -0,0 +1,46 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Zendesk < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ site: 'https://test.zendesk.com',
8
+ authorize_url: '/oauth/authorizations/new',
9
+ token_url: '/oauth/tokens'
10
+ }
11
+
12
+ option :scopes
13
+
14
+ def authorize_params
15
+ super.tap do |params|
16
+ if request.params['scope']
17
+ params[:scope] = request.params[v]
18
+ end
19
+ end
20
+ end
21
+
22
+ def raw_info
23
+ @raw_info ||= access_token.get('/api/v2/users/me.json').parsed
24
+ end
25
+
26
+ uid { raw_info['user']['email'].to_s }
27
+
28
+ info do
29
+ u = raw_info['user']
30
+ {
31
+ 'id' => u['id'],
32
+ 'name' => u['name'],
33
+ 'email' => u['email'],
34
+ 'role' => u['role'],
35
+ 'organization_id' => u['organization_id']
36
+ }
37
+ end
38
+
39
+ extra do
40
+ { 'raw_info' => raw_info }
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ OmniAuth.config.add_camelization 'zendesk', 'Zendesk'
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../lib/omniauth-zendesk-oauth2/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Jonas Oberschweiber"]
5
+ gem.email = "jonas.oberschweiber@d-velop.de"
6
+ gem.description = %q{OmniAuth Strategy for Zendesk via OAuth2}
7
+ gem.summary = %q{OmniAuth Strategy for Zendesk via OAuth2}
8
+ gem.homepage = "https://github.com/jonasoberschweiber/omniauth-zendesk-oauth2"
9
+
10
+ gem.name = "omniauth-zendesk-oauth2"
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.require_paths = ["lib"]
13
+ gem.version = OmniAuth::Zendesk::VERSION
14
+ gem.license = 'MIT'
15
+
16
+ gem.add_dependency 'omniauth', '~> 1.0'
17
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
18
+ gem.add_development_dependency 'rspec', '~> 3'
19
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Zendesk do
4
+ subject do
5
+ OmniAuth::Strategies::Zendesk.new({})
6
+ end
7
+
8
+ context 'client options' do
9
+ it 'should have correct site' do
10
+ site = subject.options.client_options.site
11
+ expect(site).to eq('https://test.zendesk.com')
12
+ end
13
+
14
+ it 'should let client override site' do
15
+ strategy = OmniAuth::Strategies::Zendesk.new(
16
+ 'KEY', 'SECRET',
17
+ client_options: { site: 'https://test2.zendesk.com' }
18
+ )
19
+ site = strategy.options.client_options.site
20
+ expect(site).to eq('https://test2.zendesk.com')
21
+ end
22
+ end
23
+
24
+ context 'info' do
25
+ before do
26
+ allow(subject).to receive(:raw_info).and_return(
27
+ 'user' => {
28
+ 'email' => 'test@test.org',
29
+ 'id' => 123,
30
+ 'name' => 'Marty McFly',
31
+ 'role' => 'admin',
32
+ 'organization_id' => 456
33
+ }
34
+ )
35
+ end
36
+
37
+ it 'returns the email as uid' do
38
+ expect(subject.uid).to eq 'test@test.org'
39
+ end
40
+
41
+ context 'puts all the info in the info hash' do
42
+ it {expect(subject.info).to have_key 'name'}
43
+ it {expect(subject.info).to have_key 'id'}
44
+ it {expect(subject.info).to have_key 'email'}
45
+ it {expect(subject.info).to have_key 'role'}
46
+ it {expect(subject.info).to have_key 'organization_id'}
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,10 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'rspec'
5
+ require 'omniauth'
6
+ require 'omniauth-zendesk-oauth2'
7
+
8
+ RSpec.configure do |config|
9
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
10
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-zendesk-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Jonas Oberschweiber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3'
55
+ description: OmniAuth Strategy for Zendesk via OAuth2
56
+ email: jonas.oberschweiber@d-velop.de
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - ".gitignore"
62
+ - ".travis.yml"
63
+ - Gemfile
64
+ - LICENSE.md
65
+ - README.md
66
+ - Rakefile
67
+ - lib/omniauth-zendesk-oauth2.rb
68
+ - lib/omniauth-zendesk-oauth2/version.rb
69
+ - lib/omniauth/strategies/zendesk.rb
70
+ - omniauth-zendesk-oauth2.gemspec
71
+ - spec/omniauth/strategies/zendesk_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: https://github.com/jonasoberschweiber/omniauth-zendesk-oauth2
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.2
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: OmniAuth Strategy for Zendesk via OAuth2
97
+ test_files: []