In some cases you may want to have some functionality that extends Doorkeeper, but it's not something that is required by the OAuth RFC and must be implemented in gem itself. In such cases you may create an extension for Doorkeeper gem.
You can reuse Doorkeeper internals for your own purposes.
You can reuse Doorkeeper options DSL to define your own configurations.
class YourExtensiondef self.configure(&block)@config = Config::Builder.new(Config.new, &block).buildenddef self.configuration@config || (raise Errors::MissingConfiguration)endclass Configclass Builder < Doorkeeper::Config::AbstractBuilder# your custom config methodsdef enforce_something@config.instance_variable_set(:@enforce_something, true)endenddef enforce_something?if defined?(@enforce_something)@enforce_somethingelsefalseendend# In case you defined some other builder classdef self.builder_classConfig::Builderendextend Doorkeeper::Config::Option# your custom optionsoption :expiration_time, default: 1.houroption :skip_something, default: trueendend
Then your extension configuration will look like:
# config/initializers/your_extension.rbYourExtension.configure doexpiration_time 15.minutesskip_something trueenforce_somethingend
Take a look at Doorkeeper config file to get more examples of options DSL and it's arguments.
Examples of extensions in the wild: