Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nbulaj committed Oct 4, 2018
1 parent ca43070 commit 0441c87
Show file tree
Hide file tree
Showing 70 changed files with 214 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ gemfile:

matrix:
fast_finish: true
# Run Danger only once
include:
- rvm: 2.5
gemfile: gemfiles/rails_5_2.gemfile
script: bundle exec danger
exclude:
- gemfile: gemfiles/rails_5_0.gemfile
rvm: 2.1
Expand Down
30 changes: 30 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# --------------------------------------------------------------------------------------------------------------------
# Has any changes happened inside the actual library code?
# --------------------------------------------------------------------------------------------------------------------
has_app_changes = !git.modified_files.grep(/lib/).empty?
has_spec_changes = !git.modified_files.grep(/spec/).empty?

# --------------------------------------------------------------------------------------------------------------------
# You've made changes to lib, but didn't write any tests?
# --------------------------------------------------------------------------------------------------------------------
if has_app_changes && !has_spec_changes
warn("There're library changes, but not tests. That's OK as long as you're refactoring existing code.", sticky: false)
end

# --------------------------------------------------------------------------------------------------------------------
# You've made changes to specs, but no library code has changed?
# --------------------------------------------------------------------------------------------------------------------
if !has_app_changes && has_spec_changes
message('We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!', sticky: false)
end

# Mainly to encourage writing up some reasoning about the PR, rather than
# just leaving a title
if github.pr_body.length < 10
fail "Please provide a summary in the Pull Request description"
end

# --------------------------------------------------------------------------------------------------------------------
# Have you updated CHANGELOG.md?
# --------------------------------------------------------------------------------------------------------------------
changelog.check
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ User-visible changes worth mentioning.
triggers every time)
- [#1149] Fix for `URIChecker#valid_for_authorization?` false negative when query is blank, but `?` present.
- [#1151] Fix Refresh Token strategy: add proper validation of client credentials both for Public & Private clients.
- [#1154] Refactor `StaleRecordsCleaner` to be ORM agnostic.

## 5.0.0

Expand Down
46 changes: 24 additions & 22 deletions doorkeeper.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@ $LOAD_PATH.push File.expand_path('../lib', __FILE__)

require 'doorkeeper/version'

Gem::Specification.new do |s|
s.name = 'doorkeeper'
s.version = Doorkeeper.gem_version
s.authors = ['Felipe Elias Philipp', 'Tute Costa', 'Jon Moss', 'Nikita Bulai']
s.email = %w([email protected])
s.homepage = 'https://github.com/doorkeeper-gem/doorkeeper'
s.summary = 'OAuth 2 provider for Rails and Grape'
s.description = 'Doorkeeper is an OAuth 2 provider for Rails and Grape.'
s.license = 'MIT'
Gem::Specification.new do |gem|
gem.name = 'doorkeeper'
gem.version = Doorkeeper.gem_version
gem.authors = ['Felipe Elias Philipp', 'Tute Costa', 'Jon Moss', 'Nikita Bulai']
gem.email = %w([email protected])
gem.homepage = 'https://github.com/doorkeeper-gem/doorkeeper'
gem.summary = 'OAuth 2 provider for Rails and Grape'
gem.description = 'Doorkeeper is an OAuth 2 provider for Rails and Grape.'
gem.license = 'MIT'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- spec/*`.split("\n")
s.require_paths = ['lib']
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- spec/*`.split("\n")
gem.require_paths = ['lib']

s.add_dependency 'railties', '>= 4.2'
s.required_ruby_version = '>= 2.1'
gem.add_dependency 'railties', '>= 4.2'
gem.required_ruby_version = '>= 2.1'

s.add_development_dependency 'capybara', '~> 2.18'
s.add_development_dependency 'coveralls'
s.add_development_dependency 'grape'
s.add_development_dependency 'database_cleaner', '~> 1.6'
s.add_development_dependency 'factory_bot', '~> 4.8'
s.add_development_dependency 'generator_spec', '~> 0.9.3'
s.add_development_dependency 'rake', '>= 11.3.0'
s.add_development_dependency 'rspec-rails'
gem.add_development_dependency 'capybara', '~> 2.18'
gem.add_development_dependency 'coveralls'
gem.add_development_dependency 'danger', '~> 5.0'
gem.add_development_dependency 'danger-changelog', '~> 0.3'
gem.add_development_dependency 'grape'
gem.add_development_dependency 'database_cleaner', '~> 1.6'
gem.add_development_dependency 'factory_bot', '~> 4.8'
gem.add_development_dependency 'generator_spec', '~> 0.9.3'
gem.add_development_dependency 'rake', '>= 11.3.0'
gem.add_development_dependency 'rspec-rails'
end
1 change: 1 addition & 0 deletions lib/doorkeeper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
require 'doorkeeper/rails/helpers'

require 'doorkeeper/rake'
require 'doorkeeper/stale_records_cleaner'

require 'doorkeeper/orm/active_record'

Expand Down
3 changes: 3 additions & 0 deletions lib/doorkeeper/errors.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module Errors
class DoorkeeperError < StandardError
Expand Down Expand Up @@ -46,6 +48,7 @@ def initialize(response)

UnableToGenerateToken = Class.new(DoorkeeperError)
TokenGeneratorNotFound = Class.new(DoorkeeperError)
NoOrmCleaner = Class.new(DoorkeeperError)

InvalidToken = Class.new BaseResponseError
TokenExpired = Class.new InvalidToken
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/grape/authorization_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module Grape
class AuthorizationDecorator < SimpleDelegator
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/grape/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'doorkeeper/grape/authorization_decorator'

module Doorkeeper
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/helpers/controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Define methods that can be called in any controller that inherits from
# Doorkeeper::ApplicationMetalController or Doorkeeper::ApplicationController
module Doorkeeper
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/models/access_grant_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module AccessGrantMixin
extend ActiveSupport::Concern
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/models/access_token_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module AccessTokenMixin
extend ActiveSupport::Concern
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/models/application_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module ApplicationMixin
extend ActiveSupport::Concern
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/models/concerns/accessible.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module Models
module Accessible
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/models/concerns/expirable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module Models
module Expirable
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/models/concerns/orderable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module Models
module Orderable
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/models/concerns/ownership.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module Models
module Ownership
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/models/concerns/revocable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module Models
module Revocable
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/models/concerns/scopes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module Models
module Scopes
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/authorization/code.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
module Authorization
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/authorization/context.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
module Authorization
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/authorization/token.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
module Authorization
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/authorization/uri_builder.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rack/utils'

module Doorkeeper
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/authorization_code_request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class AuthorizationCodeRequest < BaseRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/base_request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class BaseRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/base_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class BaseResponse
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/client.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class Client
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/client/credentials.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class Client
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/client_credentials/creator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class ClientCredentialsRequest < BaseRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/client_credentials/issuer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class ClientCredentialsRequest < BaseRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/client_credentials/validation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class ClientCredentialsRequest < BaseRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/client_credentials_request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class ClientCredentialsRequest < BaseRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/code_request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class CodeRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/code_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class CodeResponse < BaseResponse
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
Error = Struct.new(:name, :state) do
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/error_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class ErrorResponse < BaseResponse
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/forbidden_token_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class ForbiddenTokenResponse < ErrorResponse
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/helpers/scope_checker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
module Helpers
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/helpers/unique_token.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
module Helpers
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/helpers/uri_checker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
module Helpers
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/invalid_token_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class InvalidTokenResponse < ErrorResponse
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/password_access_token_request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class PasswordAccessTokenRequest < BaseRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/pre_authorization.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class PreAuthorization
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/refresh_token_request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class RefreshTokenRequest < BaseRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/scopes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class Scopes
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/token.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class Token
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/token_introspection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
# RFC7662 OAuth 2.0 Token Introspection
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/token_request.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class TokenRequest
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/oauth/token_response.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module OAuth
class TokenResponse
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/orm/active_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'active_support/lazy_load_hooks'

require 'doorkeeper/orm/active_record/stale_records_cleaner'
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/rails/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Doorkeeper
module Rails
module Helpers
Expand Down
2 changes: 2 additions & 0 deletions lib/doorkeeper/rails/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'doorkeeper/rails/routes/mapping'
require 'doorkeeper/rails/routes/mapper'

Expand Down
Loading

0 comments on commit 0441c87

Please sign in to comment.