lib/omniauth/strategies/oidc.rb in omniauth_oidc-0.2.1 vs lib/omniauth/strategies/oidc.rb in omniauth_oidc-0.2.2

- old
+ new

@@ -3,11 +3,11 @@ require "base64" require "timeout" require "net/http" require "open-uri" require "omniauth" -require "oidc" +require "openid_connect" require "openid_config_parser" require "forwardable" require "httparty" Dir[File.join(File.dirname(__FILE__), "oidc", "*.rb")].sort.each { |file| require_relative file } @@ -110,13 +110,13 @@ expires_in: access_token.expires_in, scope: access_token.scope } end - # Initialize Oidc Client with options + # Initialize OpenIDConnect Client with options def client - @client ||= ::Oidc::Client.new(client_options) + @client ||= ::OpenIDConnect::Client.new(client_options) end # Config is build from the json response from the OIDC config endpoint def config unless client_options.config_endpoint || params["config_endpoint"] @@ -125,19 +125,21 @@ end @config ||= OpenidConfigParser.fetch_openid_configuration(client_options.config_endpoint) end + # Detects if current request is for the logout url and makes a redirect to end session with OIDC provider def other_phase - if logout_path_pattern.match?(current_path) + if logout_path_pattern.match?(request.url) options.issuer = issuer if options.issuer.to_s.empty? return redirect(end_session_uri) if end_session_uri end call_app! end + # URL to end authenticated user's session with OIDC provider def end_session_uri return unless end_session_endpoint_is_valid? end_session_uri = URI(client_options.end_session_endpoint) end_session_uri.query = encoded_post_logout_redirect_uri @@ -203,10 +205,10 @@ client_options.end_session_endpoint && client_options.end_session_endpoint =~ URI::DEFAULT_PARSER.make_regexp end def logout_path_pattern - @logout_path_pattern ||= /\A#{Regexp.quote(request_path)}#{options.logout_path}/ + @logout_path_pattern ||= /\A#{Regexp.quote(request.base_url)}#{options.logout_path}/ end # Strips port and host from strings with OIDC endpoints def resolve_endpoint_from_host(host, endpoint) start_index = endpoint.index(host) + host.length