omniauth-launchpad 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: ffc66ef2a2bad8e4209bdd82da5d5630119e108b
4
+ data.tar.gz: 508eee24e8f3a0f6a8eac9c6a77feb5d70edf072
5
+ SHA512:
6
+ metadata.gz: 6a24c601fb669238dcaafb4f8c4d7219554267caa8d5b21797a56c30e68a941cadac276718b1fae3a5c5f0a54e4873eea401cfcc147be4e506f8a743371f0b81
7
+ data.tar.gz: a64270682397b08cbf43b6d6acecba996b82b9ce09832ab100cb98893376de50e5edbd94a4ef00361ef2440ec943ce8762262f84a0669737491a8ebf50338fab
data/.gitignore ADDED
@@ -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
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'httplog'
4
+ # Specify your gem's dependencies in omniauth-launchpad.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 João Pereira
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,31 @@
1
+ # Omniauth::Launchpad
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth-launchpad'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-launchpad
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/omniauth-launchpad/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/example/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+ gem 'sinatra'
3
+ gem 'omniauth-launchpad', :path => '../../'
4
+ gem 'omniauth'
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ omniauth-launchpad (0.0.1)
5
+ multi_json (~> 1.3)
6
+ omniauth (>= 1.1.1)
7
+ omniauth-oauth (>= 1.0.1)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ hashie (3.4.1)
13
+ multi_json (1.11.0)
14
+ oauth (0.4.7)
15
+ omniauth (1.2.2)
16
+ hashie (>= 1.2, < 4)
17
+ rack (~> 1.0)
18
+ omniauth-oauth (1.0.1)
19
+ oauth
20
+ omniauth (~> 1.0)
21
+ rack (1.6.0)
22
+ rack-protection (1.5.3)
23
+ rack
24
+ sinatra (1.4.6)
25
+ rack (~> 1.4)
26
+ rack-protection (~> 1.4)
27
+ tilt (>= 1.3, < 3)
28
+ tilt (2.0.1)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ omniauth
35
+ omniauth-launchpad!
36
+ sinatra
data/example/config.ru ADDED
@@ -0,0 +1,43 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra/base'
3
+ require 'omniauth'
4
+ require 'launchpad'
5
+
6
+
7
+
8
+ class App < Sinatra::Base
9
+
10
+ get '/' do
11
+ redirect '/auth/launchpad'
12
+ end
13
+ # Support both GET and POST for callbacks
14
+ %w(get post).each do |method|
15
+ send(method, "/auth/:provider/callback") do
16
+ # Everything you care about is in env['omniauth.auth']
17
+ # You'll probably want to keep track of your credential hash somewhere.
18
+ # Loading it into a client object should be easy:
19
+ # client.authorization.update_token!(credential_hash)
20
+ content_type 'application/json'
21
+ MultiJson.encode(request.env)
22
+ end
23
+ end
24
+ get '/auth/failure' do
25
+ content_type 'application/json'
26
+ MultiJson.encode(request.env)
27
+ end
28
+ end
29
+
30
+ use Rack::Session::Cookie
31
+
32
+ use OmniAuth::Builder do
33
+ provider :launchpad,
34
+ ENV['CLIENT_ID'],
35
+ ENV['CLIENT_SECRET'],
36
+ :scope => [
37
+ 'https://www.googleapis.com/auth/userinfo.profile',
38
+ 'https://www.googleapis.com/auth/plus.me'
39
+ ],
40
+ :skip_info => false
41
+ end
42
+
43
+ run App.new
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+ gem 'sinatra'
3
+ gem 'omniauth'
4
+ gem 'omniauth-launchpad', :path => '../../'
5
+ gem 'pry'
6
+ gem 'httplog'
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: ../../
3
+ specs:
4
+ omniauth-launchpad (0.0.1)
5
+ faraday
6
+ faraday_middleware
7
+ multi_json (~> 1.3)
8
+ omniauth (>= 1.1.1)
9
+ omniauth-oauth
10
+ simple_oauth
11
+
12
+ GEM
13
+ remote: http://rubygems.org/
14
+ specs:
15
+ coderay (1.1.0)
16
+ faraday (0.9.1)
17
+ multipart-post (>= 1.2, < 3)
18
+ faraday_middleware (0.9.1)
19
+ faraday (>= 0.7.4, < 0.10)
20
+ hashie (3.4.1)
21
+ httplog (0.2.7)
22
+ method_source (0.8.2)
23
+ multi_json (1.11.0)
24
+ multipart-post (2.0.0)
25
+ oauth (0.4.7)
26
+ omniauth (1.2.2)
27
+ hashie (>= 1.2, < 4)
28
+ rack (~> 1.0)
29
+ omniauth-oauth (1.0.1)
30
+ oauth
31
+ omniauth (~> 1.0)
32
+ pry (0.10.1)
33
+ coderay (~> 1.1.0)
34
+ method_source (~> 0.8.1)
35
+ slop (~> 3.4)
36
+ rack (1.6.0)
37
+ rack-protection (1.5.3)
38
+ rack
39
+ simple_oauth (0.3.1)
40
+ sinatra (1.4.6)
41
+ rack (~> 1.4)
42
+ rack-protection (~> 1.4)
43
+ tilt (>= 1.3, < 3)
44
+ slop (3.6.0)
45
+ tilt (2.0.1)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ httplog
52
+ omniauth
53
+ omniauth-launchpad!
54
+ pry
55
+ sinatra
@@ -0,0 +1,8 @@
1
+ // Create a custom Cloud9 runner - similar to the Sublime build system
2
+ // For more information see https://docs.c9.io/custom_runners.html
3
+ {
4
+ "cmd" : ["rackup"],
5
+ "info" : "Started $project_path$file_name",
6
+ "env" : {},
7
+ "selector" : "source.ext"
8
+ }
@@ -0,0 +1,26 @@
1
+ $:.push File.dirname(__FILE__) + '/../lib'
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ Bundler.setup :default, :development, :example, ENV['RACK_ENV']
6
+
7
+ require 'sinatra'
8
+ require 'omniauth-launchpad'
9
+ require 'pry'
10
+ require 'httplog'
11
+ HttpLog.options[:log_headers] = true
12
+
13
+ use Rack::Session::Cookie
14
+ use OmniAuth::Strategies::Launchpad
15
+
16
+ get '/' do
17
+ "<a href='/auth/launchpad'>Auth with BrowserID</a>"
18
+ end
19
+
20
+ post '/auth/launchpad/callback' do
21
+ content_type 'text/plain'
22
+ request.env['omniauth.auth'].to_hash.inspect
23
+ end
24
+ get '/auth/launchpad/callback' do
25
+
26
+ end
@@ -0,0 +1,2 @@
1
+ require './application'
2
+ run Sinatra::Application
@@ -0,0 +1,2 @@
1
+ require 'omniauth/launchpad/version'
2
+ require 'omniauth/strategies/launchpad'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Launchpad
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,79 @@
1
+ require 'omniauth'
2
+ require 'omniauth-oauth'
3
+ require 'oauth/signature/plaintext'
4
+ require 'omniauth-launchpad'
5
+ #require 'faraday'
6
+
7
+ module OmniAuth
8
+ module Strategies
9
+ class Launchpad < OmniAuth::Strategies::OAuth
10
+ include OmniAuth::Strategy
11
+ option :name, 'launchpad'
12
+ option :fields, [:username, :name, :email]
13
+ option :uid_field, :username
14
+
15
+ option :client_options, {
16
+ :site => "https://launchpad.net",
17
+ :realm => "https://api.launchpad.net/",
18
+ :authorize_path => '/+authorize-token',
19
+ :access_token_path => '/+access-token',
20
+ :request_token_path => '/+request-token',
21
+ :signature_method => 'PLAINTEXT',
22
+ :http_method => :post,
23
+ :scheme =>:body
24
+ }
25
+ def initialize(app, consumer_key="babun", options={}, &block)
26
+ options[:oauth_consumer_key] = consumer_key
27
+ options[:oauth_consumer_secret] = consumer_secret
28
+ super(app, consumer_key, nil, options, &block)
29
+ end
30
+
31
+ def raw_user_info
32
+ puts "before: #{@access_token.inspect}"
33
+ request_options = {:oauth_consumer_key => options[:oauth_consumer_key], :realm => "https://api.launchpad.net/"}
34
+ request_options.merge!(options[:authorize_params])
35
+ @access_token.consumer.options[:scheme] = :header
36
+ info = @access_token.get('https://api.launchpad.net/devel/people/+me', {'Accept' => 'application/json'})
37
+ info = @access_token.get(info["location"], {'Accept' => 'application/json'})
38
+ @raw_user_info ||= MultiJson.load info.body
39
+ end
40
+
41
+ uid { raw_user_info['name'] }
42
+
43
+ info do
44
+ {
45
+ name: raw_user_info['display_name'],
46
+ email: raw_user_info['preferred_email_address_link'].split(/\//)[-1],
47
+ username: raw_user_info['name']
48
+ }
49
+ end
50
+
51
+ extra do
52
+ { raw_user_info: raw_user_info }
53
+ end
54
+ def request_phase
55
+ puts "Request info: #{options.request_param}"
56
+ request_options = {:oauth_consumer_key => options[:oauth_consumer_key], :realm => "https://api.launchpad.net/"}
57
+ request_options.merge!(options[:authorize_params])
58
+
59
+ request_token = consumer.get_request_token({:oauth_callback => callback_url}, request_options)
60
+ session['oauth'] ||= {}
61
+ session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
62
+ r = Rack::Response.new
63
+
64
+ if request_token.callback_confirmed?
65
+ r.redirect(request_token.authorize_url)
66
+ else
67
+ r.redirect(request_token.authorize_url(:oauth_callback => callback_url))
68
+ end
69
+ @request_token = request_token
70
+ r.finish
71
+
72
+ rescue ::Timeout::Error => e
73
+ fail!(:timeout, e)
74
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
75
+ fail!(:service_unavailable, e)
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/launchpad/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-launchpad"
8
+ spec.version = Omniauth::Launchpad::VERSION
9
+ spec.authors = ["João Pereira"]
10
+ spec.email = ["joaopapereira@gmail.com"]
11
+ spec.summary = %q{Launchpad login for OmniAuth}
12
+ spec.description = %q{This gem will allow users to login with the Launchpad account}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency 'rspec'
24
+ spec.add_development_dependency 'webmock'
25
+ spec.add_development_dependency 'rack-test'
26
+ spec.add_development_dependency 'simplecov'
27
+
28
+ spec.add_runtime_dependency 'omniauth', '>= 1.1.1'
29
+ spec.add_runtime_dependency 'omniauth-oauth'
30
+ #spec.add_runtime_dependency 'faraday'
31
+ #spec.add_runtime_dependency 'faraday_middleware'
32
+ #spec.add_runtime_dependency 'simple_oauth'
33
+ spec.add_runtime_dependency 'multi_json', '~> 1.3'
34
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-launchpad
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - João Pereira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.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: '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: webmock
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: rack-test
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: simplecov
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
+ - !ruby/object:Gem::Dependency
98
+ name: omniauth
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 1.1.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 1.1.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: omniauth-oauth
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: multi_json
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.3'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.3'
139
+ description: This gem will allow users to login with the Launchpad account
140
+ email:
141
+ - joaopapereira@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - Gemfile
148
+ - LICENSE.txt
149
+ - README.md
150
+ - Rakefile
151
+ - example/Gemfile
152
+ - example/Gemfile.lock
153
+ - example/config.ru
154
+ - example/simple/Gemfile
155
+ - example/simple/Gemfile.lock
156
+ - example/simple/My Runner.run
157
+ - example/simple/application.rb
158
+ - example/simple/config.ru
159
+ - lib/omniauth-launchpad.rb
160
+ - lib/omniauth/launchpad/version.rb
161
+ - lib/omniauth/strategies/launchpad.rb
162
+ - omniauth-launchpad.gemspec
163
+ homepage: ''
164
+ licenses:
165
+ - MIT
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.4.2
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: Launchpad login for OmniAuth
187
+ test_files: []