pax_global_header00006660000000000000000000000064146467436330014532gustar00rootroot0000000000000052 comment=65615fc53ef4f72c7dd4fb8b67489354c622dd6e omniauth-multipassword-2.0.1/000077500000000000000000000000001464674363300162715ustar00rootroot00000000000000omniauth-multipassword-2.0.1/.editorconfig000066400000000000000000000003451464674363300207500ustar00rootroot00000000000000# 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/000077500000000000000000000000001464674363300176315ustar00rootroot00000000000000omniauth-multipassword-2.0.1/.github/workflows/000077500000000000000000000000001464674363300216665ustar00rootroot00000000000000omniauth-multipassword-2.0.1/.github/workflows/maintenance-cache-wipe.yml000066400000000000000000000003001464674363300266670ustar00rootroot00000000000000--- 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.yml000066400000000000000000000005651464674363300301760ustar00rootroot00000000000000--- 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.yml000066400000000000000000000023751464674363300233770ustar00rootroot00000000000000--- 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/.gitignore000066400000000000000000000002241464674363300202570ustar00rootroot00000000000000_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/.rspec000066400000000000000000000000141464674363300174010ustar00rootroot00000000000000--backtrace omniauth-multipassword-2.0.1/.rubocop.yml000066400000000000000000000002541464674363300205440ustar00rootroot00000000000000inherit_gem: rubocop-config: default.yml AllCops: TargetRubyVersion: "2.7" SuggestExtensions: False Naming/FileName: Exclude: - lib/omniauth-multipassword.rb omniauth-multipassword-2.0.1/Appraisals000066400000000000000000000002261464674363300203130ustar00rootroot00000000000000# 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.md000066400000000000000000000013141464674363300201010ustar00rootroot00000000000000# 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/Gemfile000066400000000000000000000006121464674363300175630ustar00rootroot00000000000000# 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/LICENSE000066400000000000000000000020541464674363300172770ustar00rootroot00000000000000Copyright (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.md000066400000000000000000000032341464674363300175520ustar00rootroot00000000000000# Omniauth::Multipassword [![Build Status](https://travis-ci.org/jgraichen/omniauth-multipassword.svg?branch=master)](https://travis-ci.org/jgraichen/omniauth-multipassword) [![Code Climate](https://codeclimate.com/github/jgraichen/omniauth-multipassword/badges/gpa.svg)](https://codeclimate.com/github/jgraichen/omniauth-multipassword) [![Test Coverage](https://codeclimate.com/github/jgraichen/omniauth-multipassword/badges/coverage.svg)](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/Rakefile000066400000000000000000000002131464674363300177320ustar00rootroot00000000000000# 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/000077500000000000000000000000001464674363300200645ustar00rootroot00000000000000omniauth-multipassword-2.0.1/gemfiles/omniauth_2.0.gemfile000066400000000000000000000005631464674363300236250ustar00rootroot00000000000000# 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.gemfile000066400000000000000000000005611464674363300236240ustar00rootroot00000000000000# 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/000077500000000000000000000000001464674363300170375ustar00rootroot00000000000000omniauth-multipassword-2.0.1/lib/omniauth-multipassword.rb000066400000000000000000000002331464674363300241210ustar00rootroot00000000000000# frozen_string_literal: true require 'omniauth/multipassword/base' require 'omniauth/multipassword/version' require 'omniauth/strategies/multi_password' omniauth-multipassword-2.0.1/lib/omniauth/000077500000000000000000000000001464674363300206635ustar00rootroot00000000000000omniauth-multipassword-2.0.1/lib/omniauth/multipassword/000077500000000000000000000000001464674363300236005ustar00rootroot00000000000000omniauth-multipassword-2.0.1/lib/omniauth/multipassword/base.rb000066400000000000000000000026161464674363300250440ustar00rootroot00000000000000# 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.rb000066400000000000000000000004021464674363300256060ustar00rootroot00000000000000# 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/000077500000000000000000000000001464674363300230355ustar00rootroot00000000000000omniauth-multipassword-2.0.1/lib/omniauth/strategies/multi_password.rb000066400000000000000000000043321464674363300264400ustar00rootroot00000000000000# 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.gemspec000066400000000000000000000016511464674363300244000ustar00rootroot00000000000000# 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.json000066400000000000000000000001771464674363300210140ustar00rootroot00000000000000{ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ "local>jgraichen/renovate-config" ] } omniauth-multipassword-2.0.1/spec/000077500000000000000000000000001464674363300172235ustar00rootroot00000000000000omniauth-multipassword-2.0.1/spec/omniauth/000077500000000000000000000000001464674363300210475ustar00rootroot00000000000000omniauth-multipassword-2.0.1/spec/omniauth/multipassword/000077500000000000000000000000001464674363300237645ustar00rootroot00000000000000omniauth-multipassword-2.0.1/spec/omniauth/multipassword/base_spec.rb000066400000000000000000000034671464674363300262470ustar00rootroot00000000000000# 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 '(env) { [404, {'Content-Type' => 'text/plain'}, [env['omniauth.auth']['uid'].to_s]] } end.to_app end it 'shows login FORM' do get '/auth/multipassword' expect(last_response.body).to include '