omniauth-bootic 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ce4de8d97deae116fadba5fac0e1920c9ff80475
4
+ data.tar.gz: 9cbc58ccfa03385516c36c34b2c243979b728bd1
5
+ SHA512:
6
+ metadata.gz: 774609b1e35d6e18c97aa2465a1f5b9986ef43a470e94f1ffb6b9b4541587f14684b30c25c6d7b02ecd3907e056dc3224c64c0993e313e25d71fde9b005fd694
7
+ data.tar.gz: e8c56b941b7b9bcb47c93f5bc0a76812e91341ded0ab26f4d20a51dbae4ce2d55a28de34dda3874811795518c644d3acb1a2387d880d4916ca39a534555b1a11
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-bootic.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # OmniAuth Bootic
2
+
3
+ This is the official OmniAuth strategy for authenticating to Bootic. Bootic's API is in alpha and not production ready (coming soon).
4
+
5
+ Please refer to the [Omniauth](https://github.com/intridea/omniauth) gem for more detail.
6
+
7
+ ## Basic Usage
8
+
9
+ ```ruby
10
+ use OmniAuth::Builder do
11
+ provider :bootic, ENV['BOOTIC_KEY'], ENV['BOOTIC_SECRET']
12
+ end
13
+ ```
14
+
15
+ ### Scopes
16
+
17
+ Bootic's API lets you set scopes to provide granular access to your Bootic data:
18
+
19
+ ```ruby
20
+ use OmniAuth::Builder do
21
+ provider :bootic, ENV['BOOTIC_KEY'], ENV['BOOTIC_SECRET'], scope: 'public,administrador,offline'
22
+ end
23
+ ```
24
+
25
+ ## License
26
+
27
+ Copyright (c) 2012 Ismael Celis of Inventario SPA.
28
+
29
+ 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:
30
+
31
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
32
+
33
+ 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'
2
+ Bundler::GemHelper.install_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,63 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Bootic < OmniAuth::Strategies::OAuth2
6
+
7
+ BOOTIC_AUTH_URL = (ENV['BOOTIC_AUTH_URL'] || "https://auth.bootic.net")
8
+ BOOTIC_API_URL = (ENV['BOOTIC_API_URL'] || "https://api.bootic.net/v1")
9
+
10
+ # Give your strategy a name.
11
+ option :name, "Bootic"
12
+ option :provider_ignores_state, true
13
+
14
+ # This is where you pass the options you would pass when
15
+ # initializing your consumer from the OAuth gem.
16
+ option :client_options, {
17
+ site: BOOTIC_API_URL,
18
+ authorize_url: "#{BOOTIC_AUTH_URL}/oauth/authorize",
19
+ token_url: "#{BOOTIC_AUTH_URL}/oauth/token"
20
+ }
21
+
22
+ def request_phase
23
+ super
24
+ end
25
+
26
+ def authorize_params
27
+ if request.params['scope']
28
+ super.merge({scope: request.params['scope']})
29
+ else
30
+ super
31
+ end
32
+ end
33
+
34
+ # These are called after authentication has succeeded. If
35
+ # possible, you should try to set the UID without making
36
+ # additional calls (if the user id is returned with the token
37
+ # or as a URI parameter). This may not be possible with all
38
+ # providers.
39
+ uid{ raw_info['uid'].to_s }
40
+
41
+ info do
42
+ {
43
+ name: raw_info['user_name'],
44
+ email: raw_info['email'],
45
+ shops: raw_info['_embedded']['shops']
46
+ }
47
+ end
48
+
49
+ extra do
50
+ {
51
+ 'raw_info' => raw_info
52
+ }
53
+ end
54
+
55
+ def raw_info
56
+ @raw_info ||= access_token.get('/v1').parsed
57
+ end
58
+
59
+ end
60
+ end
61
+ end
62
+
63
+ OmniAuth.config.add_camelization 'bootic', 'Bootic'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Bootic
3
+ VERSION = "0.0.3"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-bootic/version"
2
+ require 'omniauth/strategies/bootic'
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-bootic/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-bootic"
7
+ s.version = Omniauth::Bootic::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Ismael Celis"]
10
+ s.email = ["ismael@bootic.net"]
11
+ s.homepage = ""
12
+ s.summary = %q{Official Omniauth strategy for Bootic apps}
13
+ s.description = %q{Official Omniauth strategy for Bootic apps}
14
+
15
+ s.rubyforge_project = "omniauth-bootic"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'omniauth', '~> 1.0'
23
+ s.add_dependency 'omniauth-oauth2', '~> 1.0'
24
+ s.add_development_dependency 'rspec', '~> 2.7'
25
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Bootic do
4
+ subject do
5
+ OmniAuth::Strategies::Bootic.new({})
6
+ end
7
+
8
+ context "client options" do
9
+ it 'should have correct site' do
10
+ subject.options.client_options.site.should eq("https://api.bootic.net/v1")
11
+ end
12
+
13
+ it 'should have correct authorize url' do
14
+ subject.options.client_options.authorize_url.should eq('https://auth.bootic.net/oauth/authorize')
15
+ end
16
+
17
+ it 'should have correct token url' do
18
+ subject.options.client_options.token_url.should eq('https://auth.bootic.net/oauth/token')
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,7 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'rspec'
5
+
6
+ require 'omniauth'
7
+ require 'omniauth-bootic'
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-bootic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Ismael Celis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-17 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.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.7'
55
+ description: Official Omniauth strategy for Bootic apps
56
+ email:
57
+ - ismael@bootic.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - README.md
65
+ - Rakefile
66
+ - lib/omniauth-bootic.rb
67
+ - lib/omniauth-bootic/version.rb
68
+ - lib/omniauth/strategies/bootic.rb
69
+ - omniauth-bootic.gemspec
70
+ - spec/omniauth/strategies/bootic_spec.rb
71
+ - spec/spec_helper.rb
72
+ homepage: ''
73
+ licenses: []
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project: omniauth-bootic
91
+ rubygems_version: 2.0.3
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Official Omniauth strategy for Bootic apps
95
+ test_files:
96
+ - spec/omniauth/strategies/bootic_spec.rb
97
+ - spec/spec_helper.rb