omniauth-boletosimples 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb69873f0a79171d7ae771a54063aded5bb12994
4
+ data.tar.gz: c8ff225473b4b67b9cafa22430cc34c0c1f6bccf
5
+ SHA512:
6
+ metadata.gz: 66d1540bf4eb0adf976d5ce16ae1b0dbd301a1cb0c97bc965d80593f91bd1b3ae09a35ad2840c024d477f7083b039909104b6c5ffbaf7924d5c7d1af2b3f7b6d
7
+ data.tar.gz: ef8dc9ea47a69b755a67f470e9b3bc9ebe631b740fa8b7d92844c709e970b3ef07a76268688b89162cf10cfdbaf2a401d1b82c15696fd16895b031aecb619855
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ omniauth-boletosimples
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.0.1 (Unreleased)
4
+
5
+ ### features
6
+
7
+ ### improvements
8
+
9
+ ### bug fixes
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,47 @@
1
+ # Contributing
2
+
3
+ We love pull requests. Here's a quick guide:
4
+
5
+ 1. Fork the repo.
6
+
7
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
8
+
9
+ 3. Run the tests. We only take pull requests with passing tests, and it's great
10
+ to know that you have a clean slate: `bundle && rake`
11
+
12
+ 4. Add a test for your change. Only refactoring and documentation changes
13
+ require no new tests. If you are adding functionality or fixing a bug, we need
14
+ a test!
15
+
16
+ 5. Make the test pass.
17
+
18
+ 6. Update [CHANGELOG.md](https://github.com/BoletoSimples/omniauth-boletosimples/blob/master/CHANGELOG.md) with a brief description of your changes under the `unreleased` heading.
19
+
20
+ 7. Commit your changes (`git commit -am 'Added some feature'`)
21
+
22
+ 8. Push to the branch (`git push origin my-new-feature`)
23
+
24
+ 9. Create new Pull Request
25
+
26
+ At this point you're waiting on us. We like to at least comment on, if not
27
+ accept, pull requests within three business days (and, typically, one business
28
+ day). We may suggest some changes or improvements or alternatives.
29
+
30
+ Some things that will increase the chance that your pull request is accepted,
31
+ taken straight from the Ruby on Rails guide:
32
+
33
+ * Use Rails idioms and helpers
34
+ * Include tests that fail without your code, and pass with it
35
+ * Update the documentation, the surrounding one, examples elsewhere, guides,
36
+ whatever is affected by your contribution
37
+
38
+ Syntax:
39
+
40
+ * Two spaces, no tabs.
41
+ * No trailing whitespace. Blank lines should not have any space.
42
+ * Prefer &&/|| over and/or.
43
+ * my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
44
+ * a = b and not a=b.
45
+ * Follow the conventions you see used in the source already.
46
+
47
+ And in case we didn't emphasize it enough: we love tests!
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'omniauth-oauth2', "~>1.1.1", :git => 'git://github.com/intridea/omniauth-oauth2.git'
6
+ gem 'json'
data/Gemfile.lock ADDED
@@ -0,0 +1,58 @@
1
+ GIT
2
+ remote: git://github.com/intridea/omniauth-oauth2.git
3
+ revision: a022bc00f5cc08c69043317673f9b8d0542ba15c
4
+ specs:
5
+ omniauth-oauth2 (1.1.2)
6
+ faraday (>= 0.8, < 0.10)
7
+ multi_json (~> 1.3)
8
+ oauth2 (~> 0.9.3)
9
+ omniauth (~> 1.2)
10
+
11
+ PATH
12
+ remote: .
13
+ specs:
14
+ omniauth-boletosimples (0.0.1)
15
+ omniauth-oauth2 (~> 1.1.0)
16
+
17
+ GEM
18
+ remote: https://rubygems.org/
19
+ specs:
20
+ diff-lcs (1.2.5)
21
+ faraday (0.9.0)
22
+ multipart-post (>= 1.2, < 3)
23
+ hashie (2.1.0)
24
+ json (1.8.1)
25
+ jwt (0.1.11)
26
+ multi_json (>= 1.5)
27
+ multi_json (1.9.2)
28
+ multi_xml (0.5.5)
29
+ multipart-post (2.0.0)
30
+ oauth2 (0.9.3)
31
+ faraday (>= 0.8, < 0.10)
32
+ jwt (~> 0.1.8)
33
+ multi_json (~> 1.3)
34
+ multi_xml (~> 0.5)
35
+ rack (~> 1.2)
36
+ omniauth (1.2.1)
37
+ hashie (>= 1.2, < 3)
38
+ rack (~> 1.0)
39
+ rack (1.5.2)
40
+ rake (10.2.2)
41
+ rspec (2.14.1)
42
+ rspec-core (~> 2.14.0)
43
+ rspec-expectations (~> 2.14.0)
44
+ rspec-mocks (~> 2.14.0)
45
+ rspec-core (2.14.8)
46
+ rspec-expectations (2.14.5)
47
+ diff-lcs (>= 1.1.3, < 2.0)
48
+ rspec-mocks (2.14.6)
49
+
50
+ PLATFORMS
51
+ ruby
52
+
53
+ DEPENDENCIES
54
+ json
55
+ omniauth-boletosimples!
56
+ omniauth-oauth2 (~> 1.1.1)!
57
+ rake
58
+ rspec (~> 2.14)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Rafael Lima
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # OmniAuth BoletoSimples
2
+
3
+ This gem contains the Log In With Boleto Simples strategy for OmniAuth.
4
+
5
+ ## Installing
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem "omniauth-boletosimples"
11
+ ```
12
+
13
+ Then:
14
+
15
+ $ bundle install
16
+
17
+ ## Usage
18
+
19
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`.
20
+
21
+ ```ruby
22
+ Rails.application.config.middleware.use OmniAuth::Builder do
23
+ provider :boletosimples, ENV['APP_ID'], ENV['APP_TOKEN'], sandbox: true, scope: "profile email"
24
+ end
25
+ ```
26
+
27
+ ## Attributes and Scopes
28
+
29
+ The possible attributes to be returned at the moment are:
30
+
31
+ ```ruby
32
+ info['name']
33
+ info['email']
34
+
35
+ extra['raw_info']
36
+ ```
37
+
38
+ The actual set of attributes returned depends on the scopes set. The currently available scopes are:
39
+
40
+ ```
41
+ profile
42
+ email
43
+ write
44
+ read
45
+ webhook
46
+ ```
47
+
48
+ ## Registering for an API key
49
+
50
+ To register your application for Log In With Boleto Simples [open a ticket](http://suporte.boletosimples.com.br) asking for credentials to your app.
51
+
52
+ ## Example of result auth hash
53
+ With all scopes requested.
54
+
55
+ ```yaml
56
+ provider: boletosimples
57
+ uid: 1
58
+ info:
59
+ person_type: 'individual'
60
+ person_name: 'Henry Renato Leonardo Barros'
61
+ email: 'henry@example.com'
62
+ cnpj_cpf: '139.586.432-21'
63
+ credentials:
64
+ token: <token>
65
+ refresh_token: <refresh token>
66
+ expires_at: 1355082790
67
+ expires: true
68
+ extra:
69
+ address_street_name: 'Rua AS 3'
70
+ address_number: '349'
71
+ address_complement: 'apto 101'
72
+ address_state: 'GO'
73
+ address_city_name: 'Rio Verde'
74
+ address_neighborhood: 'Residencial Água Santa'
75
+ address_postal_code: '75909-517'
76
+ phone_number: '6336151015'
77
+ banking_bank_number: '237'
78
+ banking_agency_number: '3290'
79
+ banking_account_number: '1028'
80
+ banking_account_digit: '9'
81
+ banking_person_type: 'individual'
82
+ banking_person_name: 'Henry Renato Leonardo Barros'
83
+ banking_cnpj_cpf: '139.586.432-21'
84
+ paypal_account: 'henry@example.com'
85
+ ```
86
+
87
+ ## Issues
88
+
89
+ If you have problems, please create a [Github Issue](https://github.com/BoletoSimples/omniauth-boletosimples/issues).
90
+
91
+ ## Contributing
92
+
93
+ Please see [CONTRIBUTING.md](https://github.com/BoletoSimples/omniauth-boletosimples/blob/master/CONTRIBUTING.md) for details.
94
+
95
+ ## Credits
96
+
97
+ OmniAuth BoletoSimples was originally written by [Rafael Lima](http://rafael.adm.br) based on [omniauth-paypal](https://github.com/datariot/omniauth-paypal)
98
+ Thank you to all the [contributors](https://github.com/BoletoSimples/omniauth-boletosimples/graphs/contributors).
99
+
100
+ ## License
101
+
102
+ OmniAuth BoletoSimples is Copyright © 2014 Rafael Lima. It is free software, and may be redistributed under the terms specified in the [LICENSE](https://github.com/BoletoSimples/omniauth-boletosimples/blob/master/LICENSE) file.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module BoletoSimples
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth/boletosimples/version'
2
+ require 'omniauth/strategies/boletosimples'
@@ -0,0 +1,81 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class BoletoSimples < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPE = "profile"
7
+ ENVIRONMENTS = {
8
+ development: 'http://localhost:5000',
9
+ sandbox: 'https://sandbox.boletosimples.com.br',
10
+ production: 'https://boletosimples.com.br',
11
+ }
12
+ option :name, 'boletosimples'
13
+ option :client_options, {
14
+ :token_url => '/api/v1/oauth2/token',
15
+ :setup => true
16
+ }
17
+
18
+ option :authorize_options, [:scope, :response_type]
19
+ option :provider_ignores_state, true
20
+ option :sandbox, false
21
+
22
+ uid { raw_info['id'] }
23
+
24
+ info do
25
+ {
26
+ person_type: raw_info['person_type'],
27
+ person_name: raw_info['person_name'],
28
+ email: raw_info['email'],
29
+ cnpj_cpf: raw_info['cnpj_cpf']
30
+ }
31
+ end
32
+
33
+ extra do
34
+ {
35
+ address_street_name: raw_info['address_street_name'],
36
+ address_number: raw_info['address_number'],
37
+ address_complement: raw_info['address_complement'],
38
+ address_state: raw_info['address_state'],
39
+ address_city_name: raw_info['address_city_name'],
40
+ address_neighborhood: raw_info['address_neighborhood'],
41
+ address_postal_code: raw_info['address_postal_code'],
42
+ phone_number: raw_info['phone_number'],
43
+ banking_bank_number: raw_info['banking_bank_number'],
44
+ banking_agency_number: raw_info['banking_agency_number'],
45
+ banking_account_number: raw_info['banking_account_number'],
46
+ banking_account_digit: raw_info['banking_account_digit'],
47
+ banking_person_type: raw_info['banking_person_type'],
48
+ banking_person_name: raw_info['banking_person_name'],
49
+ banking_cnpj_cpf: raw_info['banking_cnpj_cpf'],
50
+ paypal_account: raw_info['paypal_account'],
51
+ }
52
+ end
53
+
54
+ def setup_phase
55
+ environment = options.environment || :production
56
+ options.client_options[:site] = ENVIRONMENTS[environment.to_sym]
57
+ options.client_options[:authorize_url] = "#{ENVIRONMENTS[environment.to_sym]}/api/v1/oauth2/authorize"
58
+ end
59
+
60
+ def raw_info
61
+ @raw_info ||= load_identity
62
+ end
63
+
64
+ def authorize_params
65
+ super.tap do |params|
66
+ params[:scope] ||= DEFAULT_SCOPE
67
+ end
68
+ end
69
+
70
+ private
71
+ def load_identity
72
+ access_token.options[:mode] = :query
73
+ access_token.options[:param_name] = :access_token
74
+ access_token.options[:grant_type] = :authorization_code
75
+ access_token.get('/api/v1/userinfo').parsed
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ OmniAuth.config.add_camelization 'boletosimples', 'BoletoSimples'
@@ -0,0 +1 @@
1
+ require 'omniauth/boletosimples'
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'omniauth/boletosimples/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'omniauth-boletosimples'
7
+ s.version = OmniAuth::BoletoSimples::VERSION
8
+ s.authors = ['Rafael Lima']
9
+ s.email = ['contato@rafael.adm.br']
10
+ s.summary = 'BoletoSimples strategy for OmniAuth'
11
+ s.homepage = 'https://github.com/BielSystems/omniauth-boletosimples'
12
+ s.license = 'MIT'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
17
+ s.require_paths = ['lib']
18
+
19
+ s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.0'
20
+
21
+ s.add_development_dependency 'rspec', '~> 2.14'
22
+ s.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-boletosimples'
3
+
4
+ describe OmniAuth::Strategies::BoletoSimples do
5
+ subject do
6
+ OmniAuth::Strategies::BoletoSimples.new(nil, @options || {})
7
+ end
8
+
9
+ it_should_behave_like 'an oauth2 strategy'
10
+
11
+ describe '#client' do
12
+ it 'has correct BoletoSimples site' do
13
+ subject.setup_phase
14
+ subject.client.site.should eq('https://boletosimples.com.br')
15
+ end
16
+
17
+ it 'has correct BoletoSimples sandbox site' do
18
+ @options = { :environment => :sandbox }
19
+ subject.setup_phase
20
+ subject.client.site.should eq('https://sandbox.boletosimples.com.br')
21
+ end
22
+
23
+ it 'has correct authorize url' do
24
+ subject.setup_phase
25
+ subject.client.options[:authorize_url].should eq('https://boletosimples.com.br/api/v1/oauth2/authorize')
26
+ end
27
+
28
+ it 'has correct sandbox authorize url' do
29
+ @options = { :environment => :sandbox }
30
+ subject.setup_phase
31
+ subject.client.options[:authorize_url].should eq('https://sandbox.boletosimples.com.br/api/v1/oauth2/authorize')
32
+ end
33
+
34
+ it 'has correct token url' do
35
+ subject.client.options[:token_url].should eq('/api/v1/oauth2/token')
36
+ end
37
+ end
38
+
39
+ describe '#callback_path' do
40
+ it "has the correct callback path" do
41
+ subject.callback_path.should eq('/auth/boletosimples/callback')
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ require 'rspec'
3
+ require 'omniauth'
4
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
5
+
6
+ RSpec.configure do |config|
7
+ OmniAuth.config.test_mode = true
8
+ end
@@ -0,0 +1,37 @@
1
+ # NOTE it would be useful if this lived in omniauth-oauth2 eventually
2
+ shared_examples 'an oauth2 strategy' do
3
+ describe '#client' do
4
+ it 'should be initialized with symbolized client_options' do
5
+ @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
6
+ subject.client.options[:authorize_url].should == 'https://example.com'
7
+ end
8
+ end
9
+
10
+ describe '#authorize_params' do
11
+ it 'should include any authorize params passed in the :authorize_params option' do
12
+ @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
13
+ subject.authorize_params['foo'].should eq('bar')
14
+ subject.authorize_params['baz'].should eq('zip')
15
+ end
16
+
17
+ it 'should include top-level options that are marked as :authorize_options' do
18
+ @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
19
+ subject.authorize_params['scope'].should eq('bar')
20
+ subject.authorize_params['foo'].should eq('baz')
21
+ end
22
+ end
23
+
24
+ describe '#token_params' do
25
+ it 'should include any token params passed in the :token_params option' do
26
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
27
+ subject.token_params['foo'].should eq('bar')
28
+ subject.token_params['baz'].should eq('zip')
29
+ end
30
+
31
+ it 'should include top-level options that are marked as :token_options' do
32
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
33
+ subject.token_params['scope'].should eq('bar')
34
+ subject.token_params['foo'].should eq('baz')
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-boletosimples
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rafael Lima
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.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.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - contato@rafael.adm.br
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".ruby-gemset"
64
+ - ".ruby-version"
65
+ - CHANGELOG.md
66
+ - CONTRIBUTING.md
67
+ - Gemfile
68
+ - Gemfile.lock
69
+ - LICENSE
70
+ - README.md
71
+ - Rakefile
72
+ - lib/omniauth-boletosimples.rb
73
+ - lib/omniauth/boletosimples.rb
74
+ - lib/omniauth/boletosimples/version.rb
75
+ - lib/omniauth/strategies/boletosimples.rb
76
+ - omniauth-boletosimples.gemspec
77
+ - spec/omniauth/strategies/boletosimples_spec.rb
78
+ - spec/spec_helper.rb
79
+ - spec/support/shared_examples.rb
80
+ homepage: https://github.com/BielSystems/omniauth-boletosimples
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.2.2
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: BoletoSimples strategy for OmniAuth
104
+ test_files:
105
+ - spec/omniauth/strategies/boletosimples_spec.rb
106
+ - spec/spec_helper.rb
107
+ - spec/support/shared_examples.rb