omniauth-multipassword 0.4.2 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d5f7c8a3656ca4686749bd2b4d273cc1460d39ba
4
- data.tar.gz: eb372de5e8f9ead660e3631e6b66c9c8ed34a158
2
+ SHA256:
3
+ metadata.gz: 4c42cc59feffb560101a1ca960ea75b5099054097dc688570f814fde8a07d33a
4
+ data.tar.gz: d8a94787d62f2d9ab2a8435cbaa81d087a4a2332e703a560fa907e3da0c9f9d5
5
5
  SHA512:
6
- metadata.gz: 513e554cf46d322762dfbff65e764aea532ff2986de7af99770d9f84383b336b63af43492a5a95b63cb853f53cdd0f2bf0f33e190550fa0898ef955657fe07a0
7
- data.tar.gz: c15f2b750cba4a41c170d2a983d74d8185665f3c0e70c44895ce268f7a1bdc54a1f7d713e8b7d1e5d58441ae9dd030e665b15f66bf6636ee98303b90f20ef5ad
6
+ metadata.gz: caef3ce2da16ace112cb73c2f178fb3909ad5fe184f57912cc0ae50622511e6f581638c0f4ab79d84c39229486b2114cc4799d47ba1057e02129392f892e4173
7
+ data.tar.gz: 2bb20ced2304ba9496012e1b186619b7149fc4c19265b013305afb1ce68a3c76b12fa1d7300432f38851fe6d7e1c7fa21225f337b227da89662b47ace17d9937
data/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ # EditorConfig is awesome: https://EditorConfig.org
2
+
3
+ # top-most EditorConfig file
4
+ root = true
5
+
6
+ [*]
7
+ indent_style = space
8
+ indent_size = 2
9
+ end_of_line = lf
10
+ charset = utf-8
11
+ trim_trailing_whitespace = true
12
+ insert_final_newline = true
@@ -0,0 +1,46 @@
1
+ ---
2
+ name: test
3
+ on: push
4
+ jobs:
5
+ rspec:
6
+ name: "Ruby ${{ matrix.ruby }}"
7
+ runs-on: ubuntu-20.04
8
+
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby:
13
+ - "3.0"
14
+ - "2.7"
15
+ - "2.6"
16
+ - "2.5"
17
+
18
+ steps:
19
+ - uses: actions/checkout@master
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: True
24
+ env:
25
+ BUNDLE_WITHOUT: development
26
+ BUNDLE_JOBS: 4
27
+ BUNDLE_RETRY: 3
28
+
29
+ - run: bundle exec rspec --color
30
+
31
+ rubocop:
32
+ name: rubocop
33
+ runs-on: ubuntu-20.04
34
+
35
+ steps:
36
+ - uses: actions/checkout@master
37
+ - uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: 3.0
40
+ bundler-cache: True
41
+ env:
42
+ BUNDLE_WITHOUT: development
43
+ BUNDLE_JOBS: 4
44
+ BUNDLE_RETRY: 3
45
+
46
+ - run: bundle exec rubocop --parallel --fail-level E
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --backtrace
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ inherit_gem:
2
+ my-rubocop: default.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.5
6
+ SuggestExtensions: False
7
+
8
+ Naming/FileName:
9
+ Exclude:
10
+ - lib/omniauth-multipassword.rb
data/.travis.yml CHANGED
@@ -2,8 +2,9 @@ sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - '2.1'
6
- - '2.0'
7
- - 1.9.3
8
- - jruby
9
- - rbx-2
5
+ - '2.4.0'
6
+ - '2.3.3'
7
+ - '2.2.6'
8
+ - '2.1.10'
9
+ after_success:
10
+ - bundle exec codeclimate-test-reporter
data/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ # CHANGELOG
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Changelog](http://keepachangelog.com/).
5
+
6
+ ## Unreleased
7
+ ---
8
+
9
+ ### New
10
+
11
+ ### Changes
12
+
13
+ ### Fixes
14
+
15
+ ### Breaks
16
+ * Updated strategy to OmniAuth >= 2.0
17
+
18
+
data/Gemfile CHANGED
@@ -1,10 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in omniauth-multipassword.gemspec
4
6
  gemspec
5
7
 
6
8
  gem 'rake'
7
- gem 'rack-test'
8
- gem 'rspec'
9
- gem 'simplecov'
10
- gem "codeclimate-test-reporter"
9
+ gem 'rake-release'
10
+
11
+ group :test do
12
+ gem 'rack-test'
13
+
14
+ gem 'rspec', '~> 3.0'
15
+
16
+ gem 'codecov', require: false
17
+ gem 'simplecov', require: false
18
+
19
+ gem 'my-rubocop', github: 'jgraichen/my-rubocop', ref: 'v2'
20
+ end
data/Rakefile CHANGED
@@ -1,4 +1,6 @@
1
- require 'bundler/gem_tasks'
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake/release'
2
4
  require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
@@ -1,21 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module OmniAuth
2
4
  module MultiPassword
3
5
  module Base
4
6
  def self.included(base)
5
7
  base.class_eval do
6
- option :title, "Restricted Access"
7
- option :fields, [ :username, :password ]
8
+ option :title, 'Restricted Access'
9
+ option :fields, %i[username password]
8
10
 
9
- uid { username }
11
+ uid { username }
10
12
  end
11
13
  end
12
14
 
13
15
  def username_id
14
- options[:fields][0] || "username"
16
+ options[:fields][0] || 'username'
15
17
  end
16
18
 
17
19
  def password_id
18
- options[:fields][1] || "password"
20
+ options[:fields][1] || 'password'
19
21
  end
20
22
 
21
23
  def username
@@ -37,11 +39,18 @@ module OmniAuth
37
39
  end
38
40
 
39
41
  def request_phase
40
- OmniAuth::Form.build(:title => options.title, :url => callback_url) do |f|
41
- f.text_field "Username", username_id
42
- f.password_field "Password", password_id
42
+ OmniAuth::Form.build(title: options.title, url: callback_url) do |f|
43
+ f.text_field 'Username', username_id
44
+ f.password_field 'Password', password_id
43
45
  end.to_response
44
46
  end
47
+
48
+ def other_phase
49
+ # OmniAuth, by default, disables "GET" requests for security reasons.
50
+ # This effectively disables showing a password form on a GET request to
51
+ # the `request_phase`. Instead, we hook the GET requests here.
52
+ return request_phase if on_request_path?
53
+ end
45
54
  end
46
55
  end
47
56
  end
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Omniauth
2
4
  module Multipassword
3
5
  module VERSION
4
- MAJOR = 0
5
- MINOR = 4
6
- PATCH = 2
7
- STAGE = nil
6
+ MAJOR = 2
7
+ MINOR = 0
8
+ PATCH = 0
9
+ STAGE = 'rc1'
8
10
 
9
11
  def self.to_s
10
12
  [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join '.'
@@ -1,5 +1,7 @@
1
- require "omniauth"
2
- require "omniauth/multipassword/base"
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth'
4
+ require 'omniauth/multipassword/base'
3
5
 
4
6
  module OmniAuth
5
7
  module Strategies
@@ -8,12 +10,16 @@ module OmniAuth
8
10
  include OmniAuth::MultiPassword::Base
9
11
 
10
12
  def initialize(app, *args, &block)
11
- super(app, *args) do end
13
+ super(app, *args) do
14
+ # Do pass an empty block, as otherwise the captured block would be
15
+ # passed to `super`, but this needs to be evaluate inside this
16
+ # middleware, not omniauth's Rack builder instance.
17
+ end
12
18
 
13
- if block.arity == 0
14
- instance_eval &block
19
+ if block.arity.zero?
20
+ instance_eval(&block)
15
21
  else
16
- block.call self
22
+ yield self
17
23
  end
18
24
  end
19
25
 
@@ -25,16 +31,16 @@ module OmniAuth
25
31
  def authenticator(klass, *args, &block)
26
32
  unless klass.is_a?(Class)
27
33
  begin
28
- klass = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
34
+ klass = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s)
29
35
  rescue NameError
30
- raise LoadError, "Could not find matching strategy for #{klass.inspect}." +
31
- "You may need to install an additional gem (such as omniauth-#{klass})."
36
+ raise LoadError.new("Could not find matching strategy for #{klass.inspect}." \
37
+ "You may need to install an additional gem (such as omniauth-#{klass}).")
32
38
  end
33
39
  end
34
40
 
35
41
  args << block if block
36
42
  @authenticators ||= []
37
- @authenticators << [ klass, args ]
43
+ @authenticators << [klass, args]
38
44
  end
39
45
 
40
46
  def callback_phase
@@ -43,7 +49,7 @@ module OmniAuth
43
49
  if authenticate(username, password)
44
50
  super
45
51
  else
46
- return fail!(:invalid_credentials)
52
+ fail!(:invalid_credentials)
47
53
  end
48
54
  end
49
55
 
@@ -52,11 +58,9 @@ module OmniAuth
52
58
  begin
53
59
  @authenticator = auth[0].new @app, *auth[1]
54
60
  @authenticator.init_authenticator(@request, @env, username)
55
- if @authenticator.authenticate(username, password)
56
- return true
57
- end
61
+ return true if @authenticator.authenticate(username, password)
58
62
  rescue Error => e
59
- OmniAuth.logger.warn "OmniAuth ERR >>> " + e
63
+ OmniAuth.logger.warn "OmniAuth ERR >>> #{e}"
60
64
  end
61
65
  @authenticator = nil
62
66
  end
@@ -65,6 +69,7 @@ module OmniAuth
65
69
 
66
70
  def name
67
71
  return @authenticator.name if @authenticator
72
+
68
73
  super
69
74
  end
70
75
 
@@ -1,3 +1,5 @@
1
- require "omniauth/multipassword/base"
2
- require "omniauth/multipassword/version"
3
- require "omniauth/strategies/multi_password"
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/multipassword/base'
4
+ require 'omniauth/multipassword/version'
5
+ require 'omniauth/strategies/multi_password'
@@ -1,20 +1,26 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/omniauth/multipassword/version', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path('lib/omniauth/multipassword/version', __dir__)
3
4
 
4
5
  Gem::Specification.new do |gem|
5
- gem.authors = ["Jan Graichen"]
6
- gem.email = ["jg@altimos.de"]
7
- gem.description = "A OmniAuth strategy to authenticate using different passwort strategies."
8
- gem.summary = "A OmniAuth strategy to authenticate using different passwort strategies."
9
- gem.homepage = "https://github.com/jgraichen/omniauth-multipassword"
6
+ gem.authors = ['Jan Graichen']
7
+ gem.email = ['jgraichen@altimos.de']
8
+ gem.description = 'A OmniAuth strategy to authenticate using different passwort strategies.'
9
+ gem.summary = 'A OmniAuth strategy to authenticate using different passwort strategies.'
10
+ gem.homepage = 'https://github.com/jgraichen/omniauth-multipassword'
10
11
  gem.license = 'MIT'
11
12
 
12
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
13
+ gem.required_ruby_version = '>= 2.5'
14
+ gem.metadata = {
15
+ 'rubygems_mfa_required' => 'true',
16
+ }
17
+
18
+ gem.executables = `git ls-files -- bin/*`.split("\n").map {|f| File.basename(f) }
13
19
  gem.files = `git ls-files`.split("\n")
14
20
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
- gem.name = "omniauth-multipassword"
16
- gem.require_paths = ["lib"]
21
+ gem.name = 'omniauth-multipassword'
22
+ gem.require_paths = ['lib']
17
23
  gem.version = Omniauth::Multipassword::VERSION
18
24
 
19
- gem.add_dependency 'omniauth', '~> 1.0'
25
+ gem.add_dependency 'omniauth', '~> 2.0'
20
26
  end
@@ -1,48 +1,42 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'rack/test'
3
5
 
4
- describe OmniAuth::MultiPassword::Base do
5
- let(:app) { double 'app' }
6
- let(:args) { [] }
7
- let(:block) { nil }
8
-
9
- class OmniAuth::Strategy::OneTest
10
- include OmniAuth::Strategy
11
- include OmniAuth::MultiPassword::Base
12
-
13
- def authenticate(username, password)
14
- username == 'john' && password == 'secret'
15
- end
16
- end
6
+ describe OmniAuth::MultiPassword::Base do # rubocop:disable RSpec/FilePath
7
+ subject { strategy }
17
8
 
9
+ let(:app) { instance_double(Proc) }
18
10
  let(:strategy) do
19
- OmniAuth::Strategy::OneTest.new(app, *args, &block)
11
+ OmniAuth::Strategies::OneTest.new(app, *args, &block)
20
12
  end
21
-
22
- subject { strategy }
13
+ let(:args) { [] }
14
+ let(:block) { nil }
23
15
 
24
16
  describe '#username_id' do
25
- subject { strategy.username_id }
17
+ subject(:username_id) { strategy.username_id }
26
18
 
27
19
  it 'defaults to :username' do
28
- is_expected.to eq :username
20
+ expect(username_id).to eq :username
29
21
  end
30
22
 
31
23
  context 'when configured' do
32
- let(:args) { [{fields: [:user, :pass]}] }
24
+ let(:args) { [{fields: %i[user pass]}] }
25
+
33
26
  it { is_expected.to eq :user }
34
27
  end
35
28
  end
36
29
 
37
30
  describe '#password_id' do
38
- subject { strategy.password_id }
31
+ subject(:password_id) { strategy.password_id }
39
32
 
40
33
  it 'defaults to :password' do
41
- is_expected.to eq :password
34
+ expect(password_id).to eq :password
42
35
  end
43
36
 
44
37
  context 'when configured' do
45
- let(:args) { [{fields: [:user, :pass]}] }
38
+ let(:args) { [{fields: %i[user pass]}] }
39
+
46
40
  it { is_expected.to eq :pass }
47
41
  end
48
42
  end
@@ -51,11 +45,11 @@ describe OmniAuth::MultiPassword::Base do
51
45
  include Rack::Test::Methods
52
46
 
53
47
  let(:app) do
54
- Rack::Builder.new {
48
+ Rack::Builder.new do
55
49
  use OmniAuth::Test::PhonySession
56
50
  use OmniAuth::Strategies::OneTest
57
51
  run ->(env) { [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
58
- }.to_app
52
+ end.to_app
59
53
  end
60
54
 
61
55
  it 'shows login FORM' do
@@ -1,36 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'rack/test'
3
5
 
4
- describe OmniAuth::Strategies::MultiPassword do
6
+ describe OmniAuth::Strategies::MultiPassword do # rubocop:disable RSpec/FilePath
5
7
  include Rack::Test::Methods
6
8
 
7
- class OmniAuth::Strategies::OneTest
8
- include OmniAuth::Strategy
9
- include OmniAuth::MultiPassword::Base
10
-
11
- def authenticate(username, password)
12
- username == 'john' && password == 'secret'
13
- end
14
- end
15
-
16
- class OmniAuth::Strategies::TwoTest
17
- include OmniAuth::Strategy
18
- include OmniAuth::MultiPassword::Base
19
-
20
- def authenticate(username, password)
21
- username == 'jane' && password == '1234'
22
- end
23
- end
24
-
25
9
  let(:app) do
26
- Rack::Builder.new {
10
+ Rack::Builder.new do
27
11
  use OmniAuth::Test::PhonySession
28
12
  use OmniAuth::Strategies::MultiPassword do
29
13
  authenticator :one_test
30
14
  authenticator :two_test
31
15
  end
32
16
  run ->(env) { [404, {'Content-Type' => 'text/plain'}, [env['omniauth.auth']['uid'].to_s]] }
33
- }.to_app
17
+ end.to_app
34
18
  end
35
19
 
36
20
  it 'shows login FORM' do
@@ -41,17 +25,20 @@ describe OmniAuth::Strategies::MultiPassword do
41
25
 
42
26
  it 'redirect on all failed strategies' do
43
27
  post '/auth/multipassword/callback', username: 'paul', password: 'wrong'
28
+
44
29
  expect(last_response).to be_redirect
45
30
  expect(last_response.headers['Location']).to eq '/auth/failure?message=invalid_credentials&strategy=multipassword'
46
31
  end
47
32
 
48
33
  it 'authenticates john' do
49
34
  post '/auth/multipassword/callback', username: 'john', password: 'secret'
35
+
50
36
  expect(last_response.body).to eq 'john'
51
37
  end
52
38
 
53
39
  it 'authenticates jane' do
54
40
  post '/auth/multipassword/callback', username: 'jane', password: '1234'
41
+
55
42
  expect(last_response.body).to eq 'jane'
56
43
  end
57
44
  end
data/spec/spec_helper.rb CHANGED
@@ -1,30 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rspec'
2
4
  require 'simplecov'
3
5
 
4
- if ENV['CI'] || (defined?(:RUBY_ENGINE) && RUBY_ENGINE != 'rbx')
5
- begin
6
- require 'codeclimate-test-reporter'
7
- CodeClimate::TestReporter.start
8
- rescue LoadError
9
- end
10
- SimpleCov.start
6
+ if ENV['CI']
7
+ require 'codecov'
8
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
11
9
  end
12
10
 
13
- require 'omniauth-multipassword'
14
-
15
- Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f }
16
-
17
- # Disable omniauth logger
18
- class NullLogger < Logger
19
- def initialize(*args)
20
- end
21
-
22
- def add(*args, &block)
23
- end
11
+ SimpleCov.start do
12
+ add_filter 'spec'
24
13
  end
25
14
 
26
- OmniAuth.config.logger = NullLogger.new
15
+ require 'omniauth-multipassword'
16
+
17
+ Dir[File.expand_path('spec/support/**/*.rb')].sort.each {|f| require f }
27
18
 
28
19
  RSpec.configure do |config|
29
20
  config.order = 'random'
21
+
22
+ config.before do
23
+ OmniAuth.config.logger = Logger.new(IO::NULL)
24
+ end
30
25
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class OneTest
6
+ include OmniAuth::Strategy
7
+ include OmniAuth::MultiPassword::Base
8
+
9
+ def authenticate(username, password)
10
+ username == 'john' && password == 'secret'
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ module OmniAuth
17
+ module Strategies
18
+ class TwoTest
19
+ include OmniAuth::Strategy
20
+ include OmniAuth::MultiPassword::Base
21
+
22
+ def authenticate(username, password)
23
+ username == 'jane' && password == '1234'
24
+ end
25
+ end
26
+ end
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-multipassword
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 2.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-18 00:00:00.000000000 Z
11
+ date: 2021-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -16,23 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  description: A OmniAuth strategy to authenticate using different passwort strategies.
28
28
  email:
29
- - jg@altimos.de
29
+ - jgraichen@altimos.de
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".editorconfig"
35
+ - ".github/workflows/test.yml"
34
36
  - ".gitignore"
37
+ - ".rspec"
38
+ - ".rubocop.yml"
35
39
  - ".travis.yml"
40
+ - CHANGELOG.md
36
41
  - Gemfile
37
42
  - LICENSE
38
43
  - README.md
@@ -45,10 +50,12 @@ files:
45
50
  - spec/omniauth/multipassword/base_spec.rb
46
51
  - spec/omniauth/strategy/multi_password_spec.rb
47
52
  - spec/spec_helper.rb
53
+ - spec/support/strategies.rb
48
54
  homepage: https://github.com/jgraichen/omniauth-multipassword
49
55
  licenses:
50
56
  - MIT
51
- metadata: {}
57
+ metadata:
58
+ rubygems_mfa_required: 'true'
52
59
  post_install_message:
53
60
  rdoc_options: []
54
61
  require_paths:
@@ -57,15 +64,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
57
64
  requirements:
58
65
  - - ">="
59
66
  - !ruby/object:Gem::Version
60
- version: '0'
67
+ version: '2.5'
61
68
  required_rubygems_version: !ruby/object:Gem::Requirement
62
69
  requirements:
63
- - - ">="
70
+ - - ">"
64
71
  - !ruby/object:Gem::Version
65
- version: '0'
72
+ version: 1.3.1
66
73
  requirements: []
67
- rubyforge_project:
68
- rubygems_version: 2.4.6
74
+ rubygems_version: 3.2.22
69
75
  signing_key:
70
76
  specification_version: 4
71
77
  summary: A OmniAuth strategy to authenticate using different passwort strategies.