pax_global_header00006660000000000000000000000064141471700260014514gustar00rootroot0000000000000052 comment=d447d859af7518a6b5feec528a6ba7d80e51da31 omniauth-multipassword-2.0.0.rc1/000077500000000000000000000000001414717002600167365ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/.editorconfig000066400000000000000000000003451414717002600214150ustar00rootroot00000000000000# 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/000077500000000000000000000000001414717002600202765ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/.github/workflows/000077500000000000000000000000001414717002600223335ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/.github/workflows/test.yml000066400000000000000000000016341414717002600240410ustar00rootroot00000000000000--- 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/.gitignore000066400000000000000000000002321414717002600207230ustar00rootroot00000000000000*.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/.rspec000066400000000000000000000000141414717002600200460ustar00rootroot00000000000000--backtrace omniauth-multipassword-2.0.0.rc1/.rubocop.yml000066400000000000000000000002461414717002600212120ustar00rootroot00000000000000inherit_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.yml000066400000000000000000000002211414717002600210420ustar00rootroot00000000000000sudo: 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.md000066400000000000000000000004601414717002600205470ustar00rootroot00000000000000# 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/Gemfile000066400000000000000000000005521414717002600202330ustar00rootroot00000000000000# 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/LICENSE000066400000000000000000000020541414717002600177440ustar00rootroot00000000000000Copyright (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.md000066400000000000000000000032341414717002600202170ustar00rootroot00000000000000# 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.0.rc1/Rakefile000066400000000000000000000002131414717002600203770ustar00rootroot00000000000000# 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/000077500000000000000000000000001414717002600175045ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/lib/omniauth-multipassword.rb000066400000000000000000000002331414717002600245660ustar00rootroot00000000000000# 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/000077500000000000000000000000001414717002600213305ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/lib/omniauth/multipassword/000077500000000000000000000000001414717002600242455ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/lib/omniauth/multipassword/base.rb000066400000000000000000000025651414717002600255140ustar00rootroot00000000000000# 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.rb000066400000000000000000000004131414717002600262550ustar00rootroot00000000000000# 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/000077500000000000000000000000001414717002600235025ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/lib/omniauth/strategies/multi_password.rb000066400000000000000000000043021414717002600271020ustar00rootroot00000000000000# 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.gemspec000066400000000000000000000017641414717002600250520ustar00rootroot00000000000000# 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/000077500000000000000000000000001414717002600176705ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/spec/omniauth/000077500000000000000000000000001414717002600215145ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/spec/omniauth/multipassword/000077500000000000000000000000001414717002600244315ustar00rootroot00000000000000omniauth-multipassword-2.0.0.rc1/spec/omniauth/multipassword/base_spec.rb000066400000000000000000000034571414717002600267130ustar00rootroot00000000000000# 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 '(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 '