pax_global_header 0000666 0000000 0000000 00000000064 14646743633 0014532 g ustar 00root root 0000000 0000000 52 comment=65615fc53ef4f72c7dd4fb8b67489354c622dd6e omniauth-multipassword-2.0.1/ 0000775 0000000 0000000 00000000000 14646743633 0016271 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/.editorconfig 0000664 0000000 0000000 00000000345 14646743633 0020750 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.1/.github/ 0000775 0000000 0000000 00000000000 14646743633 0017631 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/.github/workflows/ 0000775 0000000 0000000 00000000000 14646743633 0021666 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/.github/workflows/maintenance-cache-wipe.yml 0000664 0000000 0000000 00000000300 14646743633 0026667 0 ustar 00root root 0000000 0000000 --- name: maintenance-cache-clear on: schedule: - cron: "0 0 1 * *" workflow_dispatch: jobs: cache-clear: runs-on: ubuntu-latest steps: - uses: easimon/wipe-cache@v2 omniauth-multipassword-2.0.1/.github/workflows/maintenance-workflow-cleanup.yml 0000664 0000000 0000000 00000000565 14646743633 0030176 0 ustar 00root root 0000000 0000000 --- name: maintenance-workflow-cleanup on: schedule: - cron: "0 0 1 * *" workflow_dispatch: jobs: delete-workflow-runs: runs-on: ubuntu-latest steps: - uses: Mattraks/delete-workflow-runs@v2 with: token: ${{ github.token }} repository: ${{ github.repository }} retain_days: 180 keep_minimum_runs: 50 omniauth-multipassword-2.0.1/.github/workflows/test.yml 0000664 0000000 0000000 00000002375 14646743633 0023377 0 ustar 00root root 0000000 0000000 --- name: test on: - push - pull_request - workflow_dispatch jobs: rspec: name: "Ruby ${{ matrix.ruby }} / ${{ matrix.gemfile }}" runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: ruby: - "3.3" - "3.2" - "3.1" - "3.0" - "2.7" gemfile: - omniauth_2.0 - omniauth_2.1 env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile BUNDLE_WITHOUT: development steps: - uses: actions/checkout@master - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true env: BUNDLE_JOBS: 4 BUNDLE_RETRY: 3 - run: | bundle exec rspec --color --format documentation - uses: codecov/codecov-action@v4 with: fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} rubocop: name: rubocop runs-on: ubuntu-22.04 steps: - uses: actions/checkout@master - uses: ruby/setup-ruby@v1 with: ruby-version: "3.3" bundler-cache: true env: BUNDLE_JOBS: 4 BUNDLE_RETRY: 3 - run: bundle exec rubocop --parallel --fail-level E omniauth-multipassword-2.0.1/.gitignore 0000664 0000000 0000000 00000000224 14646743633 0020257 0 ustar 00root root 0000000 0000000 _yardoc .bundle .config .yardoc *.gem *.rbc coverage doc/ *.lock InstalledFiles lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp omniauth-multipassword-2.0.1/.rspec 0000664 0000000 0000000 00000000014 14646743633 0017401 0 ustar 00root root 0000000 0000000 --backtrace omniauth-multipassword-2.0.1/.rubocop.yml 0000664 0000000 0000000 00000000254 14646743633 0020544 0 ustar 00root root 0000000 0000000 inherit_gem: rubocop-config: default.yml AllCops: TargetRubyVersion: "2.7" SuggestExtensions: False Naming/FileName: Exclude: - lib/omniauth-multipassword.rb omniauth-multipassword-2.0.1/Appraisals 0000664 0000000 0000000 00000000226 14646743633 0020313 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true appraise 'omniauth-2.0' do gem 'omniauth', '~> 2.0.0' end appraise 'omniauth-2.1' do gem 'omniauth', '~> 2.1' end omniauth-multipassword-2.0.1/CHANGELOG.md 0000664 0000000 0000000 00000001314 14646743633 0020101 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] ## [2.0.1] - 2024-07-20 ### Changed - Version bump due to wrong tag ## [2.0.0] - 2024-07-20 ### Added - Add compatibility with newer Rack and OmniAuth 2.1+ ### Changed - Updated strategy to OmniAuth >= 2.0 - Drop support for Ruby < 2.7 [Unreleased]: https://github.com/jgraichen/omniauth-multipassword/compare/v2.0.1...HEAD [2.0.1]: https://github.com/jgraichen/omniauth-multipassword/compare/v2.0.0...v2.0.1 [2.0.0]: https://github.com/jgraichen/omniauth-multipassword/releases/tag/v2.0.0 omniauth-multipassword-2.0.1/Gemfile 0000664 0000000 0000000 00000000612 14646743633 0017563 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 'appraisal' gem 'rake' gem 'rake-release' group :test do gem 'rack-test' gem 'rspec', '~> 3.0' gem 'simplecov' gem 'simplecov-cobertura' end group :development do gem 'rubocop-config', github: 'jgraichen/rubocop-config', ref: 'v12' end omniauth-multipassword-2.0.1/LICENSE 0000664 0000000 0000000 00000002054 14646743633 0017277 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.1/README.md 0000664 0000000 0000000 00000003234 14646743633 0017552 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.1/Rakefile 0000664 0000000 0000000 00000000213 14646743633 0017732 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.1/gemfiles/ 0000775 0000000 0000000 00000000000 14646743633 0020064 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/gemfiles/omniauth_2.0.gemfile 0000664 0000000 0000000 00000000563 14646743633 0023625 0 ustar 00root root 0000000 0000000 # This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "rake" gem "rake-release" gem "omniauth", "~> 2.0.0" group :test do gem "rack-test" gem "rspec", "~> 3.0" gem "simplecov" gem "simplecov-cobertura" end group :development do gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12" end gemspec path: "../" omniauth-multipassword-2.0.1/gemfiles/omniauth_2.1.gemfile 0000664 0000000 0000000 00000000561 14646743633 0023624 0 ustar 00root root 0000000 0000000 # This file was generated by Appraisal source "https://rubygems.org" gem "appraisal" gem "rake" gem "rake-release" gem "omniauth", "~> 2.1" group :test do gem "rack-test" gem "rspec", "~> 3.0" gem "simplecov" gem "simplecov-cobertura" end group :development do gem "rubocop-config", github: "jgraichen/rubocop-config", ref: "v12" end gemspec path: "../" omniauth-multipassword-2.0.1/lib/ 0000775 0000000 0000000 00000000000 14646743633 0017037 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/lib/omniauth-multipassword.rb 0000664 0000000 0000000 00000000233 14646743633 0024121 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.1/lib/omniauth/ 0000775 0000000 0000000 00000000000 14646743633 0020663 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/lib/omniauth/multipassword/ 0000775 0000000 0000000 00000000000 14646743633 0023600 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/lib/omniauth/multipassword/base.rb 0000664 0000000 0000000 00000002616 14646743633 0025044 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.dig(:fields, 0) || 'username' end def password_id options.dig(:fields, 1) || 'password' end def username @username || request.params[username_id.to_s].to_s end def init_authenticator(request, env, username) @request = request @env = env @username = username end def callback_phase if authenticate(username, request.params[password_id.to_s]) 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. request_phase if on_request_path? end end end end omniauth-multipassword-2.0.1/lib/omniauth/multipassword/version.rb 0000664 0000000 0000000 00000000402 14646743633 0025606 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true module Omniauth module Multipassword module VERSION MAJOR = 2 MINOR = 0 PATCH = 1 STAGE = nil def self.to_s [MAJOR, MINOR, PATCH, STAGE].compact.join '.' end end end end omniauth-multipassword-2.0.1/lib/omniauth/strategies/ 0000775 0000000 0000000 00000000000 14646743633 0023035 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/lib/omniauth/strategies/multi_password.rb 0000664 0000000 0000000 00000004332 14646743633 0026440 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.params[username_id.to_s].to_s password = request.params[password_id.to_s].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.1/omniauth-multipassword.gemspec 0000664 0000000 0000000 00000001651 14646743633 0024400 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.name = 'omniauth-multipassword' gem.version = Omniauth::Multipassword::VERSION 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.7' 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.require_paths = ['lib'] gem.add_dependency 'omniauth', '~> 2.0' end omniauth-multipassword-2.0.1/renovate.json 0000664 0000000 0000000 00000000177 14646743633 0021014 0 ustar 00root root 0000000 0000000 { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ "local>jgraichen/renovate-config" ] } omniauth-multipassword-2.0.1/spec/ 0000775 0000000 0000000 00000000000 14646743633 0017223 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/spec/omniauth/ 0000775 0000000 0000000 00000000000 14646743633 0021047 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/spec/omniauth/multipassword/ 0000775 0000000 0000000 00000000000 14646743633 0023764 5 ustar 00root root 0000000 0000000 omniauth-multipassword-2.0.1/spec/omniauth/multipassword/base_spec.rb 0000664 0000000 0000000 00000003467 14646743633 0026247 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require 'spec_helper' require 'rack/test' describe OmniAuth::MultiPassword::Base do # rubocop:disable RSpec/SpecFilePathFormat 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 '