From 8169c2dd3eb4444fcbf9812258a10667cd65b738 Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Mon, 26 Sep 2016 22:03:16 +0200 Subject: [PATCH] fix: Add openid scope to Doorkeeper configuration --- config/locales/en.yml | 2 ++ lib/doorkeeper/openid_connect.rb | 4 ++++ lib/doorkeeper/openid_connect/config.rb | 9 ++++++++- spec/lib/doorkeeper/openid_connect/config_spec.rb | 6 ++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 9d88615..007a299 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,7 @@ en: doorkeeper: + scopes: + openid: 'Authenticate your account' openid_connect: errors: messages: diff --git a/lib/doorkeeper/openid_connect.rb b/lib/doorkeeper/openid_connect.rb index 1d354a6..514b08e 100644 --- a/lib/doorkeeper/openid_connect.rb +++ b/lib/doorkeeper/openid_connect.rb @@ -14,6 +14,10 @@ require 'doorkeeper' module Doorkeeper + class << self + prepend OpenidConnect::DoorkeeperConfiguration + end + module OpenidConnect def self.configured? @config.present? diff --git a/lib/doorkeeper/openid_connect/config.rb b/lib/doorkeeper/openid_connect/config.rb index 23b4572..c21c80e 100644 --- a/lib/doorkeeper/openid_connect/config.rb +++ b/lib/doorkeeper/openid_connect/config.rb @@ -1,5 +1,12 @@ module Doorkeeper module OpenidConnect + module DoorkeeperConfiguration + def configure(&block) + super(&block) + configuration.optional_scopes.add :openid + end + end + class MissingConfiguration < StandardError def initialize super('Configuration for Doorkeeper OpenID Connect missing. Do you have doorkeeper_openid_connect initializer?') @@ -11,7 +18,7 @@ def self.configure(&block) end def self.configuration - @config || (fail MissingConfiguration.new) + @config || (fail MissingConfiguration) end class Config diff --git a/spec/lib/doorkeeper/openid_connect/config_spec.rb b/spec/lib/doorkeeper/openid_connect/config_spec.rb index 362a30f..f38af75 100644 --- a/spec/lib/doorkeeper/openid_connect/config_spec.rb +++ b/spec/lib/doorkeeper/openid_connect/config_spec.rb @@ -3,6 +3,12 @@ describe Doorkeeper::OpenidConnect, 'configuration' do subject { Doorkeeper::OpenidConnect.configuration } + describe 'scopes' do + it' adds the openid scope to the Doorkeeper configuration' do + expect(Doorkeeper.configuration.scopes).to include 'openid' + end + end + describe 'jws_private_key' do it 'sets the value that is accessible via jws_private_key' do value = ''