doorkeeper-sequel 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +13 -0
  6. data/.travis.yml +24 -0
  7. data/CHANGELOG.md +24 -0
  8. data/Gemfile +23 -0
  9. data/Gemfile.lock +172 -0
  10. data/LICENSE +21 -0
  11. data/README.md +76 -0
  12. data/Rakefile +56 -0
  13. data/config/locales/en.yml +16 -0
  14. data/doorkeeper-sequel.gemspec +32 -0
  15. data/gemfiles/rails-4.2.gemfile +11 -0
  16. data/gemfiles/rails-5.0.gemfile +11 -0
  17. data/lib/doorkeeper/orm/sequel/access_grant.rb +9 -0
  18. data/lib/doorkeeper/orm/sequel/access_token.rb +32 -0
  19. data/lib/doorkeeper/orm/sequel/application.rb +18 -0
  20. data/lib/doorkeeper/orm/sequel/models/access_grant_mixin.rb +50 -0
  21. data/lib/doorkeeper/orm/sequel/models/access_token_mixin.rb +163 -0
  22. data/lib/doorkeeper/orm/sequel/models/application_mixin.rb +70 -0
  23. data/lib/doorkeeper/orm/sequel/models/concerns/ownership.rb +19 -0
  24. data/lib/doorkeeper/orm/sequel/models/concerns/sequel_compat.rb +40 -0
  25. data/lib/doorkeeper/orm/sequel/validators/redirect_uri_validator.rb +49 -0
  26. data/lib/doorkeeper/orm/sequel.rb +18 -0
  27. data/lib/doorkeeper-sequel/gem_version.rb +13 -0
  28. data/lib/doorkeeper-sequel/version.rb +7 -0
  29. data/lib/doorkeeper-sequel.rb +18 -0
  30. data/lib/generators/doorkeeper/sequel/application_owner_generator.rb +23 -0
  31. data/lib/generators/doorkeeper/sequel/migration_generator.rb +23 -0
  32. data/lib/generators/doorkeeper/sequel/previous_refresh_token_generator.rb +23 -0
  33. data/lib/generators/doorkeeper/sequel/templates/add_owner_to_application.rb +9 -0
  34. data/lib/generators/doorkeeper/sequel/templates/add_previous_refresh_token_to_access_tokens.rb +7 -0
  35. data/lib/generators/doorkeeper/sequel/templates/migration.rb +59 -0
  36. data/spec/controllers/application_metal_controller.rb +10 -0
  37. data/spec/controllers/applications_controller_spec.rb +58 -0
  38. data/spec/controllers/authorizations_controller_spec.rb +189 -0
  39. data/spec/controllers/protected_resources_controller_spec.rb +300 -0
  40. data/spec/controllers/token_info_controller_spec.rb +52 -0
  41. data/spec/controllers/tokens_controller_spec.rb +88 -0
  42. data/spec/dummy/Rakefile +7 -0
  43. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  44. data/spec/dummy/app/controllers/custom_authorizations_controller.rb +7 -0
  45. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +12 -0
  46. data/spec/dummy/app/controllers/home_controller.rb +17 -0
  47. data/spec/dummy/app/controllers/metal_controller.rb +11 -0
  48. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +11 -0
  49. data/spec/dummy/app/helpers/application_helper.rb +5 -0
  50. data/spec/dummy/app/models/user.rb +11 -0
  51. data/spec/dummy/app/views/home/index.html.erb +0 -0
  52. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  53. data/spec/dummy/config/application.rb +29 -0
  54. data/spec/dummy/config/boot.rb +9 -0
  55. data/spec/dummy/config/database.yml +15 -0
  56. data/spec/dummy/config/environment.rb +5 -0
  57. data/spec/dummy/config/environments/development.rb +29 -0
  58. data/spec/dummy/config/environments/production.rb +62 -0
  59. data/spec/dummy/config/environments/test.rb +44 -0
  60. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  61. data/spec/dummy/config/initializers/db.rb +74 -0
  62. data/spec/dummy/config/initializers/doorkeeper.rb +96 -0
  63. data/spec/dummy/config/initializers/secret_token.rb +9 -0
  64. data/spec/dummy/config/initializers/session_store.rb +8 -0
  65. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/spec/dummy/config/locales/doorkeeper.en.yml +5 -0
  67. data/spec/dummy/config/routes.rb +52 -0
  68. data/spec/dummy/config.ru +4 -0
  69. data/spec/dummy/db/migrate/20111122132257_create_users.rb +9 -0
  70. data/spec/dummy/db/migrate/20120312140401_add_password_to_users.rb +5 -0
  71. data/spec/dummy/db/migrate/20151223192035_create_doorkeeper_tables.rb +60 -0
  72. data/spec/dummy/db/migrate/20151223200000_add_owner_to_application.rb +7 -0
  73. data/spec/dummy/db/migrate/20160320211015_add_previous_refresh_token_to_access_tokens.rb +11 -0
  74. data/spec/dummy/db/schema.rb +67 -0
  75. data/spec/dummy/log/test.log +19813 -0
  76. data/spec/dummy/public/404.html +26 -0
  77. data/spec/dummy/public/422.html +26 -0
  78. data/spec/dummy/public/500.html +26 -0
  79. data/spec/dummy/public/favicon.ico +0 -0
  80. data/spec/dummy/script/rails +6 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-T/-TZF6Ae6YipbyKuHghb9wlTx4_b9itbSHRc_2PmqjiU.cache +1 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/0p/0pa3wNbGHqFC6gxrMvdOJiP6gPwFv9VJ_npjEfRWxAE.cache +1 -0
  83. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2e/2eYh115US2lIRhM2KTEaJFa6aV_cX8iv6JAdjuq0Uio.cache +1 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3P/3PoguHEOEeItUjmwC74MWLLP-_Ijow7798bF5U6K2dw.cache +1 -0
  85. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/6b/6b0anrSo7Fvoc05t4Ca0zZmfS_cpERy1DsG3ea6lBOg.cache +0 -0
  86. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/BA/BAC3ZaGoeZ9Od-kKg-UQYelvRgsCa0H72-52nLdcTNw.cache +1 -0
  87. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Bw/Bw6Nimjvy5Yv1AYbZb1t-v0eMNhv-bhwBzR-b5mY7FU.cache +0 -0
  88. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Fq/FqQWjMAz8yjZQlMC_dUsztaOxGruI2IXyGAAUF9SvQ0.cache +1 -0
  89. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/J_/J_D9clwKidN28hnVB1O3zEfKDwg90Usdb5ToKiPq_aw.cache +0 -0
  90. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ji/JitNKkP1dYdu9ObSdIkkEAsiFxEmRO5oy1UIyhT_hYs.cache +0 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Jq/JqTLVvnY2AgGkHftWPwqt_HkbwhYRsmgHxk37VqKJAY.cache +0 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/QX/QXcp8DweOJ6BfMedGMfeHvVXv2hjDIleln1LSJk7vOE.cache +2 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Qy/Qy1ldbz6vKa_fv4E4ByxWslKFoV1qReQR5DKJ525z88.cache +1 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Rl/RlCJ_X5xFsE3VBDhkYrY7r_R6sMgiAc03cT8nr7Q2vY.cache +0 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ta/TaYxNn81MhqC3DnMC6_y_Q7xap5Ntn4ggFo94EUaiak.cache +0 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wq/WqbLVKOcTMZtttygYt_ncr1mGIDrzevSTaPGNmzV1D8.cache +1 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YF/YF60qiQ28QMoYDrLmrbHWZr7X7bl5MxVPR5QrrVCFak.cache +1 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Yf/YfJJZvm_NONHd4eCasDibCcRapZ_WYIO5MUxSUUbYFk.cache +0 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Z0/Z0e47cT2a-21U-w-3gkbgqC3o5jWnEzOB8vW06aJH1E.cache +0 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/_u/_uy-z8SVnhffUNelRxbPDL2aAUPb_GbqREXVsfy8uGc.cache +0 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/dL/dL7SLUWUIeVdyA1UuH-rvif0nzesOar3LdEtqzdb4bE.cache +0 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/f8/f8WT8jqR1qNIdQaRDpXbyLN7E5AWkbYFBwdh9Ozk7gk.cache +1 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hk/hk2YB6skvc72qL4IzzQKU8Emyfe5vARjoD1bvQTw4zE.cache +1 -0
  104. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iO/iOpDp_7ZvBNO5WIpTmqNewUl9bB2satqXWulyNvAaX8.cache +0 -0
  105. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ii/iiJRBZIsxKiwyzU_Z7UtQeUTXMRJRPTreTKRvAWO7_8.cache +1 -0
  106. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mj/mjuMepngMLrtgilLlJ9oTTSqoGO1YUww1rXphQ1pOm4.cache +0 -0
  107. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/qo/qo6SpT75QykYB63Aqq5bgzpXyNU1Y4dGFvCCJgoWQpE.cache +1 -0
  108. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sp/sprzBMBliJDI__s-0D3q82tn1MpBkFV0N651hTr3XE8.cache +1 -0
  109. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/tM/tM6A7CR8QluP_u4u59vN1GjSZGNqNH3TXkkNzb9EPXA.cache +0 -0
  110. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/vO/vOXN0mER62j4JiPpMTSVS7MMqs0067cZx14vD5B8qiQ.cache +0 -0
  111. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zz/zzlQ_kom0liFOvGYDcjtVw6yAHOyA-bbzP8f0e_Tq1A.cache +1 -0
  112. data/spec/factories.rb +28 -0
  113. data/spec/generators/application_owner_generator_spec.rb +20 -0
  114. data/spec/generators/migration_generator_spec.rb +20 -0
  115. data/spec/generators/previous_refresh_token_generator_spec.rb +20 -0
  116. data/spec/generators/templates/routes.rb +3 -0
  117. data/spec/generators/tmp/dummy/db/migrate/20161012132809_create_doorkeeper_tables.rb +59 -0
  118. data/spec/helpers/doorkeeper/dashboard_helper_spec.rb +24 -0
  119. data/spec/lib/config_spec.rb +334 -0
  120. data/spec/lib/doorkeeper_spec.rb +28 -0
  121. data/spec/lib/models/expirable_spec.rb +51 -0
  122. data/spec/lib/models/revocable_spec.rb +59 -0
  123. data/spec/lib/models/scopes_spec.rb +43 -0
  124. data/spec/lib/oauth/authorization/uri_builder_spec.rb +42 -0
  125. data/spec/lib/oauth/authorization_code_request_spec.rb +80 -0
  126. data/spec/lib/oauth/client/credentials_spec.rb +47 -0
  127. data/spec/lib/oauth/client/methods_spec.rb +54 -0
  128. data/spec/lib/oauth/client_credentials/creator_spec.rb +44 -0
  129. data/spec/lib/oauth/client_credentials/issuer_spec.rb +86 -0
  130. data/spec/lib/oauth/client_credentials/validation_spec.rb +54 -0
  131. data/spec/lib/oauth/client_credentials_integration_spec.rb +27 -0
  132. data/spec/lib/oauth/client_credentials_request_spec.rb +104 -0
  133. data/spec/lib/oauth/client_spec.rb +39 -0
  134. data/spec/lib/oauth/code_request_spec.rb +45 -0
  135. data/spec/lib/oauth/code_response_spec.rb +34 -0
  136. data/spec/lib/oauth/error_response_spec.rb +61 -0
  137. data/spec/lib/oauth/error_spec.rb +23 -0
  138. data/spec/lib/oauth/forbidden_token_response_spec.rb +23 -0
  139. data/spec/lib/oauth/helpers/scope_checker_spec.rb +64 -0
  140. data/spec/lib/oauth/helpers/unique_token_spec.rb +20 -0
  141. data/spec/lib/oauth/helpers/uri_checker_spec.rb +104 -0
  142. data/spec/lib/oauth/invalid_token_response_spec.rb +28 -0
  143. data/spec/lib/oauth/password_access_token_request_spec.rb +90 -0
  144. data/spec/lib/oauth/pre_authorization_spec.rb +155 -0
  145. data/spec/lib/oauth/refresh_token_request_spec.rb +154 -0
  146. data/spec/lib/oauth/scopes_spec.rb +122 -0
  147. data/spec/lib/oauth/token_request_spec.rb +98 -0
  148. data/spec/lib/oauth/token_response_spec.rb +85 -0
  149. data/spec/lib/oauth/token_spec.rb +116 -0
  150. data/spec/lib/request/strategy_spec.rb +53 -0
  151. data/spec/lib/server_spec.rb +52 -0
  152. data/spec/models/doorkeeper/access_grant_spec.rb +36 -0
  153. data/spec/models/doorkeeper/access_token_spec.rb +394 -0
  154. data/spec/models/doorkeeper/application_spec.rb +179 -0
  155. data/spec/requests/applications/applications_request_spec.rb +94 -0
  156. data/spec/requests/applications/authorized_applications_spec.rb +30 -0
  157. data/spec/requests/endpoints/authorization_spec.rb +72 -0
  158. data/spec/requests/endpoints/token_spec.rb +64 -0
  159. data/spec/requests/flows/authorization_code_errors_spec.rb +66 -0
  160. data/spec/requests/flows/authorization_code_spec.rb +156 -0
  161. data/spec/requests/flows/client_credentials_spec.rb +58 -0
  162. data/spec/requests/flows/implicit_grant_errors_spec.rb +32 -0
  163. data/spec/requests/flows/implicit_grant_spec.rb +61 -0
  164. data/spec/requests/flows/password_spec.rb +115 -0
  165. data/spec/requests/flows/refresh_token_spec.rb +174 -0
  166. data/spec/requests/flows/revoke_token_spec.rb +157 -0
  167. data/spec/requests/flows/skip_authorization_spec.rb +59 -0
  168. data/spec/requests/protected_resources/metal_spec.rb +14 -0
  169. data/spec/requests/protected_resources/private_api_spec.rb +81 -0
  170. data/spec/routing/custom_controller_routes_spec.rb +71 -0
  171. data/spec/routing/default_routes_spec.rb +35 -0
  172. data/spec/routing/scoped_routes_spec.rb +31 -0
  173. data/spec/spec_helper.rb +2 -0
  174. data/spec/spec_helper_integration.rb +50 -0
  175. data/spec/stubs/config/application.rb +29 -0
  176. data/spec/stubs/config/initializers/db.rb +74 -0
  177. data/spec/stubs/generators/application_owner_generator_spec.rb +20 -0
  178. data/spec/stubs/generators/migration_generator_spec.rb +20 -0
  179. data/spec/stubs/generators/previous_refresh_token_generator_spec.rb +20 -0
  180. data/spec/stubs/generators/tmp/dummy/db/migrate/20161012132810_add_owner_to_application.rb +9 -0
  181. data/spec/stubs/models/user.rb +11 -0
  182. data/spec/stubs/spec_helper_integration.rb +50 -0
  183. data/spec/stubs/support/sequel.rb +0 -0
  184. data/spec/support/dependencies/factory_girl.rb +2 -0
  185. data/spec/support/helpers/access_token_request_helper.rb +11 -0
  186. data/spec/support/helpers/authorization_request_helper.rb +41 -0
  187. data/spec/support/helpers/config_helper.rb +9 -0
  188. data/spec/support/helpers/model_helper.rb +67 -0
  189. data/spec/support/helpers/request_spec_helper.rb +76 -0
  190. data/spec/support/helpers/url_helper.rb +55 -0
  191. data/spec/support/http_method_shim.rb +24 -0
  192. data/spec/support/orm/active_record.rb +3 -0
  193. data/spec/support/orm/sequel.rb +0 -0
  194. data/spec/support/shared/controllers_shared_context.rb +69 -0
  195. data/spec/support/shared/models_shared_examples.rb +52 -0
  196. data/spec/validators/redirect_uri_validator_spec.rb +78 -0
  197. metadata +570 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b2235f65047e089b96000ef4895bf3eb59a9fb5f
4
+ data.tar.gz: 4b87e28b654b19fa3bd3f751ff681d3a8f8d1d31
5
+ SHA512:
6
+ metadata.gz: c4dbec12974ea208de475e59eb9f044218d915110e5209081291df5ecd2ca09e09edcac75e29e92fc7f8e80fcb651cbaa5cfaaac69205d6dca7a153cba68b60d
7
+ data.tar.gz: 69c85935c01adb313590d7dbc7765a75c3b1f077293b9f994befa275c6f9f8c68faac53591fb5456611fdfbc1cc764bae8926ba7b7ab8bc91f85983473c3cc25
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ .bundle/
2
+ .rbx
3
+ *.rbc
4
+ log/*.log
5
+ .rvmrc
6
+ /.idea
7
+ /spec/*
8
+ !/spec/stubs
9
+ gemfiles/*.lock
10
+ Gemfile.lock
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "doorkeeper"]
2
+ path = doorkeeper
3
+ url = https://github.com/doorkeeper-gem/doorkeeper.git
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ LineLength:
2
+ Max: 120
3
+ AllCops:
4
+ Exclude:
5
+ - 'doorkeeper/**/*'
6
+ - 'spec/**/*'
7
+ DisplayCopNames: true
8
+ Rails:
9
+ Enabled: true
10
+ Documentation:
11
+ Enabled: false
12
+ Style/EndOfLine:
13
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,24 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+ bundler_args: --without yard guard benchmarks
5
+
6
+ before_install:
7
+ - gem install bundler -v '~> 1.10'
8
+
9
+ gemfile:
10
+ - gemfiles/rails-4.2.gemfile
11
+ - gemfiles/rails-5.0.gemfile
12
+
13
+ rvm:
14
+ - 2.1
15
+ - 2.2.4
16
+ - 2.3.0
17
+ - ruby-head
18
+
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: ruby-head
22
+ exclude:
23
+ - rvm: 2.1
24
+ gemfile: gemfiles/rails-5.0.gemfile
data/CHANGELOG.md ADDED
@@ -0,0 +1,24 @@
1
+ # Doorkeeper-Sequel ORM 1.x Changelog
2
+
3
+ Reverse Chronological Order:
4
+
5
+ ## `1.2.1` (2016-10-12)
6
+
7
+ https://github.com/nbulaj/doorkeeper-sequel/compare/1.2.0...1.2.1
8
+
9
+ * Association dependencies changed to `:delete` instead of `:destroy` (in accordance to Doorkeeper)
10
+ * Fixed generators and specs for it
11
+ * Code refactoring with [rubocop](https://github.com/bbatsov/rubocop)
12
+ * No braking changes
13
+
14
+ ## `1.2.0` (2016-09-05)
15
+
16
+ https://github.com/nbulaj/doorkeeper-sequel/compare/1.0.0...1.2.0
17
+
18
+ * Added compatibility with Doorkeeper 4.2
19
+ * No braking changes
20
+
21
+ ## `1.0.0` (2016-05-17)
22
+
23
+ * First stable release
24
+ * Compatible with Doorkeeper >= 4.x and Rails >= 4.x
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ platforms :jruby do
6
+ gem 'jdbc-sqlite3'
7
+ end
8
+
9
+ platforms :ruby, :mswin, :mswin64, :mingw, :x64_mingw do
10
+ gem 'sqlite3'
11
+ end
12
+
13
+ gem 'sequel', '>= 4.0'
14
+ gem 'sequel_polymorphic'
15
+
16
+ gem 'rails', '~> 5.0'
17
+ gem 'doorkeeper', '>= 4.0.0'
18
+
19
+ group :test do
20
+ gem 'rspec-rails', '~> 3.4'
21
+ end
22
+
23
+ gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
data/Gemfile.lock ADDED
@@ -0,0 +1,172 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ doorkeeper (4.2.0)
5
+ railties (>= 4.2)
6
+ doorkeeper-sequel (1.2.1)
7
+ doorkeeper (~> 4.0, >= 4.0.0)
8
+ sequel (~> 4.0, >= 4.0.0)
9
+ sequel_polymorphic (~> 0.2, < 1.0)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ actioncable (5.0.0.1)
15
+ actionpack (= 5.0.0.1)
16
+ nio4r (~> 1.2)
17
+ websocket-driver (~> 0.6.1)
18
+ actionmailer (5.0.0.1)
19
+ actionpack (= 5.0.0.1)
20
+ actionview (= 5.0.0.1)
21
+ activejob (= 5.0.0.1)
22
+ mail (~> 2.5, >= 2.5.4)
23
+ rails-dom-testing (~> 2.0)
24
+ actionpack (5.0.0.1)
25
+ actionview (= 5.0.0.1)
26
+ activesupport (= 5.0.0.1)
27
+ rack (~> 2.0)
28
+ rack-test (~> 0.6.3)
29
+ rails-dom-testing (~> 2.0)
30
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
31
+ actionview (5.0.0.1)
32
+ activesupport (= 5.0.0.1)
33
+ builder (~> 3.1)
34
+ erubis (~> 2.7.0)
35
+ rails-dom-testing (~> 2.0)
36
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
37
+ activejob (5.0.0.1)
38
+ activesupport (= 5.0.0.1)
39
+ globalid (>= 0.3.6)
40
+ activemodel (5.0.0.1)
41
+ activesupport (= 5.0.0.1)
42
+ activerecord (5.0.0.1)
43
+ activemodel (= 5.0.0.1)
44
+ activesupport (= 5.0.0.1)
45
+ arel (~> 7.0)
46
+ activesupport (5.0.0.1)
47
+ concurrent-ruby (~> 1.0, >= 1.0.2)
48
+ i18n (~> 0.7)
49
+ minitest (~> 5.1)
50
+ tzinfo (~> 1.1)
51
+ addressable (2.4.0)
52
+ arel (7.1.4)
53
+ builder (3.2.2)
54
+ capybara (2.7.1)
55
+ addressable
56
+ mime-types (>= 1.16)
57
+ nokogiri (>= 1.3.3)
58
+ rack (>= 1.0.0)
59
+ rack-test (>= 0.5.4)
60
+ xpath (~> 2.0)
61
+ concurrent-ruby (1.0.2)
62
+ database_cleaner (1.5.3)
63
+ diff-lcs (1.2.5)
64
+ erubis (2.7.0)
65
+ factory_girl (4.7.0)
66
+ activesupport (>= 3.0.0)
67
+ generator_spec (0.9.3)
68
+ activesupport (>= 3.0.0)
69
+ railties (>= 3.0.0)
70
+ globalid (0.3.7)
71
+ activesupport (>= 4.1.0)
72
+ i18n (0.7.0)
73
+ loofah (2.0.3)
74
+ nokogiri (>= 1.5.9)
75
+ mail (2.6.4)
76
+ mime-types (>= 1.16, < 4)
77
+ method_source (0.8.2)
78
+ mime-types (3.1)
79
+ mime-types-data (~> 3.2015)
80
+ mime-types-data (3.2016.0521)
81
+ mini_portile2 (2.1.0)
82
+ minitest (5.9.1)
83
+ nio4r (1.2.1)
84
+ nokogiri (1.6.8.1)
85
+ mini_portile2 (~> 2.1.0)
86
+ rack (2.0.1)
87
+ rack-test (0.6.3)
88
+ rack (>= 1.0)
89
+ rails (5.0.0.1)
90
+ actioncable (= 5.0.0.1)
91
+ actionmailer (= 5.0.0.1)
92
+ actionpack (= 5.0.0.1)
93
+ actionview (= 5.0.0.1)
94
+ activejob (= 5.0.0.1)
95
+ activemodel (= 5.0.0.1)
96
+ activerecord (= 5.0.0.1)
97
+ activesupport (= 5.0.0.1)
98
+ bundler (>= 1.3.0, < 2.0)
99
+ railties (= 5.0.0.1)
100
+ sprockets-rails (>= 2.0.0)
101
+ rails-dom-testing (2.0.1)
102
+ activesupport (>= 4.2.0, < 6.0)
103
+ nokogiri (~> 1.6.0)
104
+ rails-html-sanitizer (1.0.3)
105
+ loofah (~> 2.0)
106
+ railties (5.0.0.1)
107
+ actionpack (= 5.0.0.1)
108
+ activesupport (= 5.0.0.1)
109
+ method_source
110
+ rake (>= 0.8.7)
111
+ thor (>= 0.18.1, < 2.0)
112
+ rake (11.3.0)
113
+ rspec-core (3.5.4)
114
+ rspec-support (~> 3.5.0)
115
+ rspec-expectations (3.5.0)
116
+ diff-lcs (>= 1.2.0, < 2.0)
117
+ rspec-support (~> 3.5.0)
118
+ rspec-mocks (3.5.0)
119
+ diff-lcs (>= 1.2.0, < 2.0)
120
+ rspec-support (~> 3.5.0)
121
+ rspec-rails (3.5.2)
122
+ actionpack (>= 3.0)
123
+ activesupport (>= 3.0)
124
+ railties (>= 3.0)
125
+ rspec-core (~> 3.5.0)
126
+ rspec-expectations (~> 3.5.0)
127
+ rspec-mocks (~> 3.5.0)
128
+ rspec-support (~> 3.5.0)
129
+ rspec-support (3.5.0)
130
+ sequel (4.39.0)
131
+ sequel_polymorphic (0.2.2)
132
+ sequel (~> 4.0)
133
+ sprockets (3.7.0)
134
+ concurrent-ruby (~> 1.0)
135
+ rack (> 1, < 3)
136
+ sprockets-rails (3.2.0)
137
+ actionpack (>= 4.0)
138
+ activesupport (>= 4.0)
139
+ sprockets (>= 3.0.0)
140
+ sqlite3 (1.3.12)
141
+ thor (0.19.1)
142
+ thread_safe (0.3.5)
143
+ timecop (0.8.1)
144
+ tzinfo (1.2.2)
145
+ thread_safe (~> 0.1)
146
+ websocket-driver (0.6.4)
147
+ websocket-extensions (>= 0.1.0)
148
+ websocket-extensions (0.1.2)
149
+ xpath (2.0.0)
150
+ nokogiri (~> 1.3)
151
+
152
+ PLATFORMS
153
+ ruby
154
+
155
+ DEPENDENCIES
156
+ capybara (~> 2.7, >= 2.7.0)
157
+ database_cleaner (~> 1.5, >= 1.5.0)
158
+ doorkeeper (>= 4.0.0)
159
+ doorkeeper-sequel!
160
+ factory_girl (~> 4.7, >= 4.7.0)
161
+ generator_spec (~> 0.9.0)
162
+ jdbc-sqlite3
163
+ rails (~> 5.0)
164
+ rspec-rails (~> 3.4)
165
+ sequel (>= 4.0)
166
+ sequel_polymorphic
167
+ sqlite3
168
+ timecop (~> 0.8.0)
169
+ tzinfo-data
170
+
171
+ BUNDLED WITH
172
+ 1.13.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nikita Bulaj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Doorkeeper Sequel ORM extension
2
+ [![GitHub release](https://img.shields.io/github/release/nbulaj/doorkeeper-sequel.svg?maxAge=259200)]()
3
+ [![Build Status](https://travis-ci.org/nbulaj/doorkeeper-sequel.svg?branch=master)](https://travis-ci.org/nbulaj/doorkeeper-sequel)
4
+ [![Dependency Status](https://gemnasium.com/nbulaj/doorkeeper-sequel.svg)](https://gemnasium.com/nbulaj/doorkeeper-sequel)
5
+ [![Code Climate](https://codeclimate.com/github/nbulaj/doorkeeper-sequel/badges/gpa.svg)](https://codeclimate.com/github/nbulaj/doorkeeper-sequel)
6
+ [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](#license)
7
+
8
+ `doorkeeper-sequel` provides [Doorkeeper](https://github.com/doorkeeper-gem/doorkeeper) support to [Sequel](https://github.com/jeremyevans/sequel) database toolkit.
9
+
10
+ ## Requirements
11
+
12
+ * Doorkeeper >= 4.0
13
+ * Rails >= 4.2 (Doorkeeper 4 dropped support of lower versions)
14
+ * Sequel >= 4
15
+
16
+ ## Installation
17
+
18
+ To start using the Doorkeeper Sequel ORM, add to your Gemfile:
19
+
20
+ ``` ruby
21
+ gem 'doorkeeper-sequel', git: 'https://github.com/nbulaj/doorkeeper-sequel.git'
22
+ ```
23
+
24
+ Set the Doorkeeper ORM configuration:
25
+
26
+ ``` ruby
27
+ Doorkeeper.configure do
28
+ orm :sequel
29
+ end
30
+ ```
31
+
32
+ Generate migrations:
33
+
34
+ ```
35
+ rails generate doorkeeper:sequel:migration
36
+ rails generate doorkeeper:sequel:application_owner
37
+ rails generate doorkeeper:sequel:previous_refresh_token
38
+ ```
39
+
40
+ ## Tests
41
+
42
+ To run tests, clone this repository and run `rake`. It will copy and run
43
+ `Doorkeeper`’s original test suite after configuring the ORM and other stuffs.
44
+
45
+ ```
46
+ $ bundle exec rake
47
+ ```
48
+
49
+ ## Contributing
50
+
51
+ You are very welcome to help improve `doorkeeper-sequel` if you have suggestions for features that other people can use or some code improvements.
52
+
53
+ To contribute:
54
+
55
+ 1. Fork the project.
56
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
57
+ 3. Implement your feature or bug fix.
58
+ 4. Add documentation for your feature or bug fix.
59
+ 5. Add tests for your feature or bug fix.
60
+ 6. Run `rake` to make sure all tests pass.
61
+ 7. Commit your changes (`git commit -am 'Add new feature'`).
62
+ 8. Push to the branch (`git push origin my-new-feature`).
63
+ 9. Create new pull request.
64
+
65
+ Thanks.
66
+
67
+ ## License
68
+
69
+ Doorkeeper-sequel gem is released under the [MIT License](http://www.opensource.org/licenses/MIT).
70
+
71
+ Copyright (c) 2016 Nikita Bulaj (bulajnikita@gmail.com).
72
+
73
+ ---
74
+
75
+ Please refer to https://github.com/doorkeeper-gem/doorkeeper for instructions on
76
+ doorkeeper’s project.
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'bundler/setup'
2
+ require 'rspec/core/rake_task'
3
+
4
+ def clear_specs
5
+ base_dir = File.join(Dir.pwd, 'spec')
6
+ Dir.foreach(base_dir) do |file|
7
+ next if %w(. .. stubs).include?(file)
8
+
9
+ file_name = File.join(base_dir, file)
10
+ if File.directory?(file_name)
11
+ FileUtils.rm_rf(file_name)
12
+ else
13
+ File.delete(file_name)
14
+ end
15
+ end
16
+ end
17
+
18
+ desc 'Update Git submodules.'
19
+ task :update_submodules do
20
+ `git submodule foreach git pull origin master`
21
+ end
22
+
23
+ task :copy_and_run_doorkeeper_specs do
24
+ # Clear specs dir
25
+ clear_specs
26
+ # Copy native Doorkepeer specs
27
+ if Dir['doorkeeper/*'].empty?
28
+ `git submodule init`
29
+ `git submodule update`
30
+ end
31
+ `cp -r -n doorkeeper/spec .`
32
+ # Replace ORM-independent files (configs, models, etc)
33
+ FileUtils.cp_r('spec/stubs/spec_helper_integration.rb', 'spec/spec_helper_integration.rb')
34
+ FileUtils.cp_r('spec/stubs/models/user.rb', 'spec/dummy/app/models/user.rb')
35
+ FileUtils.cp_r('spec/stubs/config/initializers/db.rb', 'spec/dummy/config/initializers/db.rb')
36
+ FileUtils.cp_r('spec/stubs/config/application.rb', 'spec/dummy/config/application.rb')
37
+ FileUtils.cp_r('spec/stubs/support/sequel.rb', 'spec/support/orm/sequel.rb')
38
+ FileUtils.rm('spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb')
39
+ # Generators
40
+ FileUtils.rm(Dir.glob('spec/generators/*.rb'))
41
+ FileUtils.cp_r(Dir.glob('spec/stubs/generators/*.rb'), 'spec/generators/')
42
+ # Run specs
43
+ `bundle exec rspec`
44
+ end
45
+
46
+ desc 'Default: run specs.'
47
+ task default: :spec
48
+
49
+ desc 'Clone doorkeeper specs, prepare it for Sequel and run'
50
+ task spec: :copy_and_run_doorkeeper_specs
51
+
52
+ RSpec::Core::RakeTask.new(:spec) do |config|
53
+ config.verbose = false
54
+ end
55
+
56
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,16 @@
1
+ en:
2
+ sequel:
3
+ attributes:
4
+ doorkeeper/application:
5
+ name: 'Name'
6
+ redirect_uri: 'Redirect URI'
7
+ errors:
8
+ models:
9
+ doorkeeper/application:
10
+ attributes:
11
+ redirect_uri:
12
+ blank: "can't be blank"
13
+ fragment_present: 'cannot contain a fragment.'
14
+ invalid_uri: 'must be a valid URI.'
15
+ relative_uri: 'must be an absolute URI.'
16
+ secured_uri: 'must be an HTTPS/SSL URI.'
@@ -0,0 +1,32 @@
1
+ $LOAD_PATH.push File.expand_path('../lib', __FILE__)
2
+
3
+ require 'doorkeeper-sequel/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'doorkeeper-sequel'
7
+ gem.version = DoorkeeperSequel.gem_version
8
+ gem.authors = ['Nikita Bulaj']
9
+ gem.date = '2016-10-12'
10
+ gem.email = ['bulajnikita@gmail.com']
11
+ gem.homepage = 'http://github.com/nbulaj/doorkeeper-sequel'
12
+ gem.summary = 'Doorkeeper Sequel ORM'
13
+ gem.description = 'Provides Doorkeeper support to Sequel database toolkit.'
14
+ gem.license = 'MIT'
15
+
16
+ gem.require_paths = %w(lib config)
17
+ gem.files = `git ls-files`.split($RS)
18
+ gem.test_files = Dir['spec/**/*']
19
+
20
+ gem.required_ruby_version = '>= 2.0.0'
21
+
22
+ gem.add_runtime_dependency 'doorkeeper', '~> 4.0', '>= 4.0.0'
23
+ gem.add_runtime_dependency 'sequel', '~> 4.0', '>= 4.0.0'
24
+ gem.add_runtime_dependency 'sequel_polymorphic', '~> 0.2', '< 1.0'
25
+
26
+ gem.add_development_dependency 'rspec-rails', '~> 3.4', '>= 3.4.0'
27
+ gem.add_development_dependency 'capybara', '~> 2.7', '>= 2.7.0'
28
+ gem.add_development_dependency 'generator_spec', '~> 0.9.0'
29
+ gem.add_development_dependency 'factory_girl', '~> 4.7', '>= 4.7.0'
30
+ gem.add_development_dependency 'timecop', '~> 0.8.0'
31
+ gem.add_development_dependency 'database_cleaner', '~> 1.5', '>= 1.5.0'
32
+ end
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '../'
4
+
5
+ gem 'rails', '~> 4.2'
6
+ gem 'sqlite3', '~> 1.3.5'
7
+ gem 'sequel', '>= 4.0'
8
+
9
+ group :test do
10
+ gem 'rspec-rails', '~> 3.4'
11
+ end
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'rails', '~> 5.0'
6
+ gem 'sqlite3', '~> 1.3.5'
7
+ gem 'sequel', '>= 4.0'
8
+
9
+ group :test do
10
+ gem 'rspec-rails', '3.5.0'
11
+ end
@@ -0,0 +1,9 @@
1
+ require_relative 'models/access_grant_mixin'
2
+
3
+ module Doorkeeper
4
+ class AccessGrant < Sequel::Model
5
+ set_dataset :oauth_access_grants
6
+
7
+ include Doorkeeper::Orm::Sequel::AccessGrantMixin
8
+ end
9
+ end
@@ -0,0 +1,32 @@
1
+ require_relative 'models/access_token_mixin'
2
+
3
+ module Doorkeeper
4
+ class AccessToken < Sequel::Model
5
+ set_dataset :oauth_access_tokens
6
+
7
+ include Doorkeeper::Orm::Sequel::AccessTokenMixin
8
+
9
+ class << self
10
+ def delete_all_for(application_id, resource_owner)
11
+ where(application_id: application_id,
12
+ resource_owner_id: resource_owner.id).delete
13
+ end
14
+
15
+ def active_for(resource_owner)
16
+ where(resource_owner_id: resource_owner.id, revoked_at: nil)
17
+ end
18
+
19
+ def order_method
20
+ :order
21
+ end
22
+
23
+ def created_at_desc
24
+ ::Sequel.desc(:created_at)
25
+ end
26
+
27
+ def refresh_token_revoked_on_use?
28
+ columns.include?(:previous_refresh_token)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,18 @@
1
+ require_relative 'models/application_mixin'
2
+
3
+ module Doorkeeper
4
+ class Application < Sequel::Model
5
+ set_dataset :oauth_applications
6
+
7
+ include Doorkeeper::Orm::Sequel::ApplicationMixin
8
+
9
+ one_to_many :authorized_tokens, class: 'Doorkeeper::AccessToken', conditions: { revoked_at: nil }
10
+ many_to_many :authorized_applications, join_table: :oauth_access_tokens,
11
+ class: self, left_key: :id, right_key: :application_id
12
+
13
+ def self.authorized_for(resource_owner)
14
+ resource_access_tokens = AccessToken.active_for(resource_owner)
15
+ where(id: resource_access_tokens.select_map(:application_id)).all
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,50 @@
1
+ module Doorkeeper
2
+ module Orm
3
+ module Sequel
4
+ module AccessGrantMixin
5
+ extend ActiveSupport::Concern
6
+
7
+ include SequelCompat
8
+ include OAuth::Helpers
9
+ include Models::Expirable
10
+ include Models::Revocable
11
+ include Models::Accessible
12
+ include Models::Scopes
13
+
14
+ included do
15
+ plugin :validation_helpers
16
+ plugin :timestamps
17
+
18
+ many_to_one :application, class: 'Doorkeeper::Application'
19
+
20
+ set_allowed_columns :resource_owner_id, :application_id,
21
+ :expires_in, :redirect_uri, :scopes
22
+
23
+ def before_validation
24
+ generate_token if new?
25
+ super
26
+ end
27
+
28
+ def validate
29
+ super
30
+ validates_presence [:resource_owner_id, :application_id,
31
+ :token, :expires_in, :redirect_uri]
32
+ validates_unique [:token]
33
+ end
34
+ end
35
+
36
+ module ClassMethods
37
+ def by_token(token)
38
+ find(token: token.to_s)
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def generate_token
45
+ self.token = UniqueToken.generate
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end