From 150c904886ea71028108a93f985292cd5e679543 Mon Sep 17 00:00:00 2001 From: seka Date: Mon, 17 Sep 2018 20:10:18 +0900 Subject: [PATCH 1/3] Allow blank string --- lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb b/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb index ed9eb78..a8f5a72 100644 --- a/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb +++ b/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb @@ -71,7 +71,9 @@ def generate_uid end def generate_secret - if secret.blank? + # 空の場合は省略してもよい (MAY) となっており、実装する側に依存するようなので独自にパッチを当てる + # See https://openid-foundation-japan.github.io/rfc6749.ja.html#client-password + if secret.nil? self.secret = UniqueToken.generate end end From 70e4e268a4230e762bdf5716c8183ee769848d98 Mon Sep 17 00:00:00 2001 From: seka Date: Mon, 17 Sep 2018 20:39:46 +0900 Subject: [PATCH 2/3] Fix validation --- lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb b/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb index a8f5a72..4224cae 100644 --- a/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb +++ b/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb @@ -21,7 +21,7 @@ module ApplicationMixin has_many :access_grants, has_many_options.merge(class_name: 'Doorkeeper::AccessGrant') has_many :access_tokens, has_many_options.merge(class_name: 'Doorkeeper::AccessToken') - validates :name, :secret, :uid, presence: true + validates :name, :uid, presence: true validates :uid, uniqueness: true validates :redirect_uri, redirect_uri: true From 42b32bff7f9c295d536864df8fbc0e7c7bb6b158 Mon Sep 17 00:00:00 2001 From: seka Date: Tue, 18 Sep 2018 14:42:50 +0900 Subject: [PATCH 3/3] Tweak comment --- lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb b/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb index 4224cae..b2d5943 100644 --- a/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb +++ b/lib/doorkeeper-mongodb/mixins/mongoid/application_mixin.rb @@ -71,7 +71,9 @@ def generate_uid end def generate_secret - # 空の場合は省略してもよい (MAY) となっており、実装する側に依存するようなので独自にパッチを当てる + # 外部連携 B パターン (院内のサーバーなしのクライアントの場合) でクライアント認証なしの Authorization Code フローを利用することになったため + # 空文字のシークレットを設定できるようにしたかったが、RFC の仕様的に空の場合は省略してもよい (MAY) となっており、 + # 実装する側に処理が依存するようなので独自にパッチを当てる # See https://openid-foundation-japan.github.io/rfc6749.ja.html#client-password if secret.nil? self.secret = UniqueToken.generate