omniauth-memberful 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f7117c671b7163722a29772743c35d6912f46f47
4
+ data.tar.gz: 8b1aa8d8008e9dd6513a803b3e95c9c418bdf570
5
+ SHA512:
6
+ metadata.gz: 22dddad6b1d2605074dcfe5cc2e70ec719959cfee24657d71151f0478c906cf2f622016c99834747e5648ee91ec61d2aa3e4a5033946fbedcf4fce4722dcd2ec
7
+ data.tar.gz: 66c2bd3a39893fd1625651e2d9356a317812148acb0501e5095bf2a2184151c0205587aa62b2a752ad9572085e4f9222bf71acd60e2dd5064045c708ec200c26
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1,79 @@
1
+ AllCops:
2
+ Include:
3
+ - '**/Gemfile'
4
+ - '**/Rakefile'
5
+
6
+ Metrics/LineLength:
7
+ Max: 120
8
+
9
+ Metrics/ClassLength:
10
+ Max: 300
11
+
12
+ Metrics/MethodLength:
13
+ Max: 25
14
+
15
+ Metrics/ParameterLists:
16
+ Max: 8
17
+
18
+ Metrics/AbcSize:
19
+ Enabled: false
20
+
21
+ Metrics/CyclomaticComplexity:
22
+ Enabled: true
23
+
24
+ Metrics/PerceivedComplexity:
25
+ Enabled: false
26
+
27
+ Style/AlignParameters:
28
+ EnforcedStyle: with_fixed_indentation
29
+
30
+ Style/StringLiterals:
31
+ EnforcedStyle: single_quotes
32
+
33
+ Style/StringLiteralsInInterpolation:
34
+ EnforcedStyle: single_quotes
35
+
36
+ Style/AndOr:
37
+ Enabled: false
38
+
39
+ Style/Not:
40
+ Enabled: false
41
+
42
+ Style/FileName:
43
+ Enabled: false
44
+
45
+ Style/SingleSpaceBeforeFirstArg:
46
+ Enabled: false
47
+
48
+ Documentation:
49
+ Enabled: false
50
+
51
+ Style/CaseIndentation:
52
+ IndentWhenRelativeTo: case
53
+ SupportedStyles:
54
+ - case
55
+ - end
56
+ IndentOneStep: false
57
+
58
+ Style/PercentLiteralDelimiters:
59
+ PreferredDelimiters:
60
+ '%w': '[]'
61
+ '%W': '[]'
62
+
63
+ Style/AccessModifierIndentation:
64
+ EnforcedStyle: indent
65
+
66
+ Style/SignalException:
67
+ Enabled: false
68
+
69
+ Style/IndentationWidth:
70
+ Enabled: false
71
+
72
+ Lint/EndAlignment:
73
+ AlignWith: variable
74
+
75
+ Lint/DefEndAlignment:
76
+ Enabled: false
77
+
78
+ Lint/HandleExceptions:
79
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Ross Kaffenberger
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.
@@ -0,0 +1,63 @@
1
+ # OmniAuth::Memberful
2
+
3
+ OmniAuth strategy to authenticate users over the Memberful API in Rails (or Rack)
4
+ applications.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'omniauth-memberful'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install omniauth-memberful
21
+
22
+ ## Usage
23
+
24
+ As with other OmniAuth strategies, you'll need to setup the OmniAuth middleware and
25
+ a callback to receive the OmniAuth credentials once a user has been authenticated.
26
+
27
+ You can enable `Omniauth::Memberful` by using the `OmniAuth::Builder` to insert the strategy middleware
28
+ with your Memberful credentials. Visit your Memberful Settings page to generate
29
+ a "Custom App" with a name and endpoint in your application for the OAuth callback. You'll get use
30
+ the generated identifier and secret key in your OmniAuth setup with
31
+
32
+ In Rails:
33
+
34
+ ```yaml
35
+ # config/secrets.yml
36
+ development:
37
+ memberful_app_identifier: aaaaaaaaa
38
+ memberful_app_secret: bbbbbbbbbbbbbbbbbbb
39
+ memberful_site: https://yoursite.memberful.com
40
+ ```
41
+
42
+ ```ruby
43
+ # config/initializers/omniauth.rb
44
+ require "omniauth-memberful"
45
+
46
+ secrets = Rails.application.secrets
47
+ Rails.application.config.middleware.use OmniAuth::Builder do
48
+ provider OmniAuth::Strategies::Memberful,
49
+ secrets.memberful_app_identifier,
50
+ secrets.memberful_app_secret,
51
+ client_options: { site: secrets.memberful_site }
52
+ end
53
+ ```
54
+
55
+ Check out the example app at [rossta/memberful-rails-example](github.com/rossta/memberful-rails-example) for more info.
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it ( https://github.com/[my-github-username]/omniauth-memberful/fork )
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ RuboCop::RakeTask.new
8
+
9
+ task default: [:spec, :rubocop]
@@ -0,0 +1,2 @@
1
+ require 'omniauth-memberful/version'
2
+ require 'omniauth/strategies/memberful'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Memberful
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,56 @@
1
+ require 'omniauth'
2
+ require 'omniauth-oauth2'
3
+
4
+ # For more info, see https://github.com/intridea/omniauth
5
+ module OmniAuth
6
+ module Strategies
7
+ class Memberful < OmniAuth::Strategies::OAuth2
8
+ option :name, 'memberful'
9
+
10
+ option :client_options,
11
+ site: ENV.fetch('MEMBERFUL_SITE') { 'https://yoursite.memberful.com' },
12
+ authorize_url: '/oauth',
13
+ token_url: '/oauth/token'
14
+
15
+ option :authorize_options, [:scope]
16
+
17
+ uid { member_info['id'] }
18
+
19
+ info do
20
+ prune!(
21
+ 'nickname' => member_info['username'],
22
+ 'name' => member_info['full_name'],
23
+ 'email' => member_info['email'],
24
+ 'first_name' => member_info['first_name'],
25
+ 'last_name' => member_info['last_name']
26
+ )
27
+ end
28
+
29
+ extra do
30
+ prune!('raw_info' => raw_info)
31
+ end
32
+
33
+ protected
34
+
35
+ def raw_info
36
+ @raw_info ||= retrieve_account_info
37
+ end
38
+
39
+ def member_info
40
+ raw_info['member']
41
+ end
42
+
43
+ def retrieve_account_info
44
+ access_token.options[:mode] = :query
45
+ access_token.get('/account.json').parsed
46
+ end
47
+
48
+ def prune!(hash)
49
+ hash.delete_if do |_, value|
50
+ prune!(value) if value.is_a?(Hash)
51
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-memberful/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'omniauth-memberful'
8
+ spec.version = Omniauth::Memberful::VERSION
9
+ spec.authors = ['Ross Kaffenberger']
10
+ spec.email = ['rosskaff@gmail.com']
11
+ spec.summary = %q{OmniAuth strategy for Memberful}
12
+ spec.description = %q{OmniAuth strategy for Memberful}
13
+ spec.homepage = 'https://github.com/rossta/memberful'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = []
18
+ spec.test_files = spec.files.grep(%r{^(spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'omniauth-oauth2'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.7'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec', '~> 3.0'
26
+ spec.add_development_dependency 'rubocop'
27
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Memberful do
4
+ let(:request) { double('Request', params: {}, cookies: {}, env: {}) }
5
+
6
+ subject do
7
+ args = ['appid', 'secret', @options].compact
8
+ OmniAuth::Strategies::Memberful.new(*args).tap do |strategy|
9
+ allow(strategy).to receive(:request) {
10
+ request
11
+ }
12
+ end
13
+ end
14
+
15
+ describe 'client options' do
16
+ it 'should have correct name' do
17
+ expect(subject.options.name).to eq('memberful')
18
+ end
19
+
20
+ it 'should have correct authorize url' do
21
+ expect(subject.options.client_options.authorize_url).to eq('/oauth')
22
+ end
23
+
24
+ it 'should have correct token url' do
25
+ expect(subject.options.client_options.token_url).to eq('/oauth/token')
26
+ end
27
+
28
+ context 'site' do
29
+ it 'is inserts example by default' do
30
+ expect(subject.options.client_options.site).to eq 'https://yoursite.memberful.com'
31
+ end
32
+
33
+ it 'accepts option' do
34
+ @options = { client_options: { site: 'https://mysite.memberful.com' } }
35
+ expect(subject.options.client_options.site).to eq 'https://mysite.memberful.com'
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,2 @@
1
+ require 'rspec'
2
+ require 'omniauth-memberful'
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-memberful
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ross Kaffenberger
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-07 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: '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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
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
+ description: OmniAuth strategy for Memberful
84
+ email:
85
+ - rosskaff@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rubocop.yml"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - lib/omniauth-memberful.rb
97
+ - lib/omniauth-memberful/version.rb
98
+ - lib/omniauth/strategies/memberful.rb
99
+ - omniauth-memberful.gemspec
100
+ - spec/omniauth/strategies/memberful_spec.rb
101
+ - spec/spec_helper.rb
102
+ homepage: https://github.com/rossta/memberful
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.2.2
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: OmniAuth strategy for Memberful
126
+ test_files:
127
+ - spec/omniauth/strategies/memberful_spec.rb
128
+ - spec/spec_helper.rb
129
+ has_rdoc: