oauth2_facebook_grantable 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. data/.gitignore +5 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +8 -0
  4. data/LICENSE.txt +19 -0
  5. data/README.md +81 -0
  6. data/Rakefile +1 -0
  7. data/lib/devise/oauth2_facebook_grantable/models/oauth2_facebook_grantable.rb +23 -0
  8. data/lib/devise/oauth2_facebook_grantable/strategies/facebook_grant_type.rb +25 -0
  9. data/lib/devise/oauth2_facebook_grantable/version.rb +5 -0
  10. data/lib/generators/oauth2_facebook_grantable/install_generator.rb +32 -0
  11. data/lib/generators/oauth2_facebook_grantable/templates/migration_add_column.rb +6 -0
  12. data/lib/oauth2_facebook_grantable.rb +43 -0
  13. data/oauth2_facebook_grantable.gemspec +25 -0
  14. data/spec/spec_helper.rb +8 -0
  15. data/tests/.gitignore +15 -0
  16. data/tests/Gemfile +41 -0
  17. data/tests/README.rdoc +261 -0
  18. data/tests/Rakefile +7 -0
  19. data/tests/app/assets/images/rails.png +0 -0
  20. data/tests/app/assets/javascripts/application.js +15 -0
  21. data/tests/app/assets/stylesheets/application.css +13 -0
  22. data/tests/app/controllers/application_controller.rb +3 -0
  23. data/tests/app/helpers/application_helper.rb +2 -0
  24. data/tests/app/mailers/.gitkeep +0 -0
  25. data/tests/app/models/.gitkeep +0 -0
  26. data/tests/app/models/user.rb +12 -0
  27. data/tests/app/views/layouts/application.html.erb +14 -0
  28. data/tests/config.ru +4 -0
  29. data/tests/config/application.rb +59 -0
  30. data/tests/config/boot.rb +6 -0
  31. data/tests/config/database.yml +25 -0
  32. data/tests/config/environment.rb +5 -0
  33. data/tests/config/environments/development.rb +37 -0
  34. data/tests/config/environments/production.rb +67 -0
  35. data/tests/config/environments/test.rb +37 -0
  36. data/tests/config/initializers/backtrace_silencers.rb +7 -0
  37. data/tests/config/initializers/devise.rb +223 -0
  38. data/tests/config/initializers/inflections.rb +15 -0
  39. data/tests/config/initializers/mime_types.rb +5 -0
  40. data/tests/config/initializers/secret_token.rb +7 -0
  41. data/tests/config/initializers/session_store.rb +8 -0
  42. data/tests/config/initializers/wrap_parameters.rb +14 -0
  43. data/tests/config/locales/devise.en.yml +57 -0
  44. data/tests/config/locales/en.yml +5 -0
  45. data/tests/config/routes.rb +61 -0
  46. data/tests/config/yetting.yml +12 -0
  47. data/tests/db/migrate/20120426123002_devise_create_users.rb +49 -0
  48. data/tests/db/migrate/20120426123040_create_devise_oauth2_providable_schema.devise_oauth2_providable.rb +55 -0
  49. data/tests/db/migrate/20120426124308_add_facebook_identifier_to_users.rb +6 -0
  50. data/tests/db/schema.rb +91 -0
  51. data/tests/db/seeds.rb +7 -0
  52. data/tests/doc/README_FOR_APP +2 -0
  53. data/tests/lib/assets/.gitkeep +0 -0
  54. data/tests/lib/tasks/.gitkeep +0 -0
  55. data/tests/log/.gitkeep +0 -0
  56. data/tests/public/404.html +26 -0
  57. data/tests/public/422.html +26 -0
  58. data/tests/public/500.html +25 -0
  59. data/tests/public/favicon.ico +0 -0
  60. data/tests/public/index.html +241 -0
  61. data/tests/public/robots.txt +5 -0
  62. data/tests/script/rails +6 -0
  63. data/tests/test/fixtures/.gitkeep +0 -0
  64. data/tests/test/fixtures/users.yml +26 -0
  65. data/tests/test/functional/.gitkeep +0 -0
  66. data/tests/test/integration/.gitkeep +0 -0
  67. data/tests/test/integration/facebook_oauth_test.rb +69 -0
  68. data/tests/test/performance/browsing_test.rb +12 -0
  69. data/tests/test/test_helper.rb +13 -0
  70. data/tests/test/unit/.gitkeep +0 -0
  71. data/tests/test/unit/user_test.rb +7 -0
  72. data/tests/vendor/assets/javascripts/.gitkeep +0 -0
  73. data/tests/vendor/assets/stylesheets/.gitkeep +0 -0
  74. data/tests/vendor/plugins/.gitkeep +0 -0
  75. metadata +214 -0
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
11
+ #
12
+ # These inflection rules are supported but not enabled by default:
13
+ # ActiveSupport::Inflector.inflections do |inflect|
14
+ # inflect.acronym 'RESTful'
15
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Fbgrantable::Application.config.secret_token = '79686edc2627e8a99a7184068748518bc435a71a8512d2abafaccb5b754778236108986e0ae75f3c5ce93ccb3b92ed64fe42513273c007b90c9b921cf843a2c7'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Fbgrantable::Application.config.session_store :cookie_store, key: '_fbgrantable_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Fbgrantable::Application.config.session_store :active_record_store
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,57 @@
1
+ # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ en:
4
+ errors:
5
+ messages:
6
+ expired: "has expired, please request a new one"
7
+ not_found: "not found"
8
+ already_confirmed: "was already confirmed, please try signing in"
9
+ not_locked: "was not locked"
10
+ not_saved:
11
+ one: "1 error prohibited this %{resource} from being saved:"
12
+ other: "%{count} errors prohibited this %{resource} from being saved:"
13
+
14
+ devise:
15
+ failure:
16
+ already_authenticated: 'You are already signed in.'
17
+ unauthenticated: 'You need to sign in or sign up before continuing.'
18
+ unconfirmed: 'You have to confirm your account before continuing.'
19
+ locked: 'Your account is locked.'
20
+ invalid: 'Invalid email or password.'
21
+ invalid_token: 'Invalid authentication token.'
22
+ timeout: 'Your session expired, please sign in again to continue.'
23
+ inactive: 'Your account was not activated yet.'
24
+ sessions:
25
+ signed_in: 'Signed in successfully.'
26
+ signed_out: 'Signed out successfully.'
27
+ passwords:
28
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
29
+ updated: 'Your password was changed successfully. You are now signed in.'
30
+ updated_not_active: 'Your password was changed successfully.'
31
+ send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
32
+ confirmations:
33
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
34
+ send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
35
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
36
+ registrations:
37
+ signed_up: 'Welcome! You have signed up successfully.'
38
+ signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
39
+ signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
40
+ signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
41
+ updated: 'You updated your account successfully.'
42
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
43
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
44
+ unlocks:
45
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
46
+ unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
47
+ send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
48
+ omniauth_callbacks:
49
+ success: 'Successfully authorized from %{kind} account.'
50
+ failure: 'Could not authorize you from %{kind} because "%{reason}".'
51
+ mailer:
52
+ confirmation_instructions:
53
+ subject: 'Confirmation instructions'
54
+ reset_password_instructions:
55
+ subject: 'Reset password instructions'
56
+ unlock_instructions:
57
+ subject: 'Unlock Instructions'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,61 @@
1
+ Fbgrantable::Application.routes.draw do
2
+ devise_for :users
3
+ mount Devise::Oauth2Providable::Engine => '/oauth'
4
+
5
+ # The priority is based upon order of creation:
6
+ # first created -> highest priority.
7
+
8
+ # Sample of regular route:
9
+ # match 'products/:id' => 'catalog#view'
10
+ # Keep in mind you can assign values other than :controller and :action
11
+
12
+ # Sample of named route:
13
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
14
+ # This route can be invoked with purchase_url(:id => product.id)
15
+
16
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
17
+ # resources :products
18
+
19
+ # Sample resource route with options:
20
+ # resources :products do
21
+ # member do
22
+ # get 'short'
23
+ # post 'toggle'
24
+ # end
25
+ #
26
+ # collection do
27
+ # get 'sold'
28
+ # end
29
+ # end
30
+
31
+ # Sample resource route with sub-resources:
32
+ # resources :products do
33
+ # resources :comments, :sales
34
+ # resource :seller
35
+ # end
36
+
37
+ # Sample resource route with more complex sub-resources
38
+ # resources :products do
39
+ # resources :comments
40
+ # resources :sales do
41
+ # get 'recent', :on => :collection
42
+ # end
43
+ # end
44
+
45
+ # Sample resource route within a namespace:
46
+ # namespace :admin do
47
+ # # Directs /admin/products/* to Admin::ProductsController
48
+ # # (app/controllers/admin/products_controller.rb)
49
+ # resources :products
50
+ # end
51
+
52
+ # You can have the root of your site routed with "root"
53
+ # just remember to delete public/index.html.
54
+ # root :to => 'welcome#index'
55
+
56
+ # See how all your routes lay out with "rake routes"
57
+
58
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
59
+ # Note: This route will make all actions in every controller accessible via GET requests.
60
+ # match ':controller(/:action(/:id))(.:format)'
61
+ end
@@ -0,0 +1,12 @@
1
+ development:
2
+ facebook_api_key: "186907338078802"
3
+ facebook_api_secret: "92af665c205784a1e3a78e535dbe6754"
4
+
5
+ test:
6
+ facebook_api_key: "186907338078802"
7
+ facebook_api_secret: "92af665c205784a1e3a78e535dbe6754"
8
+
9
+
10
+ production:
11
+ facebook_api_key: "186907338078802"
12
+ facebook_api_secret: "92af665c205784a1e3a78e535dbe6754"
@@ -0,0 +1,49 @@
1
+ class DeviseCreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:users) do |t|
4
+ ## Database authenticatable
5
+ t.string :email, :null => false, :default => ""
6
+ t.string :encrypted_password, :null => false, :default => ""
7
+
8
+ ## Recoverable
9
+ t.string :reset_password_token
10
+ t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, :default => 0
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+
22
+ ## Encryptable
23
+ # t.string :password_salt
24
+
25
+ ## Confirmable
26
+ # t.string :confirmation_token
27
+ # t.datetime :confirmed_at
28
+ # t.datetime :confirmation_sent_at
29
+ # t.string :unconfirmed_email # Only if using reconfirmable
30
+
31
+ ## Lockable
32
+ # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
33
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
34
+ # t.datetime :locked_at
35
+
36
+ ## Token authenticatable
37
+ # t.string :authentication_token
38
+
39
+
40
+ t.timestamps
41
+ end
42
+
43
+ add_index :users, :email, :unique => true
44
+ add_index :users, :reset_password_token, :unique => true
45
+ # add_index :users, :confirmation_token, :unique => true
46
+ # add_index :users, :unlock_token, :unique => true
47
+ # add_index :users, :authentication_token, :unique => true
48
+ end
49
+ end
@@ -0,0 +1,55 @@
1
+ # This migration comes from devise_oauth2_providable (originally 20111014160714)
2
+ class CreateDeviseOauth2ProvidableSchema < ActiveRecord::Migration
3
+ def change
4
+ create_table :oauth2_clients do |t|
5
+ t.string :name
6
+ t.string :redirect_uri
7
+ t.string :website
8
+ t.string :identifier
9
+ t.string :secret
10
+ t.timestamps
11
+ end
12
+ change_table :oauth2_clients do |t|
13
+ t.index :identifier, :unique => true
14
+ end
15
+
16
+ create_table :oauth2_access_tokens do |t|
17
+ t.belongs_to :user, :client, :refresh_token
18
+ t.string :token
19
+ t.datetime :expires_at
20
+ t.timestamps
21
+ end
22
+ change_table :oauth2_access_tokens do |t|
23
+ t.index :token, :unique => true
24
+ t.index :expires_at
25
+ t.index :user_id
26
+ t.index :client_id
27
+ end
28
+
29
+ create_table :oauth2_refresh_tokens do |t|
30
+ t.belongs_to :user, :client
31
+ t.string :token
32
+ t.datetime :expires_at
33
+ t.timestamps
34
+ end
35
+ change_table :oauth2_refresh_tokens do |t|
36
+ t.index :token, :unique => true
37
+ t.index :expires_at
38
+ t.index :user_id
39
+ t.index :client_id
40
+ end
41
+
42
+ create_table :oauth2_authorization_codes do |t|
43
+ t.belongs_to :user, :client
44
+ t.string :token
45
+ t.datetime :expires_at
46
+ t.timestamps
47
+ end
48
+ change_table :oauth2_authorization_codes do |t|
49
+ t.index :token, :unique => true
50
+ t.index :expires_at
51
+ t.index :user_id
52
+ t.index :client_id
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,6 @@
1
+ class AddFacebookIdentifierToUsers < ActiveRecord::Migration
2
+ def change
3
+ add_column :users, :facebook_identifier, :string
4
+ add_index :users , :facebook_identifier, :unique => true
5
+ end
6
+ end
@@ -0,0 +1,91 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20120426124308) do
15
+
16
+ create_table "oauth2_access_tokens", :force => true do |t|
17
+ t.integer "user_id"
18
+ t.integer "client_id"
19
+ t.integer "refresh_token_id"
20
+ t.string "token"
21
+ t.datetime "expires_at"
22
+ t.datetime "created_at", :null => false
23
+ t.datetime "updated_at", :null => false
24
+ end
25
+
26
+ add_index "oauth2_access_tokens", ["client_id"], :name => "index_oauth2_access_tokens_on_client_id"
27
+ add_index "oauth2_access_tokens", ["expires_at"], :name => "index_oauth2_access_tokens_on_expires_at"
28
+ add_index "oauth2_access_tokens", ["token"], :name => "index_oauth2_access_tokens_on_token", :unique => true
29
+ add_index "oauth2_access_tokens", ["user_id"], :name => "index_oauth2_access_tokens_on_user_id"
30
+
31
+ create_table "oauth2_authorization_codes", :force => true do |t|
32
+ t.integer "user_id"
33
+ t.integer "client_id"
34
+ t.string "token"
35
+ t.datetime "expires_at"
36
+ t.datetime "created_at", :null => false
37
+ t.datetime "updated_at", :null => false
38
+ end
39
+
40
+ add_index "oauth2_authorization_codes", ["client_id"], :name => "index_oauth2_authorization_codes_on_client_id"
41
+ add_index "oauth2_authorization_codes", ["expires_at"], :name => "index_oauth2_authorization_codes_on_expires_at"
42
+ add_index "oauth2_authorization_codes", ["token"], :name => "index_oauth2_authorization_codes_on_token", :unique => true
43
+ add_index "oauth2_authorization_codes", ["user_id"], :name => "index_oauth2_authorization_codes_on_user_id"
44
+
45
+ create_table "oauth2_clients", :force => true do |t|
46
+ t.string "name"
47
+ t.string "redirect_uri"
48
+ t.string "website"
49
+ t.string "identifier"
50
+ t.string "secret"
51
+ t.datetime "created_at", :null => false
52
+ t.datetime "updated_at", :null => false
53
+ end
54
+
55
+ add_index "oauth2_clients", ["identifier"], :name => "index_oauth2_clients_on_identifier", :unique => true
56
+
57
+ create_table "oauth2_refresh_tokens", :force => true do |t|
58
+ t.integer "user_id"
59
+ t.integer "client_id"
60
+ t.string "token"
61
+ t.datetime "expires_at"
62
+ t.datetime "created_at", :null => false
63
+ t.datetime "updated_at", :null => false
64
+ end
65
+
66
+ add_index "oauth2_refresh_tokens", ["client_id"], :name => "index_oauth2_refresh_tokens_on_client_id"
67
+ add_index "oauth2_refresh_tokens", ["expires_at"], :name => "index_oauth2_refresh_tokens_on_expires_at"
68
+ add_index "oauth2_refresh_tokens", ["token"], :name => "index_oauth2_refresh_tokens_on_token", :unique => true
69
+ add_index "oauth2_refresh_tokens", ["user_id"], :name => "index_oauth2_refresh_tokens_on_user_id"
70
+
71
+ create_table "users", :force => true do |t|
72
+ t.string "email", :default => "", :null => false
73
+ t.string "encrypted_password", :default => "", :null => false
74
+ t.string "reset_password_token"
75
+ t.datetime "reset_password_sent_at"
76
+ t.datetime "remember_created_at"
77
+ t.integer "sign_in_count", :default => 0
78
+ t.datetime "current_sign_in_at"
79
+ t.datetime "last_sign_in_at"
80
+ t.string "current_sign_in_ip"
81
+ t.string "last_sign_in_ip"
82
+ t.datetime "created_at", :null => false
83
+ t.datetime "updated_at", :null => false
84
+ t.string "facebook_identifier"
85
+ end
86
+
87
+ add_index "users", ["email"], :name => "index_users_on_email", :unique => true
88
+ add_index "users", ["facebook_identifier"], :name => "index_users_on_facebook_identifier", :unique => true
89
+ add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
90
+
91
+ end
data/tests/db/seeds.rb ADDED
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
@@ -0,0 +1,2 @@
1
+ Use this README file to introduce your application and point to useful places in the API for learning more.
2
+ Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries.
File without changes
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>