oauth2_provider 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/CHANGELOG +306 -0
  2. data/HACKING.textile +45 -0
  3. data/NOTICE.textile +6 -0
  4. data/README.textile +11 -3
  5. data/WHAT_IS_OAUTH.textile +165 -0
  6. data/app/controllers/oauth_authorize_controller.rb +69 -0
  7. data/app/controllers/oauth_clients_controller.rb +79 -0
  8. data/app/controllers/oauth_token_controller.rb +59 -0
  9. data/app/controllers/oauth_user_tokens_controller.rb +61 -0
  10. data/app/models/oauth2/provider/oauth_authorization.rb +4 -0
  11. data/app/models/oauth2/provider/oauth_client.rb +14 -3
  12. data/app/views/{oauth2/provider/layouts → layouts}/oauth_clients.html.erb +0 -0
  13. data/app/views/oauth_authorize/index.html.erb +17 -0
  14. data/app/views/oauth_clients/_form.html.erb +27 -0
  15. data/app/views/oauth_clients/edit.html.erb +7 -0
  16. data/app/views/oauth_clients/index.html.erb +53 -0
  17. data/app/views/oauth_clients/new.html.erb +7 -0
  18. data/app/views/{oauth2/provider/oauth_clients → oauth_clients}/show.html.erb +0 -0
  19. data/app/views/oauth_user_tokens/index.html.erb +28 -0
  20. data/config/routes.rb +15 -9
  21. data/generators/oauth2_provider/USAGE +12 -0
  22. data/generators/oauth2_provider/templates/config/initializers/oauth2_provider.rb +3 -0
  23. data/lib/ext/validatable_ext.rb +27 -0
  24. data/lib/oauth2/provider/a_r_datasource.rb +13 -1
  25. data/lib/oauth2/provider/application_controller_methods.rb +32 -20
  26. data/lib/oauth2/provider/configuration.rb +39 -0
  27. data/lib/oauth2/provider/in_memory_datasource.rb +8 -0
  28. data/lib/oauth2/provider/model_base.rb +59 -10
  29. data/lib/oauth2/provider/ssl_helper.rb +42 -0
  30. data/lib/oauth2/provider/transaction_helper.rb +24 -0
  31. data/lib/oauth2/provider/url_parser.rb +17 -0
  32. data/lib/oauth2_provider.rb +3 -6
  33. data/oauth2_provider.gemspec +15 -6
  34. metadata +81 -26
  35. data/app/controllers/oauth2/provider/oauth_authorize_controller.rb +0 -68
  36. data/app/controllers/oauth2/provider/oauth_clients_controller.rb +0 -56
  37. data/app/controllers/oauth2/provider/oauth_token_controller.rb +0 -58
  38. data/app/controllers/oauth2/provider/oauth_user_tokens_controller.rb +0 -29
  39. data/app/views/oauth2/provider/oauth_authorize/index.html.erb +0 -8
  40. data/app/views/oauth2/provider/oauth_clients/edit.html.erb +0 -20
  41. data/app/views/oauth2/provider/oauth_clients/index.html.erb +0 -28
  42. data/app/views/oauth2/provider/oauth_clients/new.html.erb +0 -21
  43. data/app/views/oauth2/provider/oauth_user_tokens/index.html.erb +0 -14
  44. data/tasks/gem.rake +0 -88
@@ -1,8 +0,0 @@
1
- <% form_for(url_for(:action => :authorize), :html => {:id => 'oauth_authorize_form'}) do |f| -%>
2
- Do you wish to allow the service named '<%= @client.name %>' to access this application on your behalf? <input type="checkbox" name="authorize" id="authorize" value="1" />
3
- <input type="hidden" name="client_id" id="client_id" value="<%= params[:client_id] %>" />
4
- <input type="hidden" name="redirect_uri" id="redirect_uri" value="<%= params[:redirect_uri] %>" />
5
- <input type="hidden" name="response_type" id="response_type" value="<%= params[:response_type] %>" />
6
- <input type="hidden" name="state" id="state" value="<%= params[:state] %>" />
7
- <input type="submit" value="Submit" />
8
- <% end -%>
@@ -1,20 +0,0 @@
1
- <h1>Editing oauth_client</h1>
2
-
3
- <% form_for(@oauth_client, :html => {:id => 'oauth_client_edit_form', :class => nil}) do |f| %>
4
- <%= f.error_messages %>
5
-
6
- <div>
7
- <%= f.label :name %>
8
- <%= f.text_field :name %>
9
- </div>
10
- <div>
11
- <%= f.label :redirect_uri %>
12
- <%= f.text_field :redirect_uri %>
13
- </div>
14
- <div>
15
- <%= f.submit 'Update' %>
16
- </div>
17
- <% end %>
18
-
19
- <%= link_to 'Show', @oauth_client, :class => 'show_link' %> |
20
- <%= link_to 'Back', oauth_clients_path, :class => 'back_link' %>
@@ -1,28 +0,0 @@
1
- <h1>Listing oauth_clients</h1>
2
-
3
- <table id="oauth_clients_table" class="list_table">
4
- <tr>
5
- <th>Name</th>
6
- <th>Client id</th>
7
- <th>Client secret</th>
8
- <th>Redirect URI</th>
9
- <th>Actions</th>
10
- </tr>
11
-
12
- <% @oauth_clients.each do |oauth_client| %>
13
- <tr>
14
- <td><%=h oauth_client.name %></td>
15
- <td><%=h oauth_client.client_id %></td>
16
- <td><%=h oauth_client.client_secret %></td>
17
- <td><%=h oauth_client.redirect_uri %></td>
18
- <td>
19
- <%= link_to 'Edit', edit_oauth_client_path(oauth_client), :class => 'edit_link' %>
20
- <%= link_to 'Destroy', oauth_client, :confirm => 'Are you sure?', :method => :delete, :class => 'delete_link' %>
21
- </td>
22
- </tr>
23
- <% end %>
24
- </table>
25
-
26
- <br />
27
-
28
- <%= link_to 'New oauth_client', new_oauth_client_path, :class => 'link_as_button', :id => 'new_oauth_client_button' %>
@@ -1,21 +0,0 @@
1
- <h1>New oauth_client</h1>
2
-
3
- <!-- add in an ID for the form -->
4
-
5
- <% form_for(@oauth_client, :html => {:id => 'oauth_client_create_form', :class => nil}) do |f| %>
6
- <%= f.error_messages %>
7
-
8
- <div>
9
- <%= f.label :name %>
10
- <%= f.text_field :name %>
11
- </div>
12
- <div>
13
- <%= f.label :redirect_uri %>
14
- <%= f.text_field :redirect_uri %>
15
- </div>
16
- <div>
17
- <%= f.submit 'Create' %>
18
- </div>
19
- <% end %>
20
-
21
- <%= link_to 'Back', oauth_clients_path, :class => 'back_link' %>
@@ -1,14 +0,0 @@
1
- <table id="oauth_user_token_table" class="list_table">
2
- <tr>
3
- <th>Client</th>
4
- <th>Token</th>
5
- <th>&nbsp;</th>
6
- </tr>
7
- <% @tokens.each do |token| -%>
8
- <tr>
9
- <td><%= token.oauth_client.name %></td>
10
- <td><%= token.access_token %></td>
11
- <td><%= link_to('Destroy', {:action => :revoke, :token_id => token.id, :controller => 'Oauth2::Provider::OauthUserTokens'}, {:confirm => 'Are you sure?', :method => :delete, :class => 'delete_link'})%></td>
12
- </tr>
13
- <% end -%>
14
- </table>
@@ -1,88 +0,0 @@
1
- # Copyright (c) 2010 ThoughtWorks Inc. (http://thoughtworks.com)
2
- # Licenced under the MIT License (http://www.opensource.org/licenses/mit-license.php)
3
-
4
- require 'rubygems'
5
- require 'rake/gempackagetask'
6
-
7
- namespace :release do
8
-
9
- desc 'Update the changelog'
10
- task :changelog do
11
- File.open(File.join(File.dirname(__FILE__), '..', 'CHANGELOG'), 'w+') do |changelog|
12
- `git log -z --abbrev-commit vendor/plugins/oauth2_provider`.split("\0").each do |commit|
13
- next if commit =~ /^Merge: \d*/
14
- ref, author, time, _, title, _, message = commit.split("\n", 7)
15
- ref = ref[/commit ([0-9a-f]+)/, 1]
16
- author = author[/Author: (.*)/, 1].strip
17
- time = Time.parse(time[/Date: (.*)/, 1]).utc
18
- title.strip!
19
-
20
- changelog.puts "[#{ref} | #{time}] #{author}"
21
- changelog.puts '', " * #{title}"
22
- changelog.puts '', message.rstrip if message
23
- changelog.puts
24
- end
25
- end
26
- end
27
-
28
- desc 'Create the oauth2_provider gem'
29
- task :gem => :changelog do
30
- Rake::Task[:copyright].invoke
31
- cd File.join(File.expand_path(File.dirname(__FILE__)), '..') do
32
-
33
- cp "#{RAILS_ROOT}/../README.textile", '.', :verbose => false
34
- cp "#{RAILS_ROOT}/../MIT-LICENSE.txt", '.', :verbose => false
35
-
36
- spec = Gem::Specification.new do |s|
37
- s.name = "oauth2_provider"
38
- s.version = "0.2.0"
39
- s.author = "ThoughtWorks, Inc."
40
- s.email = "ketan@thoughtworks.com"
41
- s.homepage = "http://github.com/ThoughtWorksStudios/oauth2_provider"
42
- s.platform = Gem::Platform::RUBY
43
- s.summary = "A Rails plugin to OAuth v2.0 enable your rails application"
44
- s.description = "A Rails plugin to OAuth v2.0 enable your rails application. This plugin implements v09 of the OAuth2 draft spec http://tools.ietf.org/html/draft-ietf-oauth-v2-09."
45
- s.files = Dir["**/*.*"] + ["#{s.name}.gemspec", "README.textile", "CHANGELOG"]
46
- s.has_rdoc = false
47
- s.extra_rdoc_files = ["README.textile", "MIT-LICENSE.txt"]
48
- end
49
-
50
- File.open("#{spec.name}.gemspec", "w") { |f| f << spec.to_ruby }
51
-
52
- sh "gem build #{spec.name}.gemspec"
53
-
54
- # move it into a proper directory
55
- rm_rf "#{RAILS_ROOT}/pkg", :verbose => false
56
- mkdir "#{RAILS_ROOT}/pkg", :verbose => false
57
- mv "#{spec.name}-#{spec.version}.gem", "#{RAILS_ROOT}/pkg", :verbose => false
58
-
59
- #cleanup
60
- rm "README.textile", :verbose => false
61
- rm "MIT-LICENSE.txt", :verbose => false
62
- end
63
- end
64
-
65
- desc 'Push the gem out to gemcutter'
66
- task :push => [:test, :gem] do
67
-
68
- puts <<-INSTRUCTIONS
69
-
70
- ==============================================================
71
- Instructions before you push out:
72
- * Make sure everything is good
73
- * Bump the version number in the `gem.rake' file
74
- * Check in
75
- * Run this task again to:
76
- * verify everything is good
77
- * generate a new gem with the new version number
78
- * Create a tag in git:
79
- $ git tag -a -m 'Tag for version X.Y.Z' 'vX.Y.Z'
80
- $ gem push pkg/oauth2_provider-X.Y.Z.gem
81
- ==============================================================
82
- INSTRUCTIONS
83
- # sh("gem push pkg/*.gem") do |res, ok|
84
- # raise 'Could not push gem' if !ok
85
- # end
86
- end
87
-
88
- end