doorkeeper-grants_assertion 0.1.0 → 0.2.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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.travis.yml +1 -6
  4. data/Gemfile +6 -9
  5. data/README.md +71 -2
  6. data/Rakefile +8 -6
  7. data/doorkeeper-grants_assertion.gemspec +27 -8
  8. data/gemfiles/rails_4_2.gemfile +0 -3
  9. data/gemfiles/rails_4_2.gemfile.lock +68 -17
  10. data/gemfiles/rails_5_0.gemfile +0 -3
  11. data/gemfiles/rails_5_0.gemfile.lock +68 -17
  12. data/gemfiles/rails_latest_and_doorkeeper_latest.gemfile +0 -3
  13. data/gemfiles/rails_latest_and_doorkeeper_latest.gemfile.lock +68 -17
  14. data/lib/doorkeeper/grants_assertion.rb +5 -0
  15. data/lib/doorkeeper/grants_assertion/devise/omniauth.rb +33 -0
  16. data/lib/doorkeeper/grants_assertion/omniauth.rb +35 -0
  17. data/lib/doorkeeper/grants_assertion/railtie.rb +6 -0
  18. data/lib/doorkeeper/grants_assertion/version.rb +7 -0
  19. data/lib/doorkeeper/request/assertion.rb +2 -0
  20. metadata +115 -58
  21. data/spec/dummy/Rakefile +0 -7
  22. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  23. data/spec/dummy/app/controllers/custom_authorizations_controller.rb +0 -7
  24. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +0 -11
  25. data/spec/dummy/app/controllers/home_controller.rb +0 -17
  26. data/spec/dummy/app/controllers/metal_controller.rb +0 -11
  27. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +0 -11
  28. data/spec/dummy/app/helpers/application_helper.rb +0 -5
  29. data/spec/dummy/app/models/user.rb +0 -9
  30. data/spec/dummy/app/views/home/index.html.erb +0 -0
  31. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  32. data/spec/dummy/config.ru +0 -4
  33. data/spec/dummy/config/application.rb +0 -47
  34. data/spec/dummy/config/boot.rb +0 -4
  35. data/spec/dummy/config/database.yml +0 -15
  36. data/spec/dummy/config/environment.rb +0 -5
  37. data/spec/dummy/config/environments/development.rb +0 -29
  38. data/spec/dummy/config/environments/production.rb +0 -62
  39. data/spec/dummy/config/environments/test.rb +0 -53
  40. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  41. data/spec/dummy/config/initializers/doorkeeper.rb +0 -92
  42. data/spec/dummy/config/initializers/secret_token.rb +0 -9
  43. data/spec/dummy/config/initializers/session_store.rb +0 -8
  44. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  45. data/spec/dummy/config/locales/doorkeeper.en.yml +0 -74
  46. data/spec/dummy/config/routes.rb +0 -52
  47. data/spec/dummy/db/migrate/20111122132257_create_users.rb +0 -10
  48. data/spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb +0 -41
  49. data/spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb +0 -7
  50. data/spec/dummy/db/schema.rb +0 -66
  51. data/spec/dummy/script/rails +0 -6
  52. data/spec/factories/access_grant.rb +0 -9
  53. data/spec/factories/access_token.rb +0 -11
  54. data/spec/factories/application.rb +0 -6
  55. data/spec/requests/flows/assertion_spec.rb +0 -127
  56. data/spec/spec_helper.rb +0 -2
  57. data/spec/spec_helper_integration.rb +0 -28
  58. data/spec/support/dependencies/factory_girl.rb +0 -2
  59. data/spec/support/helpers/config_helper.rb +0 -9
  60. data/spec/support/helpers/model_helper.rb +0 -45
  61. data/spec/support/helpers/request_spec_helper.rb +0 -76
  62. data/spec/support/helpers/url_helper.rb +0 -19
  63. data/spec/support/shared/controllers_shared_context.rb +0 -60
  64. data/spec/support/shared/models_shared_examples.rb +0 -52
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env rake
2
- # Add your own tasks in files placed in lib/tasks ending in .rake,
3
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
-
5
- require File.expand_path('../config/application', __FILE__)
6
-
7
- Dummy::Application.load_tasks
@@ -1,3 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
- end
@@ -1,7 +0,0 @@
1
- class CustomAuthorizationsController < ::ApplicationController
2
- %w(index show new create edit update destroy).each do |action|
3
- define_method action do
4
- render nothing: true
5
- end
6
- end
7
- end
@@ -1,11 +0,0 @@
1
- class FullProtectedResourcesController < ApplicationController
2
- before_action :doorkeeper_authorize!
3
-
4
- def index
5
- render text: 'index'
6
- end
7
-
8
- def show
9
- render text: 'show'
10
- end
11
- end
@@ -1,17 +0,0 @@
1
- class HomeController < ApplicationController
2
- def index
3
- end
4
-
5
- def sign_in
6
- session[:user_id] = if Rails.env.development?
7
- User.first || User.create!(name: 'Joe', password: 'sekret')
8
- else
9
- User.first
10
- end
11
- redirect_to '/'
12
- end
13
-
14
- def callback
15
- render text: 'ok'
16
- end
17
- end
@@ -1,11 +0,0 @@
1
- class MetalController < ActionController::Metal
2
- include AbstractController::Callbacks
3
- include ActionController::Head
4
- include Doorkeeper::Helpers::Controller
5
-
6
- before_action :doorkeeper_authorize!
7
-
8
- def index
9
- self.response_body = { ok: true }.to_json
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- class SemiProtectedResourcesController < ApplicationController
2
- before_action :doorkeeper_authorize!, only: [:index]
3
-
4
- def index
5
- render text: 'protected index'
6
- end
7
-
8
- def show
9
- render text: 'protected show'
10
- end
11
- end
@@ -1,5 +0,0 @@
1
- module ApplicationHelper
2
- def current_user
3
- @current_user ||= User.find_by_id(session[:user_id])
4
- end
5
- end
@@ -1,9 +0,0 @@
1
- class User < ActiveRecord::Base
2
- if ::Rails.version.to_i < 4
3
- attr_accessible :name, :password, :assertion
4
- end
5
-
6
- def self.authenticate!(name, password)
7
- User.where(name: name, password: password).first
8
- end
9
- end
File without changes
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= csrf_meta_tags %>
6
- </head>
7
- <body>
8
-
9
- <%= link_to "Sign in", '/sign_in' %>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Dummy::Application
@@ -1,47 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'action_controller/railtie'
4
- require 'sprockets/railtie'
5
-
6
- Bundler.require :default
7
-
8
- require "active_record/railtie"
9
-
10
- module Dummy
11
- class Application < Rails::Application
12
- # Settings in config/environments/* take precedence over those specified here.
13
- # Application configuration should go into files in config/initializers
14
- # -- all .rb files in that directory are automatically loaded.
15
-
16
- # Only load the plugins named here, in the order given (default is alphabetical).
17
- # :all can be used as a placeholder for all plugins not explicitly named.
18
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
19
-
20
- # Activate observers that should always be running.
21
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
22
-
23
- if defined?(ActiveRecord) && Rails.version.to_i < 4
24
- config.active_record.whitelist_attributes = true
25
- end
26
-
27
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
28
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
29
- # config.time_zone = 'Central Time (US & Canada)'
30
-
31
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
32
- config.i18n.load_path += Dir[Rails.root.join('../../', 'config/locales', '*.{rb,yml}').to_s]
33
- # config.i18n.default_locale = :en
34
-
35
- # Configure the default encoding used in templates for Ruby 1.9.
36
- config.encoding = 'utf-8'
37
-
38
- # Configure sensitive parameters which will be filtered from the log file.
39
- config.filter_parameters += [:password]
40
-
41
- # Enable the asset pipeline
42
- config.assets.enabled = true
43
-
44
- # Version of your assets, change this if you want to expire all your assets
45
- config.assets.version = '1.0'
46
- end
47
- end
@@ -1,4 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
-
4
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,15 +0,0 @@
1
- development:
2
- adapter: sqlite3
3
- database: db/development.sqlite3
4
- pool: 5
5
- timeout: 5000
6
-
7
- test:
8
- adapter: sqlite3
9
- database: ":memory:"
10
- timeout: 500
11
-
12
- production:
13
- adapter: sqlite3
14
- database: ":memory:"
15
- timeout: 500
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Dummy::Application.initialize!
@@ -1,29 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Show full error reports and disable caching
10
- config.consider_all_requests_local = true
11
- config.action_controller.perform_caching = false
12
-
13
- # Don't care if the mailer can't send
14
- # config.action_mailer.raise_delivery_errors = false
15
-
16
- # Print deprecation notices to the Rails logger
17
- config.active_support.deprecation = :log
18
-
19
- # Only use best-standards-support built into browsers
20
- config.action_dispatch.best_standards_support = :builtin
21
-
22
- # Do not compress assets
23
- config.assets.compress = false
24
-
25
- # Expands the lines which load the assets
26
- config.assets.debug = true
27
-
28
- config.eager_load = false
29
- end
@@ -1,62 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # Code is not reloaded between requests
5
- config.cache_classes = true
6
-
7
- # Full error reports are disabled and caching is turned on
8
- config.consider_all_requests_local = false
9
- config.action_controller.perform_caching = true
10
-
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
13
-
14
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
16
-
17
- # Don't fallback to assets pipeline if a precompiled asset is missed
18
- config.assets.compile = false
19
-
20
- # Generate digests for assets URLs
21
- config.assets.digest = true
22
-
23
- # Defaults to Rails.root.join("public/assets")
24
- # config.assets.manifest = YOUR_PATH
25
-
26
- # Specifies the header that your server uses for sending files
27
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
-
30
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
- # config.force_ssl = true
32
-
33
- # See everything in the log (default is :info)
34
- # config.log_level = :debug
35
-
36
- # Use a different logger for distributed setups
37
- # config.logger = SyslogLogger.new
38
-
39
- # Use a different cache store in production
40
- # config.cache_store = :mem_cache_store
41
-
42
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
- # config.action_controller.asset_host = "http://assets.example.com"
44
-
45
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
- # config.assets.precompile += %w( search.js )
47
-
48
- # Disable delivery errors, bad email addresses will be ignored
49
- # config.action_mailer.raise_delivery_errors = false
50
-
51
- # Enable threaded mode
52
- # config.threadsafe!
53
-
54
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
- # the I18n.default_locale when a translation can not be found)
56
- config.i18n.fallbacks = true
57
-
58
- # Send deprecation notices to registered listeners
59
- config.active_support.deprecation = :notify
60
-
61
- config.eager_load = true
62
- end
@@ -1,53 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- if Rails.version.to_i < 5
11
- # Configure static asset server for tests with Cache-Control for performance
12
- config.serve_static_files = true
13
- config.static_cache_control = 'public, max-age=3600'
14
- end
15
-
16
- if Rails.version.to_i < 4
17
- # Log error messages when you accidentally call methods on nil
18
- config.whiny_nils = true
19
- end
20
-
21
- if Rails.version.to_i >= 4
22
- # Do not eager load code on boot. This avoids loading your whole application
23
- # just for the purpose of running a single test. If you are using a tool that
24
- # preloads Rails for running tests, you may have to set it to true.
25
- config.eager_load = false
26
- config.i18n.enforce_available_locales = true
27
- end
28
-
29
- # Show full error reports and disable caching
30
- config.consider_all_requests_local = true
31
- config.action_controller.perform_caching = false
32
-
33
- # Raise exceptions instead of rendering exception templates
34
- config.action_dispatch.show_exceptions = false
35
-
36
- # Disable request forgery protection in test environment
37
- config.action_controller.allow_forgery_protection = false
38
-
39
- # Tell Action Mailer not to deliver emails to the real world.
40
- # The :test delivery method accumulates sent emails in the
41
- # ActionMailer::Base.deliveries array.
42
- # config.action_mailer.delivery_method = :test
43
-
44
- # Use SQL instead of Active Record's schema dumper when creating the test database.
45
- # This is necessary if your schema can't be completely dumped by the schema dumper,
46
- # like if you have constraints or database-specific column types
47
- # config.active_record.schema_format = :sql
48
-
49
- # Print deprecation notices to the stderr
50
- config.active_support.deprecation = :stderr
51
-
52
- config.eager_load = true
53
- end
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
-
6
- # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
- # Rails.backtrace_cleaner.remove_silencers!
@@ -1,92 +0,0 @@
1
- Doorkeeper.configure do
2
- # Change the ORM that doorkeeper will use.
3
- # Currently supported options are :active_record, :mongoid2, :mongoid3, :mongo_mapper
4
- orm :active_record
5
-
6
- # This block will be called to check whether the resource owner is authenticated or not.
7
- resource_owner_authenticator do
8
- # Put your resource owner authentication logic here.
9
- # Example implementation:
10
- # User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
11
- User.find_by_id(session[:user_id]) || redirect_to(root_url, alert: 'Needs sign in.')
12
- end
13
-
14
- # If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
15
- # admin_authenticator do
16
- # # Put your admin authentication logic here.
17
- # # Example implementation:
18
- # Admin.find_by_id(session[:admin_id]) || redirect_to(new_admin_session_url)
19
- # end
20
-
21
- # Authorization Code expiration time (default 10 minutes).
22
- # authorization_code_expires_in 10.minutes
23
-
24
- # Access token expiration time (default 2 hours).
25
- # If you want to disable expiration, set this to nil.
26
- # access_token_expires_in 2.hours
27
-
28
- # Reuse access token for the same resource owner within an application (disabled by default)
29
- # Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
30
- # reuse_access_token
31
-
32
- # Issue access tokens with refresh token (disabled by default)
33
- # use_refresh_token
34
-
35
- # Provide support for an owner to be assigned to each registered application (disabled by default)
36
- # Optional parameter :confirmation => true (default false) if you want to enforce ownership of
37
- # a registered application
38
- # Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
39
- # enable_application_owner :confirmation => false
40
-
41
- # Define access token scopes for your provider
42
- # For more information go to
43
- # https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes
44
- # default_scopes :public
45
- # optional_scopes :write, :update
46
-
47
- # Change the way client credentials are retrieved from the request object.
48
- # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
49
- # falls back to the `:client_id` and `:client_secret` params from the `params` object.
50
- # Check out the wiki for more information on customization
51
- # client_credentials :from_basic, :from_params
52
-
53
- # Change the way access token is authenticated from the request object.
54
- # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
55
- # falls back to the `:access_token` or `:bearer_token` params from the `params` object.
56
- # Check out the wiki for more information on customization
57
- # access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
58
-
59
- # Change the test redirect uri for client apps
60
- # When clients register with the following redirect uri, they won't be redirected to any server and the authorization code will be displayed within the provider
61
- # The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
62
- # (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)
63
- #
64
- # test_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
65
-
66
- # Specify what grant flows are enabled in array of Strings. The valid
67
- # strings and the flows they enable are:
68
- #
69
- # "authorization_code" => Authorization Code Grant Flow
70
- # "implicit" => Implicit Grant Flow
71
- # "password" => Resource Owner Password Credentials Grant Flow
72
- # "client_credentials" => Client Credentials Grant Flow
73
- #
74
- # If not specified, Doorkeeper enables all the four grant flows.
75
- #
76
- grant_flows %w(authorization_code implicit password client_credentials assertion)
77
-
78
- # Under some circumstances you might want to have applications auto-approved,
79
- # so that the user skips the authorization step.
80
- # For example if dealing with trusted a application.
81
- # skip_authorization do |resource_owner, client|
82
- # client.superapp? or resource_owner.admin?
83
- # end
84
-
85
- # WWW-Authenticate Realm (default "Doorkeeper").
86
- # realm "Doorkeeper"
87
-
88
- # Allow dynamic query parameters (disabled by default)
89
- # Some applications require dynamic query parameters on their request_uri
90
- # set to true if you want this to be allowed
91
- # wildcard_redirect_uri false
92
- end