omniauth-multipassword-0.4.2/0000755000175000017500000000000012526406565017555 5ustar balasankarcbalasankarcomniauth-multipassword-0.4.2/Gemfile0000644000175000017500000000030312526406565021044 0ustar balasankarcbalasankarcsource '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/.gitignore0000644000175000017500000000023212526406565021542 0ustar balasankarcbalasankarc*.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/Rakefile0000644000175000017500000000016112526406565021220 0ustar balasankarcbalasankarcrequire 'bundler/gem_tasks' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task default: :spec omniauth-multipassword-0.4.2/omniauth-multipassword.gemspec0000644000175000017500000000160612526406565025664 0ustar balasankarcbalasankarc# -*- 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.yml0000644000175000017500000000334512526406565022065 0ustar balasankarcbalasankarc--- !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/0000755000175000017500000000000012526406565020323 5ustar balasankarcbalasankarcomniauth-multipassword-0.4.2/lib/omniauth/0000755000175000017500000000000012526406565022147 5ustar balasankarcbalasankarcomniauth-multipassword-0.4.2/lib/omniauth/multipassword/0000755000175000017500000000000012526406565025064 5ustar balasankarcbalasankarcomniauth-multipassword-0.4.2/lib/omniauth/multipassword/version.rb0000644000175000017500000000035212526406565027076 0ustar balasankarcbalasankarcmodule 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.rb0000644000175000017500000000205112526406565026321 0ustar balasankarcbalasankarcmodule 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/0000755000175000017500000000000012526406565024321 5ustar balasankarcbalasankarcomniauth-multipassword-0.4.2/lib/omniauth/strategies/multi_password.rb0000644000175000017500000000373212526406565027727 0ustar balasankarcbalasankarcrequire "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.rb0000644000175000017500000000017412526406565025411 0ustar balasankarcbalasankarcrequire "omniauth/multipassword/base" require "omniauth/multipassword/version" require "omniauth/strategies/multi_password" omniauth-multipassword-0.4.2/LICENSE0000644000175000017500000000205412526406565020563 0ustar balasankarcbalasankarcCopyright (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/0000755000175000017500000000000012526406565020507 5ustar balasankarcbalasankarcomniauth-multipassword-0.4.2/spec/omniauth/0000755000175000017500000000000012526406565022333 5ustar balasankarcbalasankarcomniauth-multipassword-0.4.2/spec/omniauth/multipassword/0000755000175000017500000000000012526406565025250 5ustar balasankarcbalasankarcomniauth-multipassword-0.4.2/spec/omniauth/multipassword/base_spec.rb0000644000175000017500000000361512526406565027526 0ustar balasankarcbalasankarcrequire '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 '(env) { [404, {'Content-Type' => 'text/plain'}, [env['omniauth.auth']['uid'].to_s]] } }.to_app end it 'shows login FORM' do get '/auth/multipassword' expect(last_response.body).to include '