omniauth-parse 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +17 -0
- data/Guardfile +42 -0
- data/LICENSE +22 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/lib/omniauth/strategies/parse.rb +62 -0
- data/lib/omniauth-parse/version.rb +5 -0
- data/lib/omniauth-parse.rb +2 -0
- data/omniauth-parse.gemspec +26 -0
- data/spec/omniauth/strategies/parse.rb +20 -0
- data/spec/spec_helper.rb +12 -0
- metadata +139 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in omniauth-parse-com.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'faraday'
|
7
|
+
group :development, :test do
|
8
|
+
gem 'guard'
|
9
|
+
gem 'guard-rspec'
|
10
|
+
gem 'guard-bundler'
|
11
|
+
gem 'growl'
|
12
|
+
gem 'rb-fsevent'
|
13
|
+
gem 'rspec'
|
14
|
+
gem 'omniauth'
|
15
|
+
gem 'debugger'
|
16
|
+
gem 'rake'
|
17
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'bundler' do
|
5
|
+
watch('Gemfile')
|
6
|
+
# Uncomment next line if Gemfile contain `gemspec' command
|
7
|
+
# watch(/^.+\.gemspec/)
|
8
|
+
end
|
9
|
+
|
10
|
+
guard 'rspec', :version => 2 do
|
11
|
+
watch(%r{^spec/.+_spec\.rb$})
|
12
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
13
|
+
watch('spec/spec_helper.rb') { "spec" }
|
14
|
+
|
15
|
+
# Rails example
|
16
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
17
|
+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
18
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
19
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
20
|
+
watch('config/routes.rb') { "spec/routing" }
|
21
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
22
|
+
|
23
|
+
# Capybara request specs
|
24
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
25
|
+
|
26
|
+
# Turnip features and steps
|
27
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
28
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
guard :test do
|
33
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
34
|
+
watch(%r{^test/.+_test\.rb$})
|
35
|
+
watch('test/test_helper.rb') { "test" }
|
36
|
+
|
37
|
+
# Rails example
|
38
|
+
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
39
|
+
watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
40
|
+
watch(%r{^app/views/.+\.rb$}) { "test/integration" }
|
41
|
+
watch('app/controllers/application_controller.rb') { ["test/functional", "test/integration"] }
|
42
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Micah Gates
|
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,34 @@
|
|
1
|
+
# Omniauth::Parse::Com
|
2
|
+
|
3
|
+
This gem is an OmniAuth strategy for parse.com.
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'omniauth-parse'
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ bundle
|
13
|
+
|
14
|
+
Or install it yourself as:
|
15
|
+
|
16
|
+
$ gem install omniauth-parse-com
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
use OmniAuth::Builder do
|
21
|
+
provider :parse, {:application_id => "application_id", :rest_api_key => "rest_api_key"}
|
22
|
+
end
|
23
|
+
|
24
|
+
Whatever fields are in the user object will get put into the info hash.
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
32
|
+
|
33
|
+
## TODO
|
34
|
+
tests tests tests
|
data/Rakefile
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'omniauth'
|
2
|
+
require 'faraday'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Parse
|
7
|
+
include OmniAuth::Strategy
|
8
|
+
|
9
|
+
PARSE_LOGIN = {:site => "https://api.parse.com", :path => "1/login"}
|
10
|
+
|
11
|
+
option :fields, [:username, :password]
|
12
|
+
option :uid_field, :username
|
13
|
+
|
14
|
+
def initialize(app, options = {})
|
15
|
+
@application_id = options[:application_id] or raise "application_id is required for initialization"
|
16
|
+
@rest_api_key = options[:rest_api_key] or raise "rest_api_key is required for initialization"
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def request_phase
|
21
|
+
form = OmniAuth::Form.new(:title => "Parse.com Info", :url => callback_path)
|
22
|
+
form.text_field :username, :username
|
23
|
+
form.password_field :password, :password
|
24
|
+
form.button "Sign In"
|
25
|
+
form.to_response
|
26
|
+
end
|
27
|
+
|
28
|
+
def callback_phase
|
29
|
+
@raw_data = get_user_data
|
30
|
+
return fail!(:invalid_credentials) unless @raw_data
|
31
|
+
@parsed_data = JSON.parse @raw_data
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
uid { @parsed_data.delete "objectId" }
|
36
|
+
|
37
|
+
info do
|
38
|
+
@parsed_data
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_user_data
|
42
|
+
conn = Faraday.new(:url => PARSE_LOGIN[:site]) do |req|
|
43
|
+
req.request :url_encoded
|
44
|
+
req.adapter Faraday.default_adapter
|
45
|
+
end
|
46
|
+
|
47
|
+
result = conn.get do |req|
|
48
|
+
req.url PARSE_LOGIN[:path]
|
49
|
+
req.headers['X-Parse-Application-Id'] = @application_id
|
50
|
+
req.headers['X-Parse-REST-API-Key'] = @rest_api_key
|
51
|
+
req.params['username'] = request.params["username"]
|
52
|
+
req.params['password'] = request.params["password"]
|
53
|
+
end
|
54
|
+
unless result.status == 200
|
55
|
+
#logging?
|
56
|
+
return false
|
57
|
+
end
|
58
|
+
return result.body
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-parse/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["Micah Gates"]
|
7
|
+
gem.email = ["github@mgates.com"]
|
8
|
+
gem.description = %q{An Omniauth Strategy for Parse.com}
|
9
|
+
gem.summary = %q{An Omniauth Strategy for Parse.com}
|
10
|
+
gem.homepage = "https://github.com/mgates/omniauth-parse"
|
11
|
+
gem.name = "omniauth-parse"
|
12
|
+
gem.version = OmniAuth::Parse::VERSION
|
13
|
+
gem.summary = %q{OmniAuth strategy for Parse}
|
14
|
+
gem.description = %q{OmniAuth strategy for Parse}
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency 'multi_json'
|
21
|
+
gem.add_dependency 'faraday'
|
22
|
+
gem.add_development_dependency 'rspec'
|
23
|
+
gem.add_development_dependency 'rack-test'
|
24
|
+
gem.add_development_dependency 'webmock'
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Parse, :type=> :strategy do
|
4
|
+
include OmniAuth::Test::StrategyTestCase
|
5
|
+
def strategy
|
6
|
+
@crowd_server_url ||= 'https://api.parse.com'
|
7
|
+
@application_name ||= 'bogus_app'
|
8
|
+
@application_password ||= 'bogus_app_password'
|
9
|
+
[OmniAuth::Strategies::Parse, {:crowd_server_url => @crowd_server_url, :application_name=>@application_name, :application_password=>@application_password}]
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "somthing" do
|
13
|
+
it "should be" do
|
14
|
+
True.should be == True
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-parse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Micah Gates
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: multi_json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: faraday
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rack-test
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: webmock
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: OmniAuth strategy for Parse
|
95
|
+
email:
|
96
|
+
- github@mgates.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- Gemfile
|
103
|
+
- Guardfile
|
104
|
+
- LICENSE
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- lib/omniauth-parse.rb
|
108
|
+
- lib/omniauth-parse/version.rb
|
109
|
+
- lib/omniauth/strategies/parse.rb
|
110
|
+
- omniauth-parse.gemspec
|
111
|
+
- spec/omniauth/strategies/parse.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
homepage: https://github.com/mgates/omniauth-parse
|
114
|
+
licenses: []
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 1.8.24
|
134
|
+
signing_key:
|
135
|
+
specification_version: 3
|
136
|
+
summary: OmniAuth strategy for Parse
|
137
|
+
test_files:
|
138
|
+
- spec/omniauth/strategies/parse.rb
|
139
|
+
- spec/spec_helper.rb
|