Module: Doorkeeper

Defined in:
lib/doorkeeper.rb,
lib/doorkeeper/rake.rb,
lib/doorkeeper/oauth.rb,
lib/doorkeeper/config.rb,
lib/doorkeeper/engine.rb,
lib/doorkeeper/errors.rb,
lib/doorkeeper/server.rb,
lib/doorkeeper/request.rb,
lib/doorkeeper/version.rb,
lib/doorkeeper/grant_flow.rb,
lib/doorkeeper/oauth/error.rb,
lib/doorkeeper/oauth/token.rb,
lib/doorkeeper/validations.rb,
lib/doorkeeper/oauth/client.rb,
lib/doorkeeper/oauth/scopes.rb,
lib/doorkeeper/rails/routes.rb,
lib/doorkeeper/request/code.rb,
lib/doorkeeper/config/option.rb,
lib/doorkeeper/grape/helpers.rb,
lib/doorkeeper/rails/helpers.rb,
lib/doorkeeper/request/token.rb,
lib/doorkeeper/grant_flow/flow.rb,
lib/doorkeeper/request/password.rb,
lib/doorkeeper/request/strategy.rb,
lib/doorkeeper/oauth/nonstandard.rb,
lib/doorkeeper/orm/active_record.rb,
lib/doorkeeper/config/validations.rb,
lib/doorkeeper/helpers/controller.rb,
lib/doorkeeper/oauth/base_request.rb,
lib/doorkeeper/oauth/code_request.rb,
lib/doorkeeper/grant_flow/registry.rb,
lib/doorkeeper/oauth/base_response.rb,
lib/doorkeeper/oauth/code_response.rb,
lib/doorkeeper/oauth/hooks/context.rb,
lib/doorkeeper/oauth/token_request.rb,
lib/doorkeeper/rails/routes/mapper.rb,
lib/doorkeeper/secret_storing/base.rb,
lib/doorkeeper/oauth/error_response.rb,
lib/doorkeeper/oauth/token_response.rb,
lib/doorkeeper/rails/routes/mapping.rb,
lib/doorkeeper/secret_storing/plain.rb,
lib/doorkeeper/rails/routes/registry.rb,
lib/doorkeeper/request/refresh_token.rb,
lib/doorkeeper/secret_storing/bcrypt.rb,
lib/doorkeeper/stale_records_cleaner.rb,
lib/doorkeeper/models/concerns/scopes.rb,
lib/doorkeeper/config/abstract_builder.rb,
lib/doorkeeper/oauth/pre_authorization.rb,
app/helpers/doorkeeper/dashboard_helper.rb,
lib/doorkeeper/grant_flow/fallback_flow.rb,
lib/doorkeeper/models/application_mixin.rb,
lib/doorkeeper/models/concerns/reusable.rb,
lib/doorkeeper/oauth/authorization/code.rb,
lib/doorkeeper/oauth/client/credentials.rb,
lib/doorkeeper/models/access_grant_mixin.rb,
lib/doorkeeper/models/access_token_mixin.rb,
lib/doorkeeper/models/concerns/expirable.rb,
lib/doorkeeper/models/concerns/orderable.rb,
lib/doorkeeper/models/concerns/ownership.rb,
lib/doorkeeper/models/concerns/revocable.rb,
lib/doorkeeper/oauth/authorization/token.rb,
lib/doorkeeper/oauth/helpers/uri_checker.rb,
lib/doorkeeper/oauth/token_introspection.rb,
lib/generators/doorkeeper/pkce_generator.rb,
lib/doorkeeper/models/concerns/accessible.rb,
lib/doorkeeper/oauth/helpers/unique_token.rb,
lib/doorkeeper/request/authorization_code.rb,
lib/doorkeeper/request/client_credentials.rb,
lib/doorkeeper/secret_storing/sha256_hash.rb,
lib/generators/doorkeeper/views_generator.rb,
lib/doorkeeper/oauth/authorization/context.rb,
lib/doorkeeper/oauth/helpers/scope_checker.rb,
lib/doorkeeper/oauth/refresh_token_request.rb,
lib/doorkeeper/oauth/invalid_token_response.rb,
lib/doorkeeper/rails/routes/abstract_router.rb,
lib/generators/doorkeeper/install_generator.rb,
app/controllers/doorkeeper/tokens_controller.rb,
lib/doorkeeper/grape/authorization_decorator.rb,
lib/doorkeeper/orm/active_record/application.rb,
lib/doorkeeper/oauth/forbidden_token_response.rb,
lib/doorkeeper/oauth/invalid_request_response.rb,
lib/doorkeeper/orm/active_record/access_grant.rb,
lib/doorkeeper/orm/active_record/access_token.rb,
lib/generators/doorkeeper/migration_generator.rb,
lib/doorkeeper/models/concerns/secret_storable.rb,
lib/doorkeeper/oauth/authorization/uri_builder.rb,
lib/doorkeeper/oauth/client_credentials/issuer.rb,
lib/doorkeeper/oauth/authorization_code_request.rb,
lib/doorkeeper/oauth/client_credentials/creator.rb,
lib/doorkeeper/oauth/client_credentials_request.rb,
app/controllers/doorkeeper/token_info_controller.rb,
app/controllers/doorkeeper/application_controller.rb,
lib/doorkeeper/models/concerns/resource_ownerable.rb,
lib/doorkeeper/oauth/client_credentials/validator.rb,
app/controllers/doorkeeper/applications_controller.rb,
lib/doorkeeper/oauth/password_access_token_request.rb,
app/controllers/doorkeeper/authorizations_controller.rb,
lib/generators/doorkeeper/application_owner_generator.rb,
lib/doorkeeper/orm/active_record/stale_records_cleaner.rb,
app/controllers/doorkeeper/application_metal_controller.rb,
lib/doorkeeper/models/concerns/expiration_time_sql_math.rb,
lib/doorkeeper/orm/active_record/redirect_uri_validator.rb,
lib/generators/doorkeeper/previous_refresh_token_generator.rb,
app/controllers/doorkeeper/authorized_applications_controller.rb,
lib/generators/doorkeeper/confidential_applications_generator.rb,
lib/generators/doorkeeper/enable_polymorphic_resource_owner_generator.rb

Overview

Define methods that can be called in any controller that inherits from Doorkeeper::ApplicationMetalController or Doorkeeper::ApplicationController

Defined Under Namespace

Modules: AccessGrantMixin, AccessTokenMixin, ApplicationMixin, DashboardHelper, Errors, Generators, GrantFlow, Grape, Helpers, Models, OAuth, Orm, Rails, Rake, Request, SecretStoring, VERSION, Validations Classes: AccessGrant, AccessToken, Application, ApplicationController, ApplicationMetalController, ApplicationOwnerGenerator, ApplicationsController, AuthorizationsController, AuthorizedApplicationsController, ConfidentialApplicationsGenerator, Config, EnablePolymorphicResourceOwnerGenerator, Engine, InstallGenerator, MigrationGenerator, MissingConfiguration, MissingConfigurationBuilderClass, PkceGenerator, PreviousRefreshTokenGenerator, RedirectUriValidator, Server, StaleRecordsCleaner, TokenInfoController, TokensController

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.orm_adapterObject (readonly)

Returns the value of attribute orm_adapter.


24
25
26
# File 'lib/doorkeeper/config.rb', line 24

def orm_adapter
  @orm_adapter
end

Class Method Details

.authenticate(request, methods = Doorkeeper.config.access_token_methods) ⇒ Object


116
117
118
# File 'lib/doorkeeper.rb', line 116

def self.authenticate(request, methods = Doorkeeper.config.access_token_methods)
  OAuth::Token.authenticate(request, *methods)
end

.configurationDoorkeeper::Config Also known as: config

Returns configuration instance.

Returns:


32
33
34
# File 'lib/doorkeeper/config.rb', line 32

def configuration
  @config || (raise MissingConfiguration)
end

.configure(&block) ⇒ Object


26
27
28
# File 'lib/doorkeeper/config.rb', line 26

def configure(&block)
  @config = Config::Builder.new(&block).build
end

.gem_versionObject


120
121
122
# File 'lib/doorkeeper.rb', line 120

def self.gem_version
  ::Gem::Version.new(::Doorkeeper::VERSION::STRING)
end

.run_orm_hooksObject


62
63
64
65
66
67
68
69
70
71
72
# File 'lib/doorkeeper/config.rb', line 62

def run_orm_hooks
  if @orm_adapter.respond_to?(:run_hooks)
    @orm_adapter.run_hooks
  else
    ::Kernel.warn <<~MSG.strip_heredoc
      [DOORKEEPER] ORM "#{configuration.orm}" should move all it's setup logic under `#run_hooks` method for
      the #{@orm_adapter.name}. Later versions of Doorkeeper will no longer support `setup_orm_models` and
      `setup_application_owner` API.
    MSG
  end
end

.setupObject


38
39
40
41
42
43
44
45
46
47
48
# File 'lib/doorkeeper/config.rb', line 38

def setup
  setup_orm_adapter
  run_orm_hooks
  config.clear_cache!

  # Deprecated, will be removed soon
  unless configuration.orm == :active_record
    setup_orm_models
    setup_application_owner
  end
end

.setup_application_ownerObject


78
79
80
# File 'lib/doorkeeper/config.rb', line 78

def setup_application_owner
  @orm_adapter.initialize_application_owner!
end

.setup_orm_adapterObject


50
51
52
53
54
55
56
57
58
59
60
# File 'lib/doorkeeper/config.rb', line 50

def setup_orm_adapter
  @orm_adapter = "doorkeeper/orm/#{configuration.orm}".classify.constantize
rescue NameError => e
  raise e, "ORM adapter not found (#{configuration.orm})", <<-ERROR_MSG.strip_heredoc
    [DOORKEEPER] ORM adapter not found (#{configuration.orm}), or there was an error
    trying to load it.

    You probably need to add the related gem for this adapter to work with
    doorkeeper.
  ERROR_MSG
end

.setup_orm_modelsObject


74
75
76
# File 'lib/doorkeeper/config.rb', line 74

def setup_orm_models
  @orm_adapter.initialize_models!
end