Skip to content

Commit

Permalink
More style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed May 19, 2020
1 parent 17ab5e6 commit 0838186
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Layout/HashAlignment:
Enabled: false
Layout/FirstHashElementIndentation:
Enabled: false
Layout/ArgumentAlignment:
Enabled: false

# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module OpenidConnect
class DiscoveryController < ::Doorkeeper::ApplicationController
include Doorkeeper::Helpers::Controller

WEBFINGER_RELATION = 'http://openid.net/specs/connect/1.0/issuer'.freeze
WEBFINGER_RELATION = 'http://openid.net/specs/connect/1.0/issuer'

def provider
render json: provider_response
Expand Down Expand Up @@ -63,12 +63,12 @@ def provider_response
# 'distributed',
],

claims_supported: [
'iss',
'sub',
'aud',
'exp',
'iat',
claims_supported: %w[
iss
sub
aud
exp
iat
] | openid_connect.claims.to_h.keys,
}.compact
end
Expand Down
14 changes: 7 additions & 7 deletions doorkeeper-openid_connect.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

$:.push File.expand_path('lib', __dir__)
$LOAD_PATH.push File.expand_path('lib', __dir__)
require 'doorkeeper/openid_connect/version'

Gem::Specification.new do |spec|
Expand All @@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
spec.authors = ['Sam Dengler', 'Markus Koller']
spec.email = ['sam.dengler@playonsports.com', 'markus-koller@gmx.ch']
spec.homepage = 'https://github.com/doorkeeper-gem/doorkeeper-openid_connect'
spec.summary = %q{OpenID Connect extension for Doorkeeper.}
spec.description = %q{OpenID Connect extension for Doorkeeper.}
spec.license = %q{MIT}
spec.summary = 'OpenID Connect extension for Doorkeeper.'
spec.description = 'OpenID Connect extension for Doorkeeper.'
spec.license = 'MIT'

spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
Expand All @@ -24,9 +24,9 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency 'doorkeeper', '>= 5.2', '< 5.5'
spec.add_runtime_dependency 'json-jwt', '>= 1.11.0'

spec.add_development_dependency 'rspec-rails'
spec.add_development_dependency 'conventional-changelog', '~> 1.2'
spec.add_development_dependency 'factory_bot'
spec.add_development_dependency 'sqlite3', '>= 1.3.6'
spec.add_development_dependency 'pry-byebug'
spec.add_development_dependency 'conventional-changelog', '~> 1.2'
spec.add_development_dependency 'rspec-rails'
spec.add_development_dependency 'sqlite3', '>= 1.3.6'
end
2 changes: 2 additions & 0 deletions gemfiles/rails_5.0.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'rails', '~> 5.0.0'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_5.2.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'rails', '~> 5.2.0'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_6.0.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'rails', '~> 6.0.0'
Expand Down
2 changes: 2 additions & 0 deletions gemfiles/rails_master.gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gem 'rails', git: 'https://github.com/rails/rails'
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/openid_connect/claims/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Claim
email: %i[email email_verified],
address: %i[address],
phone: %i[phone_number phone_number_verified],
}
}.freeze

def initialize(options = {})
@name = options[:name].to_sym
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/openid_connect/claims_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def normal_claim(name, response: [:user_info], scope: nil, &block)
generator: block
)
end
alias_method :claim, :normal_claim
alias claim normal_claim
end
end
end
16 changes: 8 additions & 8 deletions lib/doorkeeper/openid_connect/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ module Doorkeeper
module OpenidConnect
def self.configure(&block)
if Doorkeeper.configuration.orm != :active_record
fail Errors::InvalidConfiguration, 'Doorkeeper OpenID Connect currently only supports the ActiveRecord ORM adapter'
raise Errors::InvalidConfiguration, 'Doorkeeper OpenID Connect currently only supports the ActiveRecord ORM adapter'
end

@config = Config::Builder.new(&block).build
end

def self.configuration
@config || (fail Errors::MissingConfiguration)
@config || (raise Errors::MissingConfiguration)
end

class Config
Expand All @@ -25,7 +25,7 @@ def build
@config
end

def jws_public_key(*args)
def jws_public_key(*_args)
puts 'DEPRECATION WARNING: `jws_public_key` is not needed anymore and will be removed in a future version, please remove it from config/initializers/doorkeeper_openid_connect.rb'
end

Expand Down Expand Up @@ -73,7 +73,7 @@ def option(name, options = {})
value = if attribute_builder
attribute_builder.new(&block).build
else
block ? block : args.first
block || args.first
end

@config.instance_variable_set(:"@#{attribute}", value)
Expand Down Expand Up @@ -104,19 +104,19 @@ def extended(base)
option :subject_types_supported, default: [:public]

option :resource_owner_from_access_token, default: lambda { |*_|
fail Errors::InvalidConfiguration, I18n.translate('doorkeeper.openid_connect.errors.messages.resource_owner_from_access_token_not_configured')
raise Errors::InvalidConfiguration, I18n.translate('doorkeeper.openid_connect.errors.messages.resource_owner_from_access_token_not_configured')
}

option :auth_time_from_resource_owner, default: lambda { |*_|
fail Errors::InvalidConfiguration, I18n.translate('doorkeeper.openid_connect.errors.messages.auth_time_from_resource_owner_not_configured')
raise Errors::InvalidConfiguration, I18n.translate('doorkeeper.openid_connect.errors.messages.auth_time_from_resource_owner_not_configured')
}

option :reauthenticate_resource_owner, default: lambda { |*_|
fail Errors::InvalidConfiguration, I18n.translate('doorkeeper.openid_connect.errors.messages.reauthenticate_resource_owner_not_configured')
raise Errors::InvalidConfiguration, I18n.translate('doorkeeper.openid_connect.errors.messages.reauthenticate_resource_owner_not_configured')
}

option :subject, default: lambda { |*_|
fail Errors::InvalidConfiguration, I18n.translate('doorkeeper.openid_connect.errors.messages.subject_not_configured')
raise Errors::InvalidConfiguration, I18n.translate('doorkeeper.openid_connect.errors.messages.subject_not_configured')
}

option :expiration, default: 120
Expand Down
27 changes: 14 additions & 13 deletions lib/doorkeeper/openid_connect/helpers/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Controller
# FIXME: remove after Doorkeeper will merge it
def current_resource_owner
return @current_resource_owner if defined?(@current_resource_owner)

super
end

Expand All @@ -19,8 +20,8 @@ def authenticate_resource_owner!
handle_oidc_prompt_param!(owner)
handle_oidc_max_age_param!(owner)
end
rescue Errors::OpenidConnectError => exception
handle_oidc_error!(exception)
rescue Errors::OpenidConnectError => e
handle_oidc_error!(e)
end

def oidc_authorization_request?
Expand All @@ -38,17 +39,17 @@ def handle_oidc_error!(exception)
@_response_body = nil

error_response = if exception.type == :invalid_request
::Doorkeeper::OAuth::InvalidRequestResponse.new(
name: exception.type,
state: params[:state],
redirect_uri: params[:redirect_uri],
)
else
::Doorkeeper::OAuth::ErrorResponse.new(
name: exception.type,
state: params[:state],
redirect_uri: params[:redirect_uri],
)
::Doorkeeper::OAuth::InvalidRequestResponse.new(
name: exception.type,
state: params[:state],
redirect_uri: params[:redirect_uri],
)
else
::Doorkeeper::OAuth::ErrorResponse.new(
name: exception.type,
state: params[:state],
redirect_uri: params[:redirect_uri],
)
end

response.headers.merge!(error_response.headers)
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/openid_connect/id_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(access_token, nonce = nil)
@access_token = access_token
@nonce = nonce
@resource_owner = Doorkeeper::OpenidConnect.configuration.resource_owner_from_access_token.call(access_token)
@issued_at = Time.now
@issued_at = Time.zone.now
end

def claims
Expand Down
2 changes: 1 addition & 1 deletion lib/doorkeeper/openid_connect/oauth/pre_authorization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module PreAuthorization

def initialize(server, attrs = {}, resource_owner = nil)
if (Doorkeeper::VERSION::MAJOR >= 5 && Doorkeeper::VERSION::MINOR >= 4) ||
Doorkeeper::VERSION::MAJOR >= 6
Doorkeeper::VERSION::MAJOR >= 6
super
else
super(server, attrs)
Expand Down
6 changes: 3 additions & 3 deletions lib/doorkeeper/openid_connect/orm/active_record/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

module Doorkeeper
module OpenidConnect
class Request < ActiveRecord::Base
class Request < ApplicationRecord

This comment has been minimized.

Copy link
@wheeyls

wheeyls Jul 18, 2020

Contributor

This breaks the zeitwerk autoloader in Rails 6. The style warnings from RuboCop should be ignored in this case - as a gem and not a Rails app, this requirement does not apply to doorkeeper-openid_connect and is undesirable.

self.table_name = "#{table_name_prefix}oauth_openid_requests#{table_name_suffix}".to_sym

validates :access_grant_id, :nonce, presence: true
belongs_to :access_grant,
class_name: 'Doorkeeper::AccessGrant',
inverse_of: :openid_request
class_name: 'Doorkeeper::AccessGrant',
inverse_of: :openid_request
end
end
end
2 changes: 1 addition & 1 deletion lib/doorkeeper/openid_connect/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Doorkeeper
module OpenidConnect
VERSION = '1.7.1'.freeze
VERSION = '1.7.1'
end
end

0 comments on commit 0838186

Please sign in to comment.