<commit_before>Doorkeeper.configure do
  orm :active_record

  # => Authentication
  # Check whether the resource owner is authenticated or not.
  resource_owner_authenticator do
    # TODO: write error! method
    User.find(doorkeeper_token[:resource_owner_id]) or error!
  end
  # Authenticate in Resource Owner Password flow
  resource_owner_from_credentials do
    User.authenticate!(params[:email] || params[:name], params[:password])
  end
  # Restrict access to the web interface for adding oauth applications
  admin_authenticator do
    # TODO: write error! method and use Pundit
    User.find(doorkeeper_token[:resource_owner_id])
  end

  # => Token Configuration
  access_token_expires_in 30.days # Expire access tokens
  reuse_access_token # Reuse access tokens if possible
  use_refresh_token # Issue refresh tokens

  # => Application Registration
  # Require an owner for each application
  # Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
  enable_application_owner confirmation: true

  # => Available Scopes
  default_scopes :public
  optional_scopes :everything

  # Change the native redirect uri for client apps
  # 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
  # The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
  # (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)<commit_msg>Use modern Devise authentication code for Doorkeeper ROP<commit_after>Doorkeeper.configure do
  orm :active_record

  # => Authentication
  # Check whether the resource owner is authenticated or not.
  resource_owner_authenticator do
    # TODO: write error! method
    User.find(doorkeeper_token[:resource_owner_id]) or error!
  end
  # Authenticate in Resource Owner Password flow
  resource_owner_from_credentials do
    user = User.find_for_database_authentication(:email => params[:identification])
    if user && user.valid_for_authentication? { user.valid_password?(params[:password]) }
      user
    end
  end
  # Restrict access to the web interface for adding oauth applications
  admin_authenticator do
    # TODO: write error! method and use Pundit
    User.find(doorkeeper_token[:resource_owner_id])
  end

  # => Token Configuration
  access_token_expires_in 30.days # Expire access tokens
  reuse_access_token # Reuse access tokens if possible
  use_refresh_token # Issue refresh tokens

  # => Application Registration
  # Require an owner for each application
  # Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support
  enable_application_owner confirmation: true

  # => Available Scopes
  default_scopes :public
  optional_scopes :everything

  # Change the native redirect uri for client apps
  # 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
  # The value can be any string. Use nil to disable this feature. When disabled, clients must provide a valid URL
  # (Similar behaviour: https://developers.google.com/accounts/docs/OAuth2InstalledApp#choosingredirecturi)
{'fraction_non_alphanumeric': 0.05474125037391565, 'fraction_numerical': 0.0017947950942267424, 'mean_word_length': 4.706484641638225, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3386902', 'n_tokens_mistral': 898, 'n_tokens_neox': 856, 'n_words': 336}