diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e50d02..b28cfb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,19 +1,20 @@ ## Unreleased - [#PR ID] Add your changelog entry here. +- [#186] Simplify gem configuration reusing Doorkeeper configuration option DSL (thanks to @nbulaj). ## v1.8.4 (2023-02-01) -- [#185] Don't call active_record_options for Doorkeeper >= 5.6.3. -- [#183] stop render consent screen when user is not logged-in. +- [#185] Don't call active_record_options for Doorkeeper >= 5.6.3 (thanks to @zavan). +- [#183] Stop render consent screen when user is not logged-in (thanks to @nov). ## v1.8.3 (2022-12-02) -- [#180] Add PKCE support to OpenID discovery endpoint. +- [#180] Add PKCE support to OpenID discovery endpoint (thanks to @stanhu). ## Unreleased next -- [#177] Replace `json-jwt` with `ruby-jwt` to align with doorkeeper-jwt. +- [#177] Replace `json-jwt` with `ruby-jwt` to align with doorkeeper-jwt (thanks to @kristof-mattei). ## v1.8.2 (2022-07-13) diff --git a/doorkeeper-openid_connect.gemspec b/doorkeeper-openid_connect.gemspec index 2faf8fa..a0f4358 100644 --- a/doorkeeper-openid_connect.gemspec +++ b/doorkeeper-openid_connect.gemspec @@ -6,8 +6,8 @@ require 'doorkeeper/openid_connect/version' Gem::Specification.new do |spec| spec.name = 'doorkeeper-openid_connect' spec.version = Doorkeeper::OpenidConnect::VERSION - spec.authors = ['Sam Dengler', 'Markus Koller'] - spec.email = ['sam.dengler@playonsports.com', 'markus-koller@gmx.ch'] + spec.authors = ['Sam Dengler', 'Markus Koller', 'Nikita Bulai'] + spec.email = ['sam.dengler@playonsports.com', 'markus-koller@gmx.ch', 'bulajnikita@gmail.com'] spec.homepage = 'https://github.com/doorkeeper-gem/doorkeeper-openid_connect' spec.summary = 'OpenID Connect extension for Doorkeeper.' spec.description = 'OpenID Connect extension for Doorkeeper.' diff --git a/lib/doorkeeper/openid_connect/config.rb b/lib/doorkeeper/openid_connect/config.rb index f91a2e5..6ebce48 100644 --- a/lib/doorkeeper/openid_connect/config.rb +++ b/lib/doorkeeper/openid_connect/config.rb @@ -35,68 +35,9 @@ def jws_private_key(*args) end end - module Option - # Defines configuration option - # - # When you call option, it defines two methods. One method will take place - # in the +Config+ class and the other method will take place in the - # +Builder+ class. - # - # The +name+ parameter will set both builder method and config attribute. - # If the +:as+ option is defined, the builder method will be the specified - # option while the config attribute will be the +name+ parameter. - # - # If you want to introduce another level of config DSL you can - # define +builder_class+ parameter. - # Builder should take a block as the initializer parameter and respond to function +build+ - # that returns the value of the config attribute. - # - # ==== Options - # - # * [:+as+] Set the builder method that goes inside +configure+ block - # * [+:default+] The default value in case no option was set - # - # ==== Examples - # - # option :name - # option :name, as: :set_name - # option :name, default: 'My Name' - # option :scopes builder_class: ScopesBuilder - # - def option(name, options = {}) - attribute = options[:as] || name - attribute_builder = options[:builder_class] - - Builder.instance_eval do - define_method name do |*args, &block| - # TODO: is builder_class option being used? - value = if attribute_builder - attribute_builder.new(&block).build - else - block || args.first - end - - @config.instance_variable_set(:"@#{attribute}", value) - end - end - - define_method attribute do |*_| - if instance_variable_defined?(:"@#{attribute}") - instance_variable_get(:"@#{attribute}") - else - options[:default] - end - end - - public attribute - end - - def extended(base) - base.send(:private, :option) - end - end + mattr_reader(:builder_class) { Config::Builder } - extend Option + extend ::Doorkeeper::Config::Option option :issuer option :signing_key