Skip to content

Commit

Permalink
Display better error message for missing credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenagreer committed Sep 19, 2023
1 parent 5f78242 commit 9d0a5a1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/omniauth/strategies/base_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 9d0a5a1

Please sign in to comment.