doorkeeper-openid_connect 1.0.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 (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +10 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +90 -0
  7. data/Rakefile +7 -0
  8. data/app/controllers/doorkeeper/openid_connect/userinfo_controller.rb +19 -0
  9. data/config/locales/en.yml +20 -0
  10. data/doorkeeper-openid_connect.gemspec +27 -0
  11. data/lib/doorkeeper/openid_connect.rb +65 -0
  12. data/lib/doorkeeper/openid_connect/claims_builder.rb +24 -0
  13. data/lib/doorkeeper/openid_connect/config.rb +125 -0
  14. data/lib/doorkeeper/openid_connect/engine.rb +9 -0
  15. data/lib/doorkeeper/openid_connect/models/claims/aggregated_claim.rb +11 -0
  16. data/lib/doorkeeper/openid_connect/models/claims/claim.rb +15 -0
  17. data/lib/doorkeeper/openid_connect/models/claims/distributed_claim.rb +11 -0
  18. data/lib/doorkeeper/openid_connect/models/claims/normal_claim.rb +28 -0
  19. data/lib/doorkeeper/openid_connect/models/id_token.rb +63 -0
  20. data/lib/doorkeeper/openid_connect/models/user_info.rb +39 -0
  21. data/lib/doorkeeper/openid_connect/rails/routes.rb +50 -0
  22. data/lib/doorkeeper/openid_connect/rails/routes/mapper.rb +30 -0
  23. data/lib/doorkeeper/openid_connect/rails/routes/mapping.rb +34 -0
  24. data/lib/doorkeeper/openid_connect/version.rb +5 -0
  25. data/spec/dummy/Rakefile +7 -0
  26. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  27. data/spec/dummy/app/controllers/custom_authorizations_controller.rb +7 -0
  28. data/spec/dummy/app/controllers/full_protected_resources_controller.rb +12 -0
  29. data/spec/dummy/app/controllers/home_controller.rb +17 -0
  30. data/spec/dummy/app/controllers/metal_controller.rb +11 -0
  31. data/spec/dummy/app/controllers/semi_protected_resources_controller.rb +11 -0
  32. data/spec/dummy/app/helpers/application_helper.rb +5 -0
  33. data/spec/dummy/app/models/user.rb +31 -0
  34. data/spec/dummy/app/views/home/index.html.erb +0 -0
  35. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  36. data/spec/dummy/config.ru +4 -0
  37. data/spec/dummy/config/application.rb +55 -0
  38. data/spec/dummy/config/boot.rb +6 -0
  39. data/spec/dummy/config/database.yml +15 -0
  40. data/spec/dummy/config/environment.rb +5 -0
  41. data/spec/dummy/config/environments/development.rb +29 -0
  42. data/spec/dummy/config/environments/production.rb +62 -0
  43. data/spec/dummy/config/environments/test.rb +56 -0
  44. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  45. data/spec/dummy/config/initializers/doorkeeper.rb +59 -0
  46. data/spec/dummy/config/initializers/secret_token.rb +9 -0
  47. data/spec/dummy/config/initializers/session_store.rb +8 -0
  48. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  49. data/spec/dummy/config/locales/doorkeeper.en.yml +5 -0
  50. data/spec/dummy/config/mongo.yml +11 -0
  51. data/spec/dummy/config/mongoid2.yml +9 -0
  52. data/spec/dummy/config/mongoid3.yml +18 -0
  53. data/spec/dummy/config/mongoid4.yml +19 -0
  54. data/spec/dummy/config/routes.rb +52 -0
  55. data/spec/dummy/db/migrate/20111122132257_create_users.rb +9 -0
  56. data/spec/dummy/db/migrate/20120312140401_add_password_to_users.rb +5 -0
  57. data/spec/dummy/db/migrate/20130902165751_create_doorkeeper_tables.rb +41 -0
  58. data/spec/dummy/db/migrate/20130902175349_add_owner_to_application.rb +7 -0
  59. data/spec/dummy/db/schema.rb +65 -0
  60. data/spec/dummy/log/test.log +16605 -0
  61. data/spec/dummy/public/404.html +26 -0
  62. data/spec/dummy/public/422.html +26 -0
  63. data/spec/dummy/public/500.html +26 -0
  64. data/spec/dummy/public/favicon.ico +0 -0
  65. data/spec/dummy/script/rails +6 -0
  66. data/spec/lib/doorkeeper/openid_connect/config_spec.rb +65 -0
  67. data/spec/spec_helper.rb +2 -0
  68. data/spec/spec_helper_integration.rb +48 -0
  69. metadata +239 -0
@@ -0,0 +1,4 @@
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
@@ -0,0 +1,55 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'action_controller/railtie'
4
+ require 'active_support/core_ext/numeric'
5
+ require 'sprockets/railtie'
6
+
7
+ Bundler.require :default
8
+
9
+ # orm = if [:mongoid2, :mongoid3, :mongoid4].include?(DOORKEEPER_ORM)
10
+ # Mongoid.load!(File.join(File.dirname(File.expand_path(__FILE__)), "#{DOORKEEPER_ORM}.yml"))
11
+ # :mongoid
12
+ # else
13
+ # DOORKEEPER_ORM
14
+ # end
15
+ #
16
+ # require "#{orm}/railtie"
17
+
18
+ module Dummy
19
+ class Application < Rails::Application
20
+ # Settings in config/environments/* take precedence over those specified here.
21
+ # Application configuration should go into files in config/initializers
22
+ # -- all .rb files in that directory are automatically loaded.
23
+
24
+ # Only load the plugins named here, in the order given (default is alphabetical).
25
+ # :all can be used as a placeholder for all plugins not explicitly named.
26
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
27
+
28
+ # Activate observers that should always be running.
29
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
30
+
31
+ # if defined?(ActiveRecord) && Rails.version.to_i < 4
32
+ # config.active_record.whitelist_attributes = true
33
+ # end
34
+
35
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
36
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
37
+ # config.time_zone = 'Central Time (US & Canada)'
38
+
39
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
40
+ config.i18n.load_path += Dir[Rails.root.join('../../', 'config/locales', '*.{rb,yml}').to_s]
41
+ # config.i18n.default_locale = :en
42
+
43
+ # Configure the default encoding used in templates for Ruby 1.9.
44
+ config.encoding = 'utf-8'
45
+
46
+ # Configure sensitive parameters which will be filtered from the log file.
47
+ config.filter_parameters += [:password]
48
+
49
+ # Enable the asset pipeline
50
+ config.assets.enabled = true
51
+
52
+ # Version of your assets, change this if you want to expire all your assets
53
+ config.assets.version = '1.0'
54
+ end
55
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ DOORKEEPER_ORM = (ENV['orm'] || :active_record).to_sym unless defined?(DOORKEEPER_ORM)
5
+
6
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,62 @@
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
@@ -0,0 +1,56 @@
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
+ # Configure static asset server for tests with Cache-Control for performance
11
+ config.serve_static_assets = true
12
+ config.static_cache_control = 'public, max-age=3600'
13
+
14
+ if Rails.version.to_i < 4
15
+ # Log error messages when you accidentally call methods on nil
16
+ config.whiny_nils = true
17
+ end
18
+
19
+ if Rails.version.to_i >= 4
20
+ # Do not eager load code on boot. This avoids loading your whole application
21
+ # just for the purpose of running a single test. If you are using a tool that
22
+ # preloads Rails for running tests, you may have to set it to true.
23
+ config.eager_load = false
24
+ config.i18n.enforce_available_locales = true
25
+ end
26
+
27
+ # Show full error reports and disable caching
28
+ config.consider_all_requests_local = true
29
+ config.action_controller.perform_caching = false
30
+
31
+ # Raise exceptions instead of rendering exception templates
32
+ config.action_dispatch.show_exceptions = false
33
+
34
+ # Disable request forgery protection in test environment
35
+ config.action_controller.allow_forgery_protection = false
36
+
37
+ # Tell Action Mailer not to deliver emails to the real world.
38
+ # The :test delivery method accumulates sent emails in the
39
+ # ActionMailer::Base.deliveries array.
40
+ # config.action_mailer.delivery_method = :test
41
+
42
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
43
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
44
+ # like if you have constraints or database-specific column types
45
+ # config.active_record.schema_format = :sql
46
+
47
+ # Print deprecation notices to the stderr
48
+ config.active_support.deprecation = :stderr
49
+
50
+ config.eager_load = true
51
+
52
+ # if DOORKEEPER_ORM == :active_record
53
+ # config.active_record.table_name_prefix = TABLE_NAME_PREFIX.to_s
54
+ # config.active_record.table_name_suffix = TABLE_NAME_SUFFIX.to_s
55
+ # end
56
+ end
@@ -0,0 +1,7 @@
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!
@@ -0,0 +1,59 @@
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 DOORKEEPER_ORM
5
+ #
6
+ # # This block will be called to check whether the
7
+ # # resource owner is authenticated or not
8
+ # resource_owner_authenticator do
9
+ # # Put your resource owner authentication logic here.
10
+ # # e.g. User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
11
+ # User.where(id: session[:user_id]).first || redirect_to(root_url, alert: 'Needs sign in.')
12
+ # end
13
+ #
14
+ # # If you want to restrict the access to the web interface for
15
+ # # adding oauth authorized applications you need to declare the
16
+ # # block below
17
+ # # admin_authenticator do
18
+ # # # Put your admin authentication logic here.
19
+ # # Admin.find_by_id(session[:admin_id]) || redirect_to(new_admin_session_url)
20
+ # # end
21
+ #
22
+ # # Authorization Code expiration time (default 10 minutes).
23
+ # # access_token_expires_in 10.minutes
24
+ #
25
+ # # Access token expiration time (default 2 hours)
26
+ # # If you want to disable expiration, set this to nil.
27
+ # # access_token_expires_in 2.hours
28
+ #
29
+ # # Issue access tokens with refresh token (disabled by default)
30
+ # use_refresh_token
31
+ #
32
+ # # Define access token scopes for your provider
33
+ # # For more information go to
34
+ # # https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes
35
+ # default_scopes :public
36
+ # optional_scopes :write, :update
37
+ #
38
+ # # Change the way client credentials are retrieved from the request object.
39
+ # # By default it retrieves first from `HTTP_AUTHORIZATION` header and
40
+ # # fallsback to `:client_id` and `:client_secret` from `params` object
41
+ # # Check out the wiki for mor information on customization
42
+ # # client_credentials :from_basic, :from_params
43
+ #
44
+ # # Change the way access token is authenticated from the request object.
45
+ # # By default it retrieves first from `HTTP_AUTHORIZATION` header and
46
+ # # fallsback to `:access_token` or `:bearer_token` from `params` object
47
+ # # Check out the wiki for mor information on customization
48
+ # # access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
49
+ #
50
+ # # Change the native redirect uri for client apps
51
+ # # 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
52
+ # # The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
53
+ # # (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)
54
+ # #
55
+ # # native_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
56
+ #
57
+ # # WWW-Authenticate Realm (default 'Doorkeeper').
58
+ # realm 'Doorkeeper'
59
+ # end
@@ -0,0 +1,9 @@
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
+ Dummy::Application.config.secret_key_base =
8
+ Dummy::Application.config.secret_token =
9
+ 'c00157b5a1bb6181792f0f4a8a080485de7bab9987e6cf159dc74c4f0573345c1bfa713b5d756e1491fc0b098567e8a619e2f8d268eda86a20a720d05d633780'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_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
+ # Dummy::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,5 @@
1
+ en:
2
+ doorkeeper:
3
+ scopes:
4
+ public: "Access your public data"
5
+ write: "Update your data"
@@ -0,0 +1,11 @@
1
+ defaults: &defaults
2
+ host: 127.0.0.1
3
+ port: 27017
4
+
5
+ development:
6
+ <<: *defaults
7
+ database: doorkeeper-mongomapper-development
8
+
9
+ test:
10
+ <<: *defaults
11
+ database: doorkeeper-mongomapper-test-suite
@@ -0,0 +1,9 @@
1
+ development:
2
+ database: doorkeeper-development
3
+ persist_in_safe_mode: true
4
+ autocreate_indexes: true
5
+
6
+ test:
7
+ database: doorkeeper-mongoid2-test
8
+ persist_in_safe_mode: true
9
+ autocreate_indexes: true
@@ -0,0 +1,18 @@
1
+ development:
2
+ sessions:
3
+ default:
4
+ database: doorkeeper-mongoid3-development
5
+ hosts:
6
+ - localhost:27017
7
+ options:
8
+ consistency: :strong
9
+ safe: true
10
+ test:
11
+ sessions:
12
+ default:
13
+ database: doorkeeper-mongoid3-test
14
+ hosts:
15
+ - localhost:27017
16
+ options:
17
+ consistency: :strong
18
+ safe: true
@@ -0,0 +1,19 @@
1
+ development:
2
+ sessions:
3
+ default:
4
+ database: doorkeeper-mongoid4-development
5
+ hosts:
6
+ - localhost:27017
7
+ options:
8
+ write:
9
+ w: 1
10
+
11
+ test:
12
+ sessions:
13
+ default:
14
+ database: doorkeeper-mongoid4-test
15
+ hosts:
16
+ - localhost:27017
17
+ options:
18
+ write:
19
+ w: 1
@@ -0,0 +1,52 @@
1
+ Rails.application.routes.draw do
2
+ use_doorkeeper
3
+ use_doorkeeper scope: 'scope'
4
+
5
+ scope 'inner_space' do
6
+ use_doorkeeper scope: 'scope' do
7
+ controllers authorizations: 'custom_authorizations',
8
+ tokens: 'custom_authorizations',
9
+ applications: 'custom_authorizations',
10
+ token_info: 'custom_authorizations'
11
+
12
+ as authorizations: 'custom_auth',
13
+ tokens: 'custom_token',
14
+ token_info: 'custom_token_info'
15
+ end
16
+ end
17
+
18
+ scope 'space' do
19
+ use_doorkeeper do
20
+ controllers authorizations: 'custom_authorizations',
21
+ tokens: 'custom_authorizations',
22
+ applications: 'custom_authorizations',
23
+ token_info: 'custom_authorizations'
24
+
25
+ as authorizations: 'custom_auth',
26
+ tokens: 'custom_token',
27
+ token_info: 'custom_token_info'
28
+ end
29
+ end
30
+
31
+ scope 'outer_space' do
32
+ use_doorkeeper do
33
+ controllers authorizations: 'custom_authorizations',
34
+ tokens: 'custom_authorizations',
35
+ token_info: 'custom_authorizations'
36
+
37
+ as authorizations: 'custom_auth',
38
+ tokens: 'custom_token',
39
+ token_info: 'custom_token_info'
40
+
41
+ skip_controllers :tokens, :applications, :token_info
42
+ end
43
+ end
44
+
45
+ get 'metal.json' => 'metal#index'
46
+
47
+ get '/callback', to: 'home#callback'
48
+ get '/sign_in', to: 'home#sign_in'
49
+ resources :semi_protected_resources
50
+ resources :full_protected_resources
51
+ root to: 'home#index'
52
+ end