oauth_bundle 1.0.2

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: c8579e9674631bb8ff6568bbedc7f7a48adb5cec
4
+ data.tar.gz: 4040b79f12c361e827a03e0a8b577b6253e27e0a
5
+ SHA512:
6
+ metadata.gz: d6556fdfa40208d10cdae2863adc3cfafbdccc0b8c7b0ec7fe509eefc5221e75e589d19c03b5f25ed2c5605b42fb67ffcfd83993c63297606500e20db965db73
7
+ data.tar.gz: 5e6ec59eb9973e8e520b53e6a6369ab203ac0e7c0ffb28f2f946afc977d9f5e83c4dd4dd1d91d1b3d32c707feb288db5019c5eaae1cba8df649da2c629095396
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in oauth_bundle.gemspec
4
+
5
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 James Yang
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,84 @@
1
+ # OauthBundle
2
+
3
+ OauthBundle bundles __devise__ and Omniauth __twitter__, __facebook__, and __github__ strategies. It migrate required columns for your authentication model. Omniauth callbacks controller file is created and defined realted methods. This gem makes your life easier to build the omniauth services with devise gem.
4
+
5
+ ###To-Do List:
6
+
7
+ Support seperating authentication model from user model.
8
+
9
+ ## Installation
10
+
11
+ Test in OS X system.
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'devise'
16
+ gem 'omniauth'
17
+ gem 'omniauth-facebook'
18
+ gem 'omniauth-twitter'
19
+ gem 'omniauth-github'
20
+ gem 'oauth_bundle'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install oauth_bundle
29
+
30
+ ## Usage
31
+
32
+ #### Setup
33
+
34
+ `rails g oauth_bundle:install`
35
+
36
+ Update your app id and app secret for each provider:
37
+
38
+ ```ruby
39
+ # config/initializers/devise.rb
40
+ config.omniauth :github, 'APP_ID', 'APP_SECRET'
41
+ config.omniauth :facebook, 'APP_ID', 'APP_SECRET'
42
+ config.omniauth :twitter, 'APP_ID', 'APP_SECRET'
43
+ ```
44
+
45
+ #### Handle Callback Data
46
+
47
+ Each provider correspond to its named method in `app/controllers/#{models}/omniauth_callbacks_controller.rb`.
48
+
49
+ #### Routing Path
50
+
51
+ - `user_omniauth_authorize_path(:provider_name)`
52
+ - `user_omniauth_callback_path(:provider_name)`
53
+
54
+ #### More Information
55
+
56
+ - [http://blog.railsrumble.com/2010/10/08/intridea-omniauth/](http://blog.railsrumble.com/2010/10/08/intridea-omniauth/)
57
+ - [https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview)
58
+ - [https://github.com/mkdynamic/omniauth-facebook](https://github.com/mkdynamic/omniauth-facebook)
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it ( https://github.com/[my-github-username]/oauth_bundle/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create a new Pull Request
67
+
68
+ ## Development Digest
69
+
70
+ 1. Add migration for authentication model.
71
+ 2. Add `provider, uid` columns to authentication model.
72
+ 3. Setup before start to use it.
73
+ 4. Set tup provider in model.
74
+ 5. integrate `rails g devise:install` and `rails g devise user`
75
+ 6. `git add . && git commit --amend --no-edit && rake install`
76
+ 7. `"/app" => absolute path`
77
+ 8. `"app" => relative path, current execution path prefixed.`
78
+ 9. `test your sqlite db: sqlite3 /db/development.sqlite3`
79
+ 10. `http://localhost:3000/rails/info/routes` get route info
80
+ 11. Twitter dont like developers develop their app under `localhost` as callback url. :expressionless:
81
+ - [http://stackoverflow.com/questions/800827/twitter-oauth-callbackurl-localhost-development](http://stackoverflow.com/questions/800827/twitter-oauth-callbackurl-localhost-development)
82
+ 12. [http://www.rubydoc.info/github/erikhuda/thor/master/Thor/Actions#get-instance_method](http://www.rubydoc.info/github/erikhuda/thor/master/Thor/Actions#get-instance_method)
83
+ 13. [http://stackoverflow.com/questions/6338908/ruby-difference-between-exec-system-and-x-or-backticks](http://stackoverflow.com/questions/6338908/ruby-difference-between-exec-system-and-x-or-backticks)
84
+ 14. `rake build && gem push <gem>.gem`
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,9 @@
1
+ module OauthBundle
2
+ module Generators
3
+ class AuthSeperationGenerator < ::Rails::Generators::Base
4
+ def preset
5
+ puts "Expect to seperate authentication data from user model."
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,65 @@
1
+ module OauthBundle
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ # public method will be run automatically.
6
+
7
+ def install_devise_auth_model
8
+ model = ask "Please provide authentication model name (default: users):"
9
+ model = (model.empty? ? "users" : model).tableize
10
+ @auth_model = model
11
+
12
+ install_devise model
13
+ config_devise_routes model
14
+ end
15
+
16
+ def create_migration_for_auth_model
17
+ system "rails g migration AddColumnsTo#{@auth_model.capitalize} provider uid"
18
+ system "rake db:migrate"
19
+ end
20
+
21
+ def add_omniauth_to_devise_file
22
+ @providers = [:github, :facebook, :twitter]
23
+ inject_str = @providers.map do |e|
24
+ " config.omniauth :#{e}, 'APP_ID', 'APP_SECRET'"
25
+ end.join("\n") + "\n"
26
+
27
+ inject_into_file "config/initializers/devise.rb", inject_str,
28
+ :after => "scope: 'user,public_repo'\n"
29
+ end
30
+
31
+ def add_devise_omniauth_to_user_model
32
+ inject_str = " devise :omniauthable, :omniauth_providers => [:facebook, :twitter, :github]\n"
33
+ inject_into_file "app/models/user.rb", inject_str, :after => ":validatable\n"
34
+ end
35
+
36
+ def generate_omniauth_callback_controllers
37
+ path = "app/controllers/#{@auth_model}/omniauth_callbacks_controller.rb"
38
+ create_file path
39
+ append_file path, omniauth_callback_contrllers_content
40
+ end
41
+
42
+ private
43
+
44
+ def install_devise(model)
45
+ system "rails g devise:install"
46
+ unless File.exist?("app/models/#{model.singularize}.rb")
47
+ system "rails g devise #{model.singularize}"
48
+ end
49
+ end
50
+
51
+ def config_devise_routes(model)
52
+ gsub_file "config/routes.rb", /devise_for :#{model}$/, "devise_for :#{model}, :controllers => {:omniauth_callbacks => 'users/omniauth_callbacks'}"
53
+ end
54
+
55
+ def omniauth_callback_contrllers_content
56
+ content = "class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController\n"
57
+ providers = @providers.map do |e|
58
+ " def #{e}\n #handle callback data in here.\n end\n"
59
+ end.join("\n")
60
+
61
+ "#{content}#{providers}end\n"
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,2 @@
1
+ require "oauth_bundle/version"
2
+ require "oauth_bundle/engine"
@@ -0,0 +1,5 @@
1
+ module OauthBundle
2
+ class Engine < ::Rails::Engine
3
+ # automatically load app/controllers, app/views, app/models.
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module OauthBundle
2
+ VERSION = "1.0.2"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'oauth_bundle/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "oauth_bundle"
8
+ spec.version = OauthBundle::VERSION
9
+ spec.authors = ["James Yang"]
10
+ spec.email = ["jamesyang124@gmail.com"]
11
+ spec.summary = %q{Bundle omniauth-facebook, omniauth-github, omniauth-twitter with Devise gem.}
12
+ spec.description = %q{`Create new rails app, then run rails g oauth_bundle:install`}
13
+ spec.homepage = "https://github.com/jamesyang124/oauth_bundle"
14
+ spec.license = "MIT"
15
+
16
+ spec.add_dependency "devise"
17
+ spec.add_dependency "omniauth"
18
+ spec.add_dependency "omniauth-facebook"
19
+ spec.add_dependency "omniauth-twitter"
20
+ spec.add_dependency "omniauth-github"
21
+
22
+ spec.files = `git ls-files -z`.split("\x0")
23
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.6"
28
+ spec.add_development_dependency "rake"
29
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oauth_bundle
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - James Yang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: devise
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
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: omniauth-facebook
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: omniauth-twitter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
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: omniauth-github
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
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: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: "`Create new rails app, then run rails g oauth_bundle:install`"
112
+ email:
113
+ - jamesyang124@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - lib/generators/oauth_bundle/auth_seperation/auth_seperation_generator.rb
124
+ - lib/generators/oauth_bundle/install/install_generator.rb
125
+ - lib/oauth_bundle.rb
126
+ - lib/oauth_bundle/engine.rb
127
+ - lib/oauth_bundle/version.rb
128
+ - oauth_bundle.gemspec
129
+ homepage: https://github.com/jamesyang124/oauth_bundle
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.2.2
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Bundle omniauth-facebook, omniauth-github, omniauth-twitter with Devise gem.
153
+ test_files: []