Skip to content

Commit

Permalink
avoid using match when MatchData is not used
Browse files Browse the repository at this point in the history
  • Loading branch information
yannvery committed Feb 1, 2019
1 parent 3ae8b9a commit 694fc90
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/omniauth/strategies/openid_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def config
end

def request_phase
options.issuer = issuer if options.issuer.nil? || options.issuer.empty?
discover!
redirect authorize_uri
end
Expand All @@ -97,6 +98,7 @@ def callback_phase
elsif !request.params['code']
return fail!(:missing_code, OmniAuth::OpenIDConnect::MissingCodeError.new(request.params['error']))
else
options.issuer = issuer if options.issuer.nil? || options.issuer.empty?
discover!
client.redirect_uri = redirect_uri
client.authorization_code = authorization_code
Expand All @@ -112,7 +114,8 @@ def callback_phase
end

def other_phase
if logout_path_pattern.match(current_path)
if logout_path_pattern.match?(current_path)
options.issuer = issuer if options.issuer.nil? || options.issuer.empty?
discover!
return redirect(end_session_uri) if end_session_uri
end
Expand Down Expand Up @@ -159,16 +162,11 @@ def issuer

def discover!
return unless options.discovery
options.issuer = issuer if options.issuer.blank?
setup_client_options(config)
end

def setup_client_options(discover)
client_options.authorization_endpoint = discover.authorization_endpoint
client_options.token_endpoint = discover.token_endpoint
client_options.userinfo_endpoint = discover.userinfo_endpoint
client_options.jwks_uri = discover.jwks_uri
client_options.end_session_endpoint = discover.try :end_session_endpoint
client_options.authorization_endpoint = config.authorization_endpoint
client_options.token_endpoint = config.token_endpoint
client_options.userinfo_endpoint = config.userinfo_endpoint
client_options.jwks_uri = config.jwks_uri
client_options.end_session_endpoint = config.end_session_endpoint if config.respond_to?(:end_session_endpoint)
end

def user_info
Expand Down

0 comments on commit 694fc90

Please sign in to comment.