doorkeeper.rb 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. Doorkeeper.configure do
  2. # Change the ORM that doorkeeper will use (needs plugins)
  3. orm :active_record
  4. # This block will be called to check whether the resource owner is authenticated or not.
  5. resource_owner_authenticator do
  6. # fail "Please configure doorkeeper resource_owner_authenticator block located in #{__FILE__}"
  7. # Put your resource owner authentication logic here.
  8. # Example implementation:
  9. User.find_by_id(session[:user_id]) || redirect_to(new_user_session_url)
  10. end
  11. # If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
  12. # admin_authenticator do
  13. # # Put your admin authentication logic here.
  14. # # Example implementation:
  15. # Admin.find_by_id(session[:admin_id]) || redirect_to(new_admin_session_url)
  16. # end
  17. # Authorization Code expiration time (default 10 minutes).
  18. # authorization_code_expires_in 10.minutes
  19. # Access token expiration time (default 2 hours).
  20. # If you want to disable expiration, set this to nil.
  21. # access_token_expires_in 2.hours
  22. # Assign a custom TTL for implicit grants.
  23. # custom_access_token_expires_in do |oauth_client|
  24. # oauth_client.application.additional_settings.implicit_oauth_expiration
  25. # end
  26. # Use a custom class for generating the access token.
  27. # https://github.com/doorkeeper-gem/doorkeeper#custom-access-token-generator
  28. # access_token_generator '::Doorkeeper::JWT'
  29. # The controller Doorkeeper::ApplicationController inherits from.
  30. # Defaults to ActionController::Base.
  31. # https://github.com/doorkeeper-gem/doorkeeper#custom-base-controller
  32. # base_controller 'ApplicationController'
  33. # Reuse access token for the same resource owner within an application (disabled by default)
  34. # Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
  35. # reuse_access_token
  36. # Issue access tokens with refresh token (disabled by default)
  37. use_refresh_token
  38. # Provide support for an owner to be assigned to each registered application (disabled by default)
  39. # Optional parameter confirmation: true (default false) if you want to enforce ownership of
  40. # a registered application
  41. # Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
  42. # enable_application_owner confirmation: false
  43. # Define access token scopes for your provider
  44. # For more information go to
  45. # https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes
  46. # default_scopes :public
  47. # optional_scopes :write, :update
  48. # Change the way client credentials are retrieved from the request object.
  49. # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
  50. # falls back to the `:client_id` and `:client_secret` params from the `params` object.
  51. # Check out the wiki for more information on customization
  52. # client_credentials :from_basic, :from_params
  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. # Change the native redirect uri for client apps
  59. # 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
  60. # The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
  61. # (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)
  62. #
  63. # native_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
  64. # Forces the usage of the HTTPS protocol in non-native redirect uris (enabled
  65. # by default in non-development environments). OAuth2 delegates security in
  66. # communication to the HTTPS protocol so it is wise to keep this enabled.
  67. #
  68. # force_ssl_in_redirect_uri !Rails.env.development?
  69. # Specify what grant flows are enabled in array of Strings. The valid
  70. # strings and the flows they enable are:
  71. #
  72. # "authorization_code" => Authorization Code Grant Flow
  73. # "implicit" => Implicit Grant Flow
  74. # "password" => Resource Owner Password Credentials Grant Flow
  75. # "client_credentials" => Client Credentials Grant Flow
  76. #
  77. # If not specified, Doorkeeper enables authorization_code and
  78. # client_credentials.
  79. #
  80. # implicit and password grant flows have risks that you should understand
  81. # before enabling:
  82. # http://tools.ietf.org/html/rfc6819#section-4.4.2
  83. # http://tools.ietf.org/html/rfc6819#section-4.4.3
  84. #
  85. # grant_flows %w(authorization_code client_credentials)
  86. # Under some circumstances you might want to have applications auto-approved,
  87. # so that the user skips the authorization step.
  88. # For example if dealing with a trusted application.
  89. # skip_authorization do |resource_owner, client|
  90. # client.superapp? or resource_owner.admin?
  91. # end
  92. # WWW-Authenticate Realm (default "Doorkeeper").
  93. # realm "Doorkeeper"
  94. end