From 9d0a5a140723e1fc001b3d6c147e37a2403c88d7 Mon Sep 17 00:00:00 2001 From: Stephen Greer Date: Tue, 19 Sep 2023 14:56:38 -0500 Subject: [PATCH] Display better error message for missing credentials --- lib/omniauth/strategies/base_strategy.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/omniauth/strategies/base_strategy.rb b/lib/omniauth/strategies/base_strategy.rb index 2ca2896..f75af63 100644 --- a/lib/omniauth/strategies/base_strategy.rb +++ b/lib/omniauth/strategies/base_strategy.rb @@ -7,6 +7,7 @@ module OmniAuth module Strategies class BaseStrategy < OmniAuth::Strategies::OpenIDConnect class APIError < StandardError; end + class ClientCredentialsError < StandardError; end def public_key @public_key ||= if options.discovery @@ -18,6 +19,14 @@ def public_key end end + def client + super + rescue AttrRequired::AttrMissing + raise ClientCredentialsError.new( + "#{options[:name].camelize} client credentials not found. Please check your environment." + ) + end + def self.decode_logout_token(token) jwks = fetch_jwks JSON::JWT.decode(token, jwks)