PageRenderTime 23ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/config/initializers/doorkeeper.rb

https://gitlab.com/pedrolab/gitlab-ce
Ruby | 102 lines | 18 code | 17 blank | 67 comment | 1 complexity | 064936e05da9afb170b77f4c2e1c86d9 MD5 | raw file
  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. # This block will be called to check whether the resource owner is authenticated or not.
  6. resource_owner_authenticator do
  7. # Put your resource owner authentication logic here.
  8. # Ensure user is redirected to redirect_uri after login
  9. session[:user_return_to] = request.fullpath
  10. current_user || redirect_to(new_user_session_url)
  11. end
  12. resource_owner_from_credentials do |routes|
  13. Gitlab::Auth.new.find(params[:username], params[:password])
  14. end
  15. # If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
  16. # admin_authenticator do
  17. # # Put your admin authentication logic here.
  18. # # Example implementation:
  19. # Admin.find_by_id(session[:admin_id]) || redirect_to(new_admin_session_url)
  20. # end
  21. # Authorization Code expiration time (default 10 minutes).
  22. # authorization_code_expires_in 10.minutes
  23. # Access token expiration time (default 2 hours).
  24. # If you want to disable expiration, set this to nil.
  25. access_token_expires_in nil
  26. # Reuse access token for the same resource owner within an application (disabled by default)
  27. # Rationale: https://github.com/doorkeeper-gem/doorkeeper/issues/383
  28. # reuse_access_token
  29. # Issue access tokens with refresh token (disabled by default)
  30. use_refresh_token
  31. # Forces the usage of the HTTPS protocol in non-native redirect uris (enabled
  32. # by default in non-development environments). OAuth2 delegates security in
  33. # communication to the HTTPS protocol so it is wise to keep this enabled.
  34. #
  35. force_ssl_in_redirect_uri false
  36. # Provide support for an owner to be assigned to each registered application (disabled by default)
  37. # Optional parameter confirmation: true (default false) if you want to enforce ownership of
  38. # a registered application
  39. # Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
  40. enable_application_owner confirmation: false
  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 :api
  45. #optional_scopes :write, :update
  46. # Change the way client credentials are retrieved from the request object.
  47. # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
  48. # falls back to the `:client_id` and `:client_secret` params from the `params` object.
  49. # Check out the wiki for more information on customization
  50. # client_credentials :from_basic, :from_params
  51. # Change the way access token is authenticated from the request object.
  52. # By default it retrieves first from the `HTTP_AUTHORIZATION` header, then
  53. # falls back to the `:access_token` or `:bearer_token` params from the `params` object.
  54. # Check out the wiki for more information on customization
  55. access_token_methods :from_access_token_param, :from_bearer_authorization, :from_bearer_param
  56. # Change the native redirect uri for client apps
  57. # 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
  58. # The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
  59. # (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)
  60. #
  61. native_redirect_uri nil#'urn:ietf:wg:oauth:2.0:oob'
  62. # Specify what grant flows are enabled in array of Strings. The valid
  63. # strings and the flows they enable are:
  64. #
  65. # "authorization_code" => Authorization Code Grant Flow
  66. # "implicit" => Implicit Grant Flow
  67. # "password" => Resource Owner Password Credentials Grant Flow
  68. # "client_credentials" => Client Credentials Grant Flow
  69. #
  70. # If not specified, Doorkeeper enables all the four grant flows.
  71. #
  72. grant_flows %w(authorization_code password client_credentials)
  73. # Under some circumstances you might want to have applications auto-approved,
  74. # so that the user skips the authorization step.
  75. # For example if dealing with trusted a application.
  76. # skip_authorization do |resource_owner, client|
  77. # client.superapp? or resource_owner.admin?
  78. # end
  79. # WWW-Authenticate Realm (default "Doorkeeper").
  80. # realm "Doorkeeper"
  81. # Allow dynamic query parameters (disabled by default)
  82. # Some applications require dynamic query parameters on their request_uri
  83. # set to true if you want this to be allowed
  84. # wildcard_redirect_uri false
  85. end