pax_global_header 0000666 0000000 0000000 00000000064 14147170026 0014514 g ustar 00root root 0000000 0000000 52 comment=d447d859af7518a6b5feec528a6ba7d80e51da31 omniauth-multipassword-2.0.0.rc1/ 0000775 0000000 0000000 00000000000 14147170026 0016736 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/.editorconfig 0000664 0000000 0000000 00000000345 14147170026 0021415 0 ustar 00root root 0000000 0000000 # EditorConfig is awesome: https://EditorConfig.org # top-most EditorConfig file root = true [*] indent_style = space indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true omniauth-multipassword-2.0.0.rc1/.github/ 0000775 0000000 0000000 00000000000 14147170026 0020276 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/.github/workflows/ 0000775 0000000 0000000 00000000000 14147170026 0022333 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/.github/workflows/test.yml 0000664 0000000 0000000 00000001634 14147170026 0024041 0 ustar 00root root 0000000 0000000 --- name: test on: push jobs: rspec: name: "Ruby ${{ matrix.ruby }}" runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: ruby: - "3.0" - "2.7" - "2.6" - "2.5" steps: - uses: actions/checkout@master - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: True env: BUNDLE_WITHOUT: development BUNDLE_JOBS: 4 BUNDLE_RETRY: 3 - run: bundle exec rspec --color rubocop: name: rubocop runs-on: ubuntu-20.04 steps: - uses: actions/checkout@master - uses: ruby/setup-ruby@v1 with: ruby-version: 3.0 bundler-cache: True env: BUNDLE_WITHOUT: development BUNDLE_JOBS: 4 BUNDLE_RETRY: 3 - run: bundle exec rubocop --parallel --fail-level E omniauth-multipassword-2.0.0.rc1/.gitignore 0000664 0000000 0000000 00000000232 14147170026 0020723 0 ustar 00root root 0000000 0000000 *.gem *.rbc .bundle .config .yardoc Gemfile.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp omniauth-multipassword-2.0.0.rc1/.rspec 0000664 0000000 0000000 00000000014 14147170026 0020046 0 ustar 00root root 0000000 0000000 --backtrace omniauth-multipassword-2.0.0.rc1/.rubocop.yml 0000664 0000000 0000000 00000000246 14147170026 0021212 0 ustar 00root root 0000000 0000000 inherit_gem: my-rubocop: default.yml AllCops: TargetRubyVersion: 2.5 SuggestExtensions: False Naming/FileName: Exclude: - lib/omniauth-multipassword.rb omniauth-multipassword-2.0.0.rc1/.travis.yml 0000664 0000000 0000000 00000000221 14147170026 0021042 0 ustar 00root root 0000000 0000000 sudo: false language: ruby cache: bundler rvm: - '2.4.0' - '2.3.3' - '2.2.6' - '2.1.10' after_success: - bundle exec codeclimate-test-reporter omniauth-multipassword-2.0.0.rc1/CHANGELOG.md 0000664 0000000 0000000 00000000460 14147170026 0020547 0 ustar 00root root 0000000 0000000 # CHANGELOG All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Changelog](http://keepachangelog.com/). ## Unreleased --- ### New ### Changes ### Fixes ### Breaks * Updated strategy to OmniAuth >= 2.0 omniauth-multipassword-2.0.0.rc1/Gemfile 0000664 0000000 0000000 00000000552 14147170026 0020233 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true source 'https://rubygems.org' # Specify your gem's dependencies in omniauth-multipassword.gemspec gemspec gem 'rake' gem 'rake-release' group :test do gem 'rack-test' gem 'rspec', '~> 3.0' gem 'codecov', require: false gem 'simplecov', require: false gem 'my-rubocop', github: 'jgraichen/my-rubocop', ref: 'v2' end omniauth-multipassword-2.0.0.rc1/LICENSE 0000664 0000000 0000000 00000002054 14147170026 0017744 0 ustar 00root root 0000000 0000000 Copyright (c) 2012 Jan Graichen MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. omniauth-multipassword-2.0.0.rc1/README.md 0000664 0000000 0000000 00000003234 14147170026 0020217 0 ustar 00root root 0000000 0000000 # Omniauth::Multipassword [](https://travis-ci.org/jgraichen/omniauth-multipassword) [](https://codeclimate.com/github/jgraichen/omniauth-multipassword) [](https://codeclimate.com/github/jgraichen/omniauth-multipassword/coverage) **omniauth-multipassword** is a [OmniAuth](https://github.com/intridea/omniauth) strategy that allows to authenticate again different password strategies at once. ## Installation Add this line to your application's Gemfile: gem 'omniauth-multipassword' Add multipassword compatible omniauth strategies you want to use: gem 'omniauth-internal' gem 'omniauth-kerberos' And then execute: $ bundle Or install it yourself as: $ gem install omniauth-multipassword ## Usage ```ruby Rails.application.config.middleware.use OmniAuth::Strategies::MultiPassword, fields: [ :auth_key ] do |mp| mp.authenticator :internal mp.authenticator :kerberos end ``` ## Options ** title ** The title text shown on default login form. (default: `"Restricted Access"`) ** fields ** The request parameter names to fetch username and password. (default: `[ "username", "password" ]`) ### Compatible Strategies * [omniauth-internal](https://github.com/jgraichen/omniauth-internal) * [omniauth-kerberos](https://github.com/jgraichen/omniauth-kerberos) ## License [MIT License](http://www.opensource.org/licenses/mit-license.php) Copyright (c) 2012, Jan Graichen omniauth-multipassword-2.0.0.rc1/Rakefile 0000664 0000000 0000000 00000000213 14147170026 0020377 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require 'rake/release' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task default: :spec omniauth-multipassword-2.0.0.rc1/lib/ 0000775 0000000 0000000 00000000000 14147170026 0017504 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/lib/omniauth-multipassword.rb 0000664 0000000 0000000 00000000233 14147170026 0024566 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require 'omniauth/multipassword/base' require 'omniauth/multipassword/version' require 'omniauth/strategies/multi_password' omniauth-multipassword-2.0.0.rc1/lib/omniauth/ 0000775 0000000 0000000 00000000000 14147170026 0021330 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/lib/omniauth/multipassword/ 0000775 0000000 0000000 00000000000 14147170026 0024245 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/lib/omniauth/multipassword/base.rb 0000664 0000000 0000000 00000002565 14147170026 0025514 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module OmniAuth module MultiPassword module Base def self.included(base) base.class_eval do option :title, 'Restricted Access' option :fields, %i[username password] uid { username } end end def username_id options[:fields][0] || 'username' end def password_id options[:fields][1] || 'password' end def username @username || request[username_id].to_s end def init_authenticator(request, env, username) @request = request @env = env @username = username end def callback_phase if authenticate(username, request[password_id]) super else fail!(:invalid_credentials) end end def request_phase OmniAuth::Form.build(title: options.title, url: callback_url) do |f| f.text_field 'Username', username_id f.password_field 'Password', password_id end.to_response end def other_phase # OmniAuth, by default, disables "GET" requests for security reasons. # This effectively disables showing a password form on a GET request to # the `request_phase`. Instead, we hook the GET requests here. return request_phase if on_request_path? end end end end omniauth-multipassword-2.0.0.rc1/lib/omniauth/multipassword/version.rb 0000664 0000000 0000000 00000000413 14147170026 0026255 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module Omniauth module Multipassword module VERSION MAJOR = 2 MINOR = 0 PATCH = 0 STAGE = 'rc1' def self.to_s [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join '.' end end end end omniauth-multipassword-2.0.0.rc1/lib/omniauth/strategies/ 0000775 0000000 0000000 00000000000 14147170026 0023502 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/lib/omniauth/strategies/multi_password.rb 0000664 0000000 0000000 00000004302 14147170026 0027102 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require 'omniauth' require 'omniauth/multipassword/base' module OmniAuth module Strategies class MultiPassword include OmniAuth::Strategy include OmniAuth::MultiPassword::Base def initialize(app, *args, &block) super(app, *args) do # Do pass an empty block, as otherwise the captured block would be # passed to `super`, but this needs to be evaluate inside this # middleware, not omniauth's Rack builder instance. end if block.arity.zero? instance_eval(&block) else yield self end end def options yield @options if block_given? @options end def authenticator(klass, *args, &block) unless klass.is_a?(Class) begin klass = OmniAuth::Strategies.const_get(OmniAuth::Utils.camelize(klass.to_s).to_s) rescue NameError raise LoadError.new("Could not find matching strategy for #{klass.inspect}." \ "You may need to install an additional gem (such as omniauth-#{klass}).") end end args << block if block @authenticators ||= [] @authenticators << [klass, args] end def callback_phase username = request[username_id].to_s password = request[password_id].to_s if authenticate(username, password) super else fail!(:invalid_credentials) end end def authenticate(username, password) @authenticators.each do |auth| begin @authenticator = auth[0].new @app, *auth[1] @authenticator.init_authenticator(@request, @env, username) return true if @authenticator.authenticate(username, password) rescue Error => e OmniAuth.logger.warn "OmniAuth ERR >>> #{e}" end @authenticator = nil end false end def name return @authenticator.name if @authenticator super end info do info = @authenticator.info if @authenticator info = {} unless info.is_a?(Hash) info end end end end omniauth-multipassword-2.0.0.rc1/omniauth-multipassword.gemspec 0000664 0000000 0000000 00000001764 14147170026 0025052 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require File.expand_path('lib/omniauth/multipassword/version', __dir__) Gem::Specification.new do |gem| gem.authors = ['Jan Graichen'] gem.email = ['jgraichen@altimos.de'] gem.description = 'A OmniAuth strategy to authenticate using different passwort strategies.' gem.summary = 'A OmniAuth strategy to authenticate using different passwort strategies.' gem.homepage = 'https://github.com/jgraichen/omniauth-multipassword' gem.license = 'MIT' gem.required_ruby_version = '>= 2.5' gem.metadata = { 'rubygems_mfa_required' => 'true', } gem.executables = `git ls-files -- bin/*`.split("\n").map {|f| File.basename(f) } gem.files = `git ls-files`.split("\n") gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") gem.name = 'omniauth-multipassword' gem.require_paths = ['lib'] gem.version = Omniauth::Multipassword::VERSION gem.add_dependency 'omniauth', '~> 2.0' end omniauth-multipassword-2.0.0.rc1/spec/ 0000775 0000000 0000000 00000000000 14147170026 0017670 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/spec/omniauth/ 0000775 0000000 0000000 00000000000 14147170026 0021514 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/spec/omniauth/multipassword/ 0000775 0000000 0000000 00000000000 14147170026 0024431 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.0.rc1/spec/omniauth/multipassword/base_spec.rb 0000664 0000000 0000000 00000003457 14147170026 0026713 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require 'spec_helper' require 'rack/test' describe OmniAuth::MultiPassword::Base do # rubocop:disable RSpec/FilePath subject { strategy } let(:app) { instance_double(Proc) } let(:strategy) do OmniAuth::Strategies::OneTest.new(app, *args, &block) end let(:args) { [] } let(:block) { nil } describe '#username_id' do subject(:username_id) { strategy.username_id } it 'defaults to :username' do expect(username_id).to eq :username end context 'when configured' do let(:args) { [{fields: %i[user pass]}] } it { is_expected.to eq :user } end end describe '#password_id' do subject(:password_id) { strategy.password_id } it 'defaults to :password' do expect(password_id).to eq :password end context 'when configured' do let(:args) { [{fields: %i[user pass]}] } it { is_expected.to eq :pass } end end describe 'single strategy' do include Rack::Test::Methods let(:app) do Rack::Builder.new do use OmniAuth::Test::PhonySession use OmniAuth::Strategies::OneTest run ->(env) { [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] } end.to_app end it 'shows login FORM' do get '/auth/onetest' expect(last_response.body).to include '