omniauth-startuphubs 0.0.1

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: 58d410b5bf739809b9a1eadb4578339fd1729de0
4
+ data.tar.gz: e542b2953fdf14b366d9e8aff922747583787f65
5
+ SHA512:
6
+ metadata.gz: 3bbb424caa03748c3fc76036ef7fb29c9cd0a748290752012623cbee8241c8c91ef033f88fe72e5120b3d966c51fd6dd2329be2a083d56a60ae18ce7bda2bf9a
7
+ data.tar.gz: 0216fee30bb903539b00d4179a4d6d87ede30766bb9b7d8028f28200911e2ed13c434f83751830d5ff109dd9573ae75367b32619ecca82c0a26056c4510fdfd7
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 ..gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # OmniAuth Startuphubs
2
+
3
+ This gem contains the Startuphubs strategy for OmniAuth.
4
+
5
+ Startuphubs uses the OAuth2 flow, you can read about it here: http://api.startuphubs/api/oauth
6
+
7
+ ## How To Use It
8
+
9
+ So let's say you're using Rails, you need to add the strategy to your `Gemfile`:
10
+
11
+ gem 'omniauth-startuphubs'
12
+
13
+ You can pull them in directly from github e.g.:
14
+
15
+ gem 'omniauth-startuphubs', :git => 'https://github.com/ravensnowbird/omniauth-startuphubs.git'
16
+
17
+ Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
18
+
19
+ Rails.application.config.middleware.use OmniAuth::Builder do
20
+ provider :startuphubs, "consumer_key", "consumer_secret"
21
+ end
22
+
23
+ You will obviously have to put in your key and secret, which you get when you register your app with Startuphubs (they call them API Key and Secret Key).
24
+
25
+ Now just follow the README at: https://github.com/intridea/omniauth
26
+
27
+ ## License
28
+
29
+ Copyright (c) 2014 by Vivek Sampara
30
+
31
+ 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:
32
+
33
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
34
+
35
+ 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,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
@@ -0,0 +1,2 @@
1
+ require "omniauth-startuphubs/version"
2
+ require "omniauth/strategies/startuphubs"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Startuphubs
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,91 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Startuphubs < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPE = 'email'
7
+
8
+ option :client_options, {
9
+ :site => 'https://startuphubs.com/',
10
+ :authorize_url => 'https://startuphubs.com/api/oauth/authorize',
11
+ :token_url => 'https://startuphubs.com/api/oauth/token'
12
+ }
13
+
14
+ option :access_token_options, {
15
+ :mode => :query,
16
+ :header_format => 'OAuth %s'
17
+ }
18
+
19
+ option :provider_ignores_state, true
20
+
21
+ def request_phase
22
+ super
23
+ end
24
+
25
+ uid { raw_info['id'] }
26
+
27
+ info do
28
+ prune!({
29
+ "name" => raw_info["name"],
30
+ "email" => raw_info["email"],
31
+ "bio" => raw_info["bio"],
32
+ "blog_url" => raw_info["blog_url"],
33
+ "online_bio_url" => raw_info["online_bio_url"],
34
+ "twitter_url" => raw_info["twitter_url"],
35
+ "facebook_url" => raw_info["facebook_url"],
36
+ "linkedin_url" => raw_info["linkedin_url"],
37
+ "follower_count" => raw_info["follower_count"],
38
+ "investor" => raw_info["investor"],
39
+ "locations" => raw_info["locations"],
40
+ "roles" => raw_info["roles"],
41
+ "angellist_url" => raw_info["angellist_url"],
42
+ "image" => raw_info["image"],
43
+ "skills" => raw_info["skills"]
44
+ })
45
+ end
46
+
47
+ credentials do
48
+ hash = {'token' => access_token.token}
49
+ hash.merge!('refresh_token' => access_token.refresh_token) if access_token.expires? && access_token.refresh_token
50
+ hash.merge!('expires_at' => access_token.expires_at) if access_token.expires?
51
+ hash.merge!('expires' => access_token.expires?)
52
+ hash.merge!('scope' => raw_info["scopes"] ? raw_info["scopes"].join(" ") : nil)
53
+ prune!(hash)
54
+ end
55
+
56
+ def raw_info
57
+ unless skip_info?
58
+ @raw_info ||= access_token.get('/api/v1/me.json').parsed
59
+ else
60
+ {}
61
+ end
62
+ end
63
+
64
+ def authorize_params
65
+ super.tap do |params|
66
+ params.merge! request.params
67
+ %w[scope state].each do |v|
68
+ if request.params[v]
69
+ params[v.to_sym] = request.params[v]
70
+
71
+ # to support omniauth-oauth2's auto csrf protection
72
+ session['omniauth.state'] = params[:state] if v == 'state'
73
+ end
74
+ end
75
+
76
+ params[:scope] ||= DEFAULT_SCOPE
77
+ end
78
+ end
79
+
80
+ private
81
+ def prune!(hash)
82
+ hash.delete_if do |_, value|
83
+ prune!(value) if value.is_a?(Hash)
84
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ OmniAuth.config.add_camelization 'startuphubs', 'Startuphubs'
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-startuphubs/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-startuphubs"
7
+ s.version = Omniauth::Startuphubs::VERSION
8
+ s.authors = ["Vivek Sampara"]
9
+ s.email = ["ravensnowbird@gmail.com"]
10
+ s.homepage = "https://github.com/ravensnowbird/omniauth-startuphubs"
11
+ s.summary = %q{Startuphubs OAuth strategy for OmniAuth}
12
+ s.description = %q{Startuphubs OAuth strategy for OmniAuth}
13
+ s.license = "MIT"
14
+
15
+ s.rubyforge_project = "omniauth-startuphubs"
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_runtime_dependency 'omniauth-oauth2', '~> 1.1'
23
+ s.add_development_dependency 'rspec', '~> 2.7'
24
+ s.add_development_dependency 'rack-test'
25
+ s.add_development_dependency 'simplecov'
26
+ s.add_development_dependency 'webmock'
27
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ require 'bundler/setup'
2
+ require 'rspec'
3
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
4
+
5
+ RSpec.configure do |config|
6
+ end
@@ -0,0 +1,23 @@
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 '#token_params' do
11
+ it 'should include any authorize params passed in the :authorize_params option' do
12
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
13
+ subject.token_params['foo'].should eq('bar')
14
+ subject.token_params['baz'].should eq('zip')
15
+ end
16
+
17
+ it 'should include top-level options that are marked as :authorize_options' do
18
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
19
+ subject.token_params['scope'].should eq('bar')
20
+ subject.token_params['foo'].should eq('baz')
21
+ end
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-startuphubs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vivek Sampara
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-11 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'
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'
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.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
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
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
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: webmock
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: Startuphubs OAuth strategy for OmniAuth
84
+ email:
85
+ - ravensnowbird@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - README.md
93
+ - Rakefile
94
+ - lib/omniauth-startuphubs.rb
95
+ - lib/omniauth-startuphubs/version.rb
96
+ - lib/omniauth/strategies/startuphubs.rb
97
+ - omniauth-startuphubs.gemspec
98
+ - spec/omniauth/strategies/startuphubs.com
99
+ - spec/spec_helper.rb
100
+ - spec/support/shared_examples.rb
101
+ homepage: https://github.com/ravensnowbird/omniauth-startuphubs
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project: omniauth-startuphubs
121
+ rubygems_version: 2.2.2
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Startuphubs OAuth strategy for OmniAuth
125
+ test_files: []