omniauth-bandify-oauth2 0.1.0

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
+ SHA256:
3
+ metadata.gz: 4c2e91daf468afaf5e16f3c1797738cf2e3ffe591b2f9078719581f8f1b261c8
4
+ data.tar.gz: 04c8374100534071b9cf5f64b97fa969b0d52ac0dce9ddfe0f695e9deb3b5195
5
+ SHA512:
6
+ metadata.gz: e4cde4ea1f8e49695f9decc138bd649eb30e949ab47ef396131b9248fcae4b29f070e57b53fba9d8cf3ffff718896069b6d0841a9049e456f5ae840965ae0747
7
+ data.tar.gz: c5210ade58468654ce578a1ecf0931b03a1a96322523706f48bd1983989bc531f912767aa9d778270bd0ea5cb460fcad137994839de7d8631d05909cb3cf6476
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .ruby-gemset
7
+ .ruby-version
8
+ .rvmrc
9
+ Gemfile.lock
10
+ InstalledFiles
11
+ _yardoc
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
21
+ .powenv
22
+ .idea/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+ # Specify your gem's dependencies in omniauth-twitter.gemspec
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # OmniAuth Bandify
2
+
3
+ This gem contains the Bandify strategy for OmniAuth.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-bandify-oauth2', :git => 'https://github.com/Bandify/omniauth-bandify-oauth2.git'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```sh
16
+ $ bundle
17
+ ```
18
+
19
+
20
+ ## Usage
21
+
22
+ ### Rails
23
+
24
+ If you're using Rails, you need to add the strategy to your `Gemfile`:
25
+
26
+ ```ruby
27
+ gem 'omniauth-bandify-oauth2'
28
+ ```
29
+
30
+ Once you've added the gem to your project, you need to add the following to your `config/initializers/omniauth.rb`:
31
+
32
+ ```ruby
33
+ Rails.application.config.middleware.use OmniAuth::Builder do
34
+ provider :bandify_oauth2, "client_id", "client_secret"
35
+ end
36
+ ```
37
+
38
+ Enter your `client_id` and `client_secret`, which you receive when you register your application with Bandify.
39
+
40
+ Now just follow the README at: https://github.com/intridea/omniauth
41
+
42
+ ### Sinatra
43
+
44
+ ```ruby
45
+ require 'omniauth'
46
+ require 'omniauth-bandify-oauth2'
47
+
48
+ use Rack::Session::Cookie
49
+ use OmniAuth::Builder do
50
+ provider :bandify_oauth2, "client_id", "client_secret"
51
+ end
52
+
53
+ get '/auth/:provider/callback' do
54
+ # Do something with auth_hash
55
+ redirect to('/')
56
+ end
57
+
58
+ def auth_hash
59
+ request.env['omniauth.auth']
60
+ end
61
+ ```
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require File.join('bundler', 'gem_tasks')
3
+ require File.join('rspec', 'core', 'rake_task')
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module BandifyOauth2
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require File.join('omniauth', 'strategies', 'bandify_oauth2')
@@ -0,0 +1,34 @@
1
+ require 'multi_json'
2
+ require 'omniauth/strategies/oauth2'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class BandifyOauth2 < OmniAuth::Strategies::OAuth2
7
+ option :name, 'bandify_oauth2'
8
+
9
+ option :client_options, {
10
+ site: ENV['BANDIFY_OAUTH2_SITE'] || 'https://login.bandify.co',
11
+ request_token_url: '/oauth/request_token',
12
+ authorize_url: '/oauth/authorize',
13
+ token_url: '/oauth/token',
14
+ }
15
+
16
+ uid { raw_info['uid'] }
17
+
18
+ info do
19
+ {
20
+ email: raw_info['email'],
21
+ roles: raw_info['roles'],
22
+ }
23
+ end
24
+
25
+ def raw_info
26
+ @raw_info ||= MultiJson.decode(access_token.get('/api/v1/me').body)
27
+ end
28
+
29
+ def callback_url
30
+ full_host + script_name + callback_path
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1 @@
1
+ require File.join('omniauth', 'bandify_oauth2')
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path(File.join('..', 'lib', 'omniauth', 'bandify_oauth2', 'version'), __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "omniauth-bandify-oauth2"
6
+ s.version = OmniAuth::BandifyOauth2::VERSION
7
+ s.authors = ['Bandify']
8
+ s.email = ['hello@bandify.co']
9
+ s.homepage = "https://github.com/Bandify/omniauth-bandify-oauth2"
10
+ s.summary = %q{OmniAuth strategy for Bandify.}
11
+ s.description = %q{OmniAuth strategy for Bandify.}
12
+
13
+ s.rubyforge_project = "omniauth-bandify-oauth2"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency 'multi_json'
20
+ s.add_runtime_dependency 'omniauth-oauth2'
21
+ s.add_development_dependency 'rspec', '~> 3.7'
22
+ s.add_development_dependency 'rack-test'
23
+ s.add_development_dependency 'simplecov'
24
+ s.add_development_dependency 'webmock'
25
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::BandifyOauth2 do
4
+ subject do
5
+ OmniAuth::Strategies::BandifyOauth2.new({})
6
+ end
7
+
8
+ context "client options" do
9
+ it 'should have correct name' do
10
+ expect(subject.options.name).to eq('bandify_oauth2')
11
+ end
12
+
13
+ it 'should have correct site' do
14
+ expect(subject.options.client_options.site).to eq('https://login.bandify.co')
15
+ end
16
+
17
+ it 'should have correct authorize url' do
18
+ expect(subject.options.client_options.authorize_url).to eq('/oauth/authorize')
19
+ end
20
+ end
21
+ 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-bandify-oauth2'
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,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-bandify-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bandify
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-07-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: multi_json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '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: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '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: '3.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rack-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: OmniAuth strategy for Bandify.
98
+ email:
99
+ - hello@bandify.co
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - README.md
107
+ - Rakefile
108
+ - lib/omniauth-bandify-oauth2.rb
109
+ - lib/omniauth/bandify_oauth2.rb
110
+ - lib/omniauth/bandify_oauth2/version.rb
111
+ - lib/omniauth/strategies/bandify_oauth2.rb
112
+ - omniauth-bandify-oauth2.gemspec
113
+ - spec/omniauth/strategies/bandify_oauth2_spec.rb
114
+ - spec/spec_helper.rb
115
+ homepage: https://github.com/Bandify/omniauth-bandify-oauth2
116
+ licenses: []
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubygems_version: 3.0.3
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: OmniAuth strategy for Bandify.
137
+ test_files:
138
+ - spec/omniauth/strategies/bandify_oauth2_spec.rb
139
+ - spec/spec_helper.rb