Skip to content

Commit

Permalink
fix: Add openid scope to Doorkeeper configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
toupeira committed Oct 5, 2016
1 parent b44c2b4 commit 8169c2d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
en:
doorkeeper:
scopes:
openid: 'Authenticate your account'
openid_connect:
errors:
messages:
Expand Down
4 changes: 4 additions & 0 deletions lib/doorkeeper/openid_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
require 'doorkeeper'

module Doorkeeper
class << self
prepend OpenidConnect::DoorkeeperConfiguration
end

module OpenidConnect
def self.configured?
@config.present?
Expand Down
9 changes: 8 additions & 1 deletion lib/doorkeeper/openid_connect/config.rb
Original file line number Diff line number Diff line change
@@ -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?')
Expand All @@ -11,7 +18,7 @@ def self.configure(&block)
end

def self.configuration
@config || (fail MissingConfiguration.new)
@config || (fail MissingConfiguration)
end

class Config
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/doorkeeper/openid_connect/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ''
Expand Down

0 comments on commit 8169c2d

Please sign in to comment.