doorkeeper 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of doorkeeper might be problematic. Click here for more details.

Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +3 -3
  4. data/CHANGELOG.md +9 -0
  5. data/Gemfile +5 -1
  6. data/README.md +33 -15
  7. data/app/assets/stylesheets/doorkeeper/admin/application.css +14 -0
  8. data/app/assets/stylesheets/doorkeeper/application.css +50 -4
  9. data/app/controllers/doorkeeper/applications_controller.rb +1 -0
  10. data/app/helpers/doorkeeper/form_errors_helper.rb +5 -3
  11. data/app/views/doorkeeper/applications/_delete_form.html.erb +3 -14
  12. data/app/views/doorkeeper/applications/_form.html.erb +29 -27
  13. data/app/views/doorkeeper/applications/edit.html.erb +3 -11
  14. data/app/views/doorkeeper/applications/index.html.erb +24 -31
  15. data/app/views/doorkeeper/applications/new.html.erb +3 -11
  16. data/app/views/doorkeeper/applications/show.html.erb +31 -21
  17. data/app/views/doorkeeper/authorizations/error.html.erb +6 -5
  18. data/app/views/doorkeeper/authorizations/new.html.erb +21 -18
  19. data/app/views/doorkeeper/authorizations/show.html.erb +6 -3
  20. data/app/views/doorkeeper/authorized_applications/_delete_form.html.erb +5 -0
  21. data/app/views/doorkeeper/authorized_applications/index.html.erb +19 -19
  22. data/app/views/layouts/doorkeeper/admin.html.erb +34 -0
  23. data/app/views/layouts/doorkeeper/application.html.erb +13 -22
  24. data/lib/doorkeeper/config.rb +15 -4
  25. data/lib/doorkeeper/helpers/filter.rb +1 -1
  26. data/lib/doorkeeper/models/active_record/access_grant.rb +1 -1
  27. data/lib/doorkeeper/models/active_record/access_token.rb +1 -1
  28. data/lib/doorkeeper/models/active_record/application.rb +2 -2
  29. data/lib/doorkeeper/models/application.rb +2 -1
  30. data/lib/doorkeeper/models/mongoid/version.rb +15 -0
  31. data/lib/doorkeeper/models/{mongoid3 → mongoid3_4}/access_grant.rb +8 -1
  32. data/lib/doorkeeper/models/{mongoid3 → mongoid3_4}/access_token.rb +8 -1
  33. data/lib/doorkeeper/models/{mongoid3 → mongoid3_4}/application.rb +0 -0
  34. data/lib/doorkeeper/oauth/error_response.rb +2 -1
  35. data/lib/doorkeeper/oauth/helpers/uri_checker.rb +7 -2
  36. data/lib/doorkeeper/version.rb +1 -1
  37. data/lib/generators/doorkeeper/templates/initializer.rb +5 -0
  38. data/spec/dummy/app/models/user.rb +1 -1
  39. data/spec/dummy/config/application.rb +1 -1
  40. data/spec/dummy/config/environments/development.rb +2 -3
  41. data/spec/dummy/config/environments/production.rb +2 -0
  42. data/spec/dummy/config/environments/test.rb +8 -0
  43. data/spec/dummy/config/mongoid4.yml +18 -0
  44. data/spec/lib/config_spec.rb +5 -0
  45. data/spec/lib/oauth/helpers/uri_checker_spec.rb +45 -0
  46. data/spec/requests/applications/applications_request_spec.rb +4 -4
  47. data/spec/requests/flows/authorization_code_spec.rb +1 -1
  48. data/spec/requests/flows/client_credentials_spec.rb +1 -1
  49. data/spec/spec_helper_integration.rb +6 -0
  50. data/spec/support/helpers/request_spec_helper.rb +4 -0
  51. data/vendor/assets/stylesheets/doorkeeper/bootstrap.min.css +7 -356
  52. metadata +10 -6
  53. data/app/assets/stylesheets/doorkeeper/form.css +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6d9a384a7eea2de2b4c25ea45fa6143aa23f8e6
4
- data.tar.gz: 6401bda0dec405b1acdf9fd0cd4db42ada6f7f97
3
+ metadata.gz: 5932eba602c89d1c69d2255da6feb6c617fe969c
4
+ data.tar.gz: bc86b1d997b36876f7f3adb05f6043b069c79528
5
5
  SHA512:
6
- metadata.gz: d61715593d0cd03aa6c7f32c62fcbdb3d924f410c5635a8cc97d6510fb09b48b508417fe70f9dccbcf1d0d20be8c12c86a37085b5a448bbb0c71203f015640cb
7
- data.tar.gz: 9f10eb154a27dbcc558672f8add080aaa79380a3fe4ec807ef28c33f51679c84f5cc7be7debe019e0f9d21d70ed88656cacbed47e2019943cc72229d01c54bb6
6
+ metadata.gz: 5e2cd77f86d3c8ca56317b562502f186e54633c6decc945fd50e52ca7ad34133f52190129db1171d59e014d878abb1390ae2082d0fb3438a18315a3c09d734b1
7
+ data.tar.gz: 6c484a19b386a02d24ffebbc62ad80d6c9e7cda67d94baa49afe25fd010a51eec4d4c8bfe0ef59f8fa95265ca66b6e7fbb337260f7473170d4502cbc3c96ee49
data/.gitignore CHANGED
@@ -11,4 +11,4 @@ gemfiles/*.lock
11
11
  spec/generators/tmp
12
12
  .rvmrc
13
13
  *.swp
14
-
14
+ .idea
data/.travis.yml CHANGED
@@ -13,9 +13,9 @@ env:
13
13
  - rails=4.1.0.beta1
14
14
  - orm=mongoid2
15
15
  - orm=mongoid3
16
+ - orm=mongoid4
16
17
  - orm=mongo_mapper
18
+ - table_name_prefix=h_
19
+ - table_name_suffix=_h
17
20
  services:
18
21
  - mongodb
19
- matrix:
20
- allow_failures:
21
- - env: orm=mongoid2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0 (not yet released)
4
+
5
+ - enhancements
6
+ - [#336] mongoid4 support.
7
+ - [#372] Allow users to set ActiveRecord table_name_prefix/suffix options
8
+ - internals
9
+ - [#343] separate OAuth's admin and user end-point to different layouts, upgrade theme to Bootstrap 3.1.
10
+ - [#348] Move render_options in filter after `@error` has been set
11
+
3
12
  ## 1.0.0
4
13
 
5
14
  - bug (spec)
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  # Defaults. For supported versions check .travis.yml
2
- ENV['rails'] ||= '3.2.13'
2
+ ENV['rails'] ||= ENV['orm'] == "mongoid4" ? '4.0.2' : '3.2.13'
3
3
  ENV['orm'] ||= 'active_record'
4
4
 
5
5
  source 'https://rubygems.org'
@@ -20,6 +20,10 @@ when 'mongoid2'
20
20
  when 'mongoid3'
21
21
  gem 'mongoid', '3.0.10'
22
22
 
23
+ when 'mongoid4'
24
+ gem 'mongoid', '4.0.0.beta1'
25
+ gem 'moped'
26
+
23
27
  when 'mongo_mapper'
24
28
  gem 'mongo_mapper', '0.12.0'
25
29
  gem 'bson_ext', '~> 1.7'
data/README.md CHANGED
@@ -7,12 +7,39 @@
7
7
 
8
8
  Doorkeeper is a gem that makes it easy to introduce OAuth 2 provider functionality to your application.
9
9
 
10
- The gem is under constant development. It is based in the [version 22 of the OAuth specification](http://tools.ietf.org/html/draft-ietf-oauth-v2-22) and it still does not support all OAuth features.
10
+ ## Table of Contents
11
+
12
+ - [Useful links](#useful-links)
13
+ - [Requirements](#requirements)
14
+ - [Installation](#installation)
15
+ - [Configuration](#configuration)
16
+ - [Active Record](#active-record)
17
+ - [Mongoid / MongoMapper](#mongoid--mongomapper)
18
+ - [Mongoid indexes](#mongoid-indexes)
19
+ - [MongoMapper indexes](#mongomapper-indexes)
20
+ - [Routes](#routes)
21
+ - [Authenticating](#authenticating)
22
+ - [Protecting resources with OAuth (a.k.a your API endpoint)](#protecting-resources-with-oauth-aka-your-api-endpoint)
23
+ - [ActionController::Metal integration and other integrations](#actioncontrollermetal-integration-and-other-integrations)
24
+ - [Access Token Scopes](#access-token-scopes)
25
+ - [Authenticated resource owner](#authenticated-resource-owner)
26
+ - [Applications list](#applications-list)
27
+ - [Other customizations](#other-customizations)
28
+ - [Upgrading](#upgrading)
29
+ - [Development](#development)
30
+ - [Contributing](#contributing)
31
+ - [Other resources](#other-resources)
32
+ - [Wiki](#wiki)
33
+ - [Live demo](#live-demo)
34
+ - [Screencast](#screencast)
35
+ - [Client applications](#client-applications)
36
+ - [Contributors](#contributors)
37
+ - [License](#license)
11
38
 
12
39
  ## Useful links
13
40
 
14
41
  - For documentation, please check out our [wiki](https://github.com/applicake/doorkeeper/wiki)
15
- - For general questions, please post it in our [google groups](https://groups.google.com/forum/?fromgroups#!forum/doorkeeper-gem) or [stack overflow](http://stackoverflow.com/questions/tagged/doorkeeper)
42
+ - For general questions, please post it in [stack overflow](http://stackoverflow.com/questions/tagged/doorkeeper)
16
43
 
17
44
  ## Requirements
18
45
 
@@ -25,7 +52,7 @@ The gem is under constant development. It is based in the [version 22 of the OAu
25
52
  Put this in your Gemfile:
26
53
 
27
54
  ``` ruby
28
- gem 'doorkeeper', '~> 0.7.0'
55
+ gem 'doorkeeper'
29
56
  ```
30
57
 
31
58
  Run the installation generator with:
@@ -52,7 +79,7 @@ Doorkeeper currently supports MongoMapper, Mongoid 2 and 3. To start using it, y
52
79
 
53
80
  ``` ruby
54
81
  Doorkeeper.configure do
55
- orm :mongoid2 # or :mongoid3, :mongo_mapper
82
+ orm :mongoid2 # or :mongoid3, :mongoid4, :mongo_mapper
56
83
  end
57
84
  ```
58
85
 
@@ -234,7 +261,7 @@ The logic is the same as the `resource_owner_authenticator` block. **Note:** sin
234
261
 
235
262
  If you want to upgrade doorkeeper to a new version, check out the [upgrading notes](https://github.com/applicake/doorkeeper/wiki/Migration-from-old-versions) and take a look at the [changelog](https://github.com/applicake/doorkeeper/blob/master/CHANGELOG.md).
236
263
 
237
- ### Development
264
+ ## Development
238
265
 
239
266
  To run the local engine server:
240
267
 
@@ -251,7 +278,7 @@ rails=3.2.8 orm=active_record bundle exec rake
251
278
 
252
279
  Or you might prefer to run `script/run_all` to integrate against all ORMs.
253
280
 
254
- ### Contributing
281
+ ## Contributing
255
282
 
256
283
  Want to contribute and don't know where to start? Check out [features we're missing](https://github.com/applicake/doorkeeper/wiki/Supported-Features), create [example apps](https://github.com/applicake/doorkeeper/wiki/Example-Applications), integrate the gem with your app and let us know!
257
284
 
@@ -275,15 +302,6 @@ Check out this screencast from [railscasts.com](http://railscasts.com/): [#353 O
275
302
 
276
303
  After you set up the provider, you may want to create a client application to test the integration. Check out these [client examples](https://github.com/applicake/doorkeeper/wiki/Example-Applications) in our wiki or follow this [tutorial here](https://github.com/applicake/doorkeeper/wiki/Testing-your-provider-with-OAuth2-gem).
277
304
 
278
- ### Supported ruby versions
279
-
280
- All supported ruby versions are [listed here](https://github.com/applicake/doorkeeper/wiki/Supported-Ruby-&-Rails-versions).
281
-
282
- ### Maintainers
283
-
284
- - Felipe Elias Philipp - [coderwall.com/felipeelias](http://coderwall.com/felipeelias)
285
- - Piotr Jakubowski - [coderwall.com/piotrj](http://coderwall.com/piotrj)
286
-
287
305
  ### Contributors
288
306
 
289
307
  Thanks to all our [awesome contributors](https://github.com/applicake/doorkeeper/contributors)!
@@ -0,0 +1,14 @@
1
+ /*
2
+ *= require doorkeeper/bootstrap.min
3
+ *
4
+ *= require_self
5
+ *= require_tree .
6
+ */
7
+
8
+ body {
9
+ padding-top: 60px;
10
+ }
11
+
12
+ td {
13
+ vertical-align: middle !important;
14
+ }
@@ -6,13 +6,59 @@
6
6
  */
7
7
 
8
8
  body {
9
- padding-top: 60px;
9
+ background-color: #eee;
10
+ font-size: 14px;
11
+ }
12
+
13
+ #container {
14
+ background-color: #fff;
15
+ border: 1px solid #999;
16
+ border: 1px solid rgba(0, 0, 0, 0.2);
17
+ border-radius: 6px;
18
+ -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
19
+ box-shadow: 0 3px 20px rgba(0, 0, 0, 0.3);
20
+ margin: 2em auto;
21
+ max-width: 600px;
22
+ outline: 0;
23
+ padding: 1em;
24
+ width: 80%;
25
+ }
26
+
27
+ .page-header {
28
+ margin-top: 20px;
29
+ }
30
+
31
+ #oauth-permissions {
32
+ width: 260px;
33
+ }
34
+
35
+ .actions {
36
+ border-top: 1px solid #eee;
37
+ margin-top: 1em;
38
+ padding-top: 9px;
39
+ }
40
+
41
+ .actions > form > .btn {
42
+ margin-top: 5px;
43
+ }
44
+
45
+ .separator {
46
+ color: #eee;
47
+ padding: 0 .5em;
10
48
  }
11
49
 
12
50
  .inline_block {
13
- display: inline-block;
51
+ display: inline-block;
52
+ }
53
+
54
+ #oauth {
55
+ margin-bottom: 1em;
56
+ }
57
+
58
+ #oauth > .btn {
59
+ width: 7em;
14
60
  }
15
61
 
16
- table td {
17
- vertical-align: middle;
62
+ td {
63
+ vertical-align: middle !important;
18
64
  }
@@ -1,5 +1,6 @@
1
1
  module Doorkeeper
2
2
  class ApplicationsController < Doorkeeper::ApplicationController
3
+ layout 'doorkeeper/admin'
3
4
  respond_to :html
4
5
 
5
6
  before_filter :authenticate_admin!
@@ -1,9 +1,11 @@
1
1
  module Doorkeeper::FormErrorsHelper
2
2
  def errors_for(object, method)
3
3
  if object.errors[method].present?
4
- content_tag(:span, :class => "error help-inline") do
5
- object.errors[method].join(',')
6
- end
4
+ object.errors[method].map do |msg|
5
+ content_tag(:span, :class => "help-block") do
6
+ msg.capitalize
7
+ end
8
+ end.reduce(&:join).html_safe
7
9
  end
8
10
  end
9
11
  end
@@ -1,16 +1,5 @@
1
- <style>
2
- input[type=submit] {
3
- padding: 0;
4
- border: none;
5
- box-shadow: none;
6
- background: none;
7
- color: #0069d6;
8
- }
9
- input[type=submit]:hover {
10
- text-decoration: underline;
11
- }
12
- </style>
13
- <%= form_for [:oauth, application] do |f| %>
1
+ <%- submit_btn_css ||= 'btn btn-link' %>
2
+ <%= form_tag [:oauth, application] do %>
14
3
  <input type="hidden" name="_method" value="delete">
15
- <%= f.submit value: 'Remove', onclick: "return confirm('Are you sure?')" %>
4
+ <%= submit_tag 'Destroy', onclick: "return confirm('Are you sure?')", class: submit_btn_css %>
16
5
  <% end %>
@@ -1,35 +1,37 @@
1
- <%= form_for([:oauth, application]) do |f| %>
2
- <fieldset>
3
- <% if application.errors.any? %>
4
- <div class="alert-message error" data-alert><a class="close" href="#">×</a><p>Whoops! Check your form for possible errors</p></div>
5
- <% end %>
1
+ <%= form_for [:oauth, application], html: {class: 'form-horizontal', role: 'form'} do |f| %>
2
+ <% if application.errors.any? %>
3
+ <div class="alert alert-danger" data-alert><p>Whoops! Check your form for possible errors</p></div>
4
+ <% end %>
6
5
 
7
- <div class="clearfix">
8
- <%= f.label :name %>
9
- <div class="input">
10
- <%= f.text_field :name %>
11
- <%= errors_for application, :name %>
12
- </div>
6
+ <%= content_tag :div, class: "form-group#{' has-error' if application.errors[:name].present?}" do %>
7
+ <%= f.label :name, class: 'col-sm-2 control-label', for: 'application_name' %>
8
+ <div class="col-sm-10">
9
+ <%= f.text_field :name, class: 'form-control' %>
10
+ <%= errors_for application, :name %>
13
11
  </div>
12
+ <% end %>
14
13
 
15
- <div class="clearfix">
16
- <%= f.label :redirect_uri %>
17
- <div class="input">
18
- <%= f.text_area :redirect_uri %>
19
- <%= errors_for application, :redirect_uri %>
20
- <span class="help-inline">Please use one line per URI.</span>
21
- <% if Doorkeeper.configuration.test_redirect_uri %>
22
- <span class="help-inline">Use <%= Doorkeeper.configuration.test_redirect_uri %> for local tests</span>
23
- <% end %>
24
- </div>
14
+ <%= content_tag :div, class: "form-group#{' has-error' if application.errors[:redirect_uri].present?}" do %>
15
+ <%= f.label :redirect_uri, class: 'col-sm-2 control-label', for: 'application_redirect_uri' %>
16
+ <div class="col-sm-10">
17
+ <%= f.text_area :redirect_uri, class: 'form-control' %>
18
+ <%= errors_for application, :redirect_uri %>
19
+ <span class="help-block">
20
+ Use one line per URI
21
+ </span>
22
+ <% if Doorkeeper.configuration.test_redirect_uri %>
23
+ <span class="help-block">
24
+ Use <code><%= Doorkeeper.configuration.test_redirect_uri %></code> for local tests
25
+ </span>
26
+ <% end %>
25
27
  </div>
28
+ <% end %>
26
29
 
27
- <div class="clearfix"></div>
28
-
29
- <div class="actions">
30
- <%= f.submit :Submit, :class => "btn primary" %>
31
- <%= link_to "Cancel", oauth_applications_path, :class => "btn" %>
30
+ <div class="form-group">
31
+ <div class="col-sm-offset-2 col-sm-10">
32
+ <%= f.submit 'Submit', :class => "btn btn-primary" %>
33
+ <%= link_to "Cancel", oauth_applications_path, :class => "btn btn-default" %>
32
34
  </div>
33
- </fieldset>
35
+ </div>
34
36
  <% end %>
35
37
 
@@ -1,13 +1,5 @@
1
- <div class="span16">
2
- <header class="page-header"><h2>Edit application</h2></header>
3
- </div>
4
-
5
- <div class="span12">
6
- <%= render 'form', :application => @application %>
7
- </div>
8
-
9
- <div class="span4">
10
- <h3>Actions</h3>
11
- <p><%= link_to 'Back to application list', oauth_applications_path %></p>
1
+ <div class="page-header">
2
+ <h1>Edit application</h1>
12
3
  </div>
13
4
 
5
+ <%= render 'form', :application => @application %>
@@ -1,33 +1,26 @@
1
- <style>
2
- input[type=submit] {
3
- margin-top: 15px;
4
- }
5
- </style>
6
- <div class="span16">
7
- <header class="page-header">
8
- <h2>Your applications</h2>
9
- </header>
1
+ <div class="page-header">
2
+ <h1>Your applications</h1>
3
+ </div>
10
4
 
11
- <p><%= link_to 'New Application', new_oauth_application_path %></p>
5
+ <p><%= link_to 'New Application', new_oauth_application_path, class: 'btn btn-success' %></p>
12
6
 
13
- <table class="zebra-striped">
14
- <thead>
15
- <tr>
16
- <th>Name</th>
17
- <th>Callback url</th>
18
- <th></th>
19
- <th></th>
20
- </tr>
21
- </thead>
22
- <tbody>
23
- <% @applications.each do |application| %>
24
- <tr id="application_<%= application.id %>">
25
- <td><%= link_to application.name, [:oauth, application] %></td>
26
- <td><%= application.redirect_uri %></td>
27
- <td><%= link_to 'Edit', edit_oauth_application_path(application) %></td>
28
- <td><%= render 'delete_form', application: application %></td>
29
- </tr>
30
- <% end %>
31
- </tbody>
32
- </table>
33
- </div>
7
+ <table class="table table-striped">
8
+ <thead>
9
+ <tr>
10
+ <th>Name</th>
11
+ <th>Callback URL</th>
12
+ <th></th>
13
+ <th></th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <% @applications.each do |application| %>
18
+ <tr id="application_<%= application.id %>">
19
+ <td><%= link_to application.name, [:oauth, application] %></td>
20
+ <td><%= application.redirect_uri %></td>
21
+ <td><%= link_to 'Edit', edit_oauth_application_path(application), class: 'btn btn-link' %></td>
22
+ <td><%= render 'delete_form', application: application %></td>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
@@ -1,13 +1,5 @@
1
- <div class="span16">
2
- <header class="page-header"><h2>New application</h2></header>
3
- </div>
4
-
5
- <div class="span12">
6
- <%= render 'form', :application => @application %>
7
- </div>
8
-
9
- <div class="span4">
10
- <h3>Actions</h3>
11
- <p><%= link_to 'Back to application list', oauth_applications_path %></p>
1
+ <div class="page-header">
2
+ <h1>New application</h1>
12
3
  </div>
13
4
 
5
+ <%= render 'form', :application => @application %>