doorkeeper.rb 5.1 KB

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