diff --git a/.rubocop.yml b/.rubocop.yml index 2f96046..c38df9f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,3 +22,6 @@ RSpec/FilePath: RSpec/SpecFilePathFormat: CustomTransform: OmniAuth: omniauth + +Style/NumericPredicate: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bcdd4b9..3e8096d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -11,11 +11,6 @@ Lint/EnsureReturn: Exclude: - 'lib/omniauth/strategies/cas/logout_request.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -Lint/UselessAssignment: - Exclude: - - 'lib/omniauth/strategies/cas.rb' - Lint/UselessRescue: Exclude: - 'lib/omniauth/strategies/cas/logout_request.rb' @@ -48,10 +43,6 @@ Naming/AccessorMethodName: Exclude: - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' -Naming/ConstantName: - Exclude: - - 'lib/omniauth/strategies/cas.rb' - # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms. # CheckDefinitionPathHierarchyRoots: lib, spec, test, src # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS @@ -122,49 +113,6 @@ Style/Documentation: - 'lib/omniauth/strategies/cas/logout_request.rb' - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, always_true, never -Style/FrozenStringLiteralComment: - Exclude: - - 'lib/omniauth-cas.rb' - - 'lib/omniauth/cas.rb' - - 'lib/omniauth/cas/version.rb' - - 'lib/omniauth/strategies/cas.rb' - - 'lib/omniauth/strategies/cas/logout_request.rb' - - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' - -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedReceivers. -# AllowedReceivers: Thread.current -Style/HashEachMethods: - Exclude: - - 'lib/omniauth/strategies/cas.rb' - -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: literals, strict -Style/MutableConstant: - Exclude: - - 'lib/omniauth/cas/version.rb' - - 'lib/omniauth/strategies/cas.rb' - - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' - -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. -# SupportedStyles: predicate, comparison -Style/NumericPredicate: - Exclude: - - 'spec/**/*' - - 'lib/omniauth/strategies/cas/service_ticket_validator.rb' - -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: short, verbose -Style/PreferredHashMethods: - Exclude: - - 'lib/omniauth/strategies/cas.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https diff --git a/lib/omniauth-cas.rb b/lib/omniauth-cas.rb index 3de039d..a98c23d 100644 --- a/lib/omniauth-cas.rb +++ b/lib/omniauth-cas.rb @@ -1 +1,3 @@ +# frozen_string_literal: true + require 'omniauth/cas' diff --git a/lib/omniauth/cas.rb b/lib/omniauth/cas.rb index 2fe34bb..5990130 100644 --- a/lib/omniauth/cas.rb +++ b/lib/omniauth/cas.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + require 'omniauth/cas/version' require 'omniauth/strategies/cas' diff --git a/lib/omniauth/cas/version.rb b/lib/omniauth/cas/version.rb index 0fb6fc5..160d8e1 100644 --- a/lib/omniauth/cas/version.rb +++ b/lib/omniauth/cas/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module OmniAuth module Cas VERSION = '3.0.0' diff --git a/lib/omniauth/strategies/cas.rb b/lib/omniauth/strategies/cas.rb index e1db34a..77868ac 100644 --- a/lib/omniauth/strategies/cas.rb +++ b/lib/omniauth/strategies/cas.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'omniauth' require 'addressable/uri' @@ -48,7 +50,7 @@ class InvalidCASTicket < StandardError; end option :phone_key, 'phone' # As required by https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema - AuthHashSchemaKeys = %w[name email nickname first_name last_name location image phone] + AUTH_HASH_SCHEMA_KEYS = %w[name email nickname first_name last_name location image phone].freeze info do prune!({ name: raw_info[options[:name_key].to_s], @@ -64,7 +66,7 @@ class InvalidCASTicket < StandardError; end extra do prune!( - raw_info.delete_if { |k, _v| AuthHashSchemaKeys.include?(k) } + raw_info.delete_if { |k, _v| AUTH_HASH_SCHEMA_KEYS.include?(k) } ) end @@ -104,7 +106,7 @@ def request_phase end def on_sso_path? - request.post? && request.params.has_key?('logoutRequest') + request.post? && request.params.key?('logoutRequest') end def single_sign_out_phase @@ -177,7 +179,7 @@ def login_url(service) # # @return [String] the new joined URL. def append_params(base, params) - params = params.each { |_k, v| v = Rack::Utils.escape(v) } + params = params.each_value { |v| Rack::Utils.escape(v) } Addressable::URI.parse(base).tap do |base_uri| base_uri.query_values = (base_uri.query_values || {}).merge(params) end.to_s diff --git a/lib/omniauth/strategies/cas/logout_request.rb b/lib/omniauth/strategies/cas/logout_request.rb index 3448208..0a33cdc 100644 --- a/lib/omniauth/strategies/cas/logout_request.rb +++ b/lib/omniauth/strategies/cas/logout_request.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module OmniAuth module Strategies class CAS diff --git a/lib/omniauth/strategies/cas/service_ticket_validator.rb b/lib/omniauth/strategies/cas/service_ticket_validator.rb index 6b813fa..9db770b 100644 --- a/lib/omniauth/strategies/cas/service_ticket_validator.rb +++ b/lib/omniauth/strategies/cas/service_ticket_validator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'net/http' require 'net/https' require 'nokogiri' @@ -6,7 +8,7 @@ module OmniAuth module Strategies class CAS class ServiceTicketValidator - VALIDATION_REQUEST_HEADERS = { 'Accept' => '*/*' } + VALIDATION_REQUEST_HEADERS = { 'Accept' => '*/*' }.freeze attr_reader :success_body