omniauth-multipassword-0.4.2/ 0000755 0001750 0001750 00000000000 12526406565 017555 5 ustar balasankarc balasankarc omniauth-multipassword-0.4.2/Gemfile 0000644 0001750 0001750 00000000303 12526406565 021044 0 ustar balasankarc balasankarc source 'https://rubygems.org' # Specify your gem's dependencies in omniauth-multipassword.gemspec gemspec gem 'rake' gem 'rack-test' gem 'rspec' gem 'simplecov' gem "codeclimate-test-reporter" omniauth-multipassword-0.4.2/.gitignore 0000644 0001750 0001750 00000000232 12526406565 021542 0 ustar balasankarc balasankarc *.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-0.4.2/Rakefile 0000644 0001750 0001750 00000000161 12526406565 021220 0 ustar balasankarc balasankarc require 'bundler/gem_tasks' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task default: :spec omniauth-multipassword-0.4.2/omniauth-multipassword.gemspec 0000644 0001750 0001750 00000001606 12526406565 025664 0 ustar balasankarc balasankarc # -*- encoding: utf-8 -*- require File.expand_path('../lib/omniauth/multipassword/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Jan Graichen"] gem.email = ["jg@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.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', '~> 1.0' end omniauth-multipassword-0.4.2/metadata.yml 0000644 0001750 0001750 00000003345 12526406565 022065 0 ustar balasankarc balasankarc --- !ruby/object:Gem::Specification name: omniauth-multipassword version: !ruby/object:Gem::Version version: 0.4.2 platform: ruby authors: - Jan Graichen autorequire: bindir: bin cert_chain: [] date: 2015-05-18 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: omniauth requirement: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.0' type: :runtime prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - "~>" - !ruby/object:Gem::Version version: '1.0' description: A OmniAuth strategy to authenticate using different passwort strategies. email: - jg@altimos.de executables: [] extensions: [] extra_rdoc_files: [] files: - ".gitignore" - ".travis.yml" - Gemfile - LICENSE - README.md - Rakefile - lib/omniauth-multipassword.rb - lib/omniauth/multipassword/base.rb - lib/omniauth/multipassword/version.rb - lib/omniauth/strategies/multi_password.rb - omniauth-multipassword.gemspec - spec/omniauth/multipassword/base_spec.rb - spec/omniauth/strategy/multi_password_spec.rb - spec/spec_helper.rb homepage: https://github.com/jgraichen/omniauth-multipassword licenses: - MIT metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: rubygems_version: 2.4.6 signing_key: specification_version: 4 summary: A OmniAuth strategy to authenticate using different passwort strategies. test_files: [] omniauth-multipassword-0.4.2/lib/ 0000755 0001750 0001750 00000000000 12526406565 020323 5 ustar balasankarc balasankarc omniauth-multipassword-0.4.2/lib/omniauth/ 0000755 0001750 0001750 00000000000 12526406565 022147 5 ustar balasankarc balasankarc omniauth-multipassword-0.4.2/lib/omniauth/multipassword/ 0000755 0001750 0001750 00000000000 12526406565 025064 5 ustar balasankarc balasankarc omniauth-multipassword-0.4.2/lib/omniauth/multipassword/version.rb 0000644 0001750 0001750 00000000352 12526406565 027076 0 ustar balasankarc balasankarc module Omniauth module Multipassword module VERSION MAJOR = 0 MINOR = 4 PATCH = 2 STAGE = nil def self.to_s [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join '.' end end end end omniauth-multipassword-0.4.2/lib/omniauth/multipassword/base.rb 0000644 0001750 0001750 00000002051 12526406565 026321 0 ustar balasankarc balasankarc module OmniAuth module MultiPassword module Base def self.included(base) base.class_eval do option :title, "Restricted Access" option :fields, [ :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 end end end omniauth-multipassword-0.4.2/lib/omniauth/strategies/ 0000755 0001750 0001750 00000000000 12526406565 024321 5 ustar balasankarc balasankarc omniauth-multipassword-0.4.2/lib/omniauth/strategies/multi_password.rb 0000644 0001750 0001750 00000003732 12526406565 027727 0 ustar balasankarc balasankarc 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 end if block.arity == 0 instance_eval &block else block.call 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)}") rescue NameError raise LoadError, "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 return 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) if @authenticator.authenticate(username, password) return true end 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-0.4.2/lib/omniauth-multipassword.rb 0000644 0001750 0001750 00000000174 12526406565 025411 0 ustar balasankarc balasankarc require "omniauth/multipassword/base" require "omniauth/multipassword/version" require "omniauth/strategies/multi_password" omniauth-multipassword-0.4.2/LICENSE 0000644 0001750 0001750 00000002054 12526406565 020563 0 ustar balasankarc balasankarc 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-0.4.2/spec/ 0000755 0001750 0001750 00000000000 12526406565 020507 5 ustar balasankarc balasankarc omniauth-multipassword-0.4.2/spec/omniauth/ 0000755 0001750 0001750 00000000000 12526406565 022333 5 ustar balasankarc balasankarc omniauth-multipassword-0.4.2/spec/omniauth/multipassword/ 0000755 0001750 0001750 00000000000 12526406565 025250 5 ustar balasankarc balasankarc omniauth-multipassword-0.4.2/spec/omniauth/multipassword/base_spec.rb 0000644 0001750 0001750 00000003615 12526406565 027526 0 ustar balasankarc balasankarc require 'spec_helper' require 'rack/test' describe OmniAuth::MultiPassword::Base do let(:app) { double 'app' } let(:args) { [] } let(:block) { nil } class OmniAuth::Strategy::OneTest include OmniAuth::Strategy include OmniAuth::MultiPassword::Base def authenticate(username, password) username == 'john' && password == 'secret' end end let(:strategy) do OmniAuth::Strategy::OneTest.new(app, *args, &block) end subject { strategy } describe '#username_id' do subject { strategy.username_id } it 'defaults to :username' do is_expected.to eq :username end context 'when configured' do let(:args) { [{fields: [:user, :pass]}] } it { is_expected.to eq :user } end end describe '#password_id' do subject { strategy.password_id } it 'defaults to :password' do is_expected.to eq :password end context 'when configured' do let(:args) { [{fields: [:user, :pass]}] } it { is_expected.to eq :pass } end end describe 'single strategy' do include Rack::Test::Methods let(:app) do Rack::Builder.new { use OmniAuth::Test::PhonySession use OmniAuth::Strategies::OneTest run ->(env) { [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] } }.to_app end it 'shows login FORM' do get '/auth/onetest' expect(last_response.body).to include '