You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
4.8 KiB

  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. current_user || redirect_to(new_user_session_url)
  7. end
  8. resource_owner_from_credentials do |routes|
  9. request.params[:user] = { email: request.params[:username], password: request.params[:password] }
  10. request.env["devise.allow_params_authentication"] = true
  11. request.env["warden"].authenticate!(scope: :user)
  12. end
  13. # If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
  14. admin_authenticator do
  15. current_user || redirect_to(new_user_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 nil
  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. # Reuse access token for the same resource owner within an application (disabled by default)
  30. # Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
  31. # reuse_access_token
  32. # Issue access tokens with refresh token (disabled by default)
  33. # use_refresh_token
  34. # Provide support for an owner to be assigned to each registered application (disabled by default)
  35. # Optional parameter :confirmation => true (default false) if you want to enforce ownership of
  36. # a registered application
  37. # Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
  38. enable_application_owner :confirmation => true
  39. # Define access token scopes for your provider
  40. # For more information go to
  41. # https://github.com/doorkeeper-gem/doorkeeper/wiki/Using-Scopes
  42. # default_scopes :public
  43. # optional_scopes :write, :follow
  44. # Change the way client credentials are retrieved from the request object.
  45. # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
  46. # falls back to the `:client_id` and `:client_secret` params from the `params` object.
  47. # Check out the wiki for more information on customization
  48. # client_credentials :from_basic, :from_params
  49. # Change the way access token is authenticated from the request object.
  50. # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
  51. # falls back to the `:access_token` or `:bearer_token` params from the `params` object.
  52. # Check out the wiki for more information on customization
  53. # access_token_methods :from_bearer_authorization, :from_access_token_param, :from_bearer_param
  54. # Change the native redirect uri for client apps
  55. # 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
  56. # The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
  57. # (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)
  58. #
  59. # native_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
  60. # Forces the usage of the HTTPS protocol in non-native redirect uris (enabled
  61. # by default in non-development environments). OAuth2 delegates security in
  62. # communication to the HTTPS protocol so it is wise to keep this enabled.
  63. #
  64. # force_ssl_in_redirect_uri !Rails.env.development?
  65. # Specify what grant flows are enabled in array of Strings. The valid
  66. # strings and the flows they enable are:
  67. #
  68. # "authorization_code" => Authorization Code Grant Flow
  69. # "implicit" => Implicit Grant Flow
  70. # "password" => Resource Owner Password Credentials Grant Flow
  71. # "client_credentials" => Client Credentials Grant Flow
  72. #
  73. # If not specified, Doorkeeper enables authorization_code and
  74. # client_credentials.
  75. #
  76. # implicit and password grant flows have risks that you should understand
  77. # before enabling:
  78. # http://tools.ietf.org/html/rfc6819#section-4.4.2
  79. # http://tools.ietf.org/html/rfc6819#section-4.4.3
  80. #
  81. grant_flows %w(authorization_code password client_credentials)
  82. # Under some circumstances you might want to have applications auto-approved,
  83. # so that the user skips the authorization step.
  84. # For example if dealing with a trusted application.
  85. skip_authorization do |resource_owner, client|
  86. client.superapp?
  87. end
  88. # WWW-Authenticate Realm (default "Doorkeeper").
  89. # realm "Doorkeeper"
  90. end