omniauth-multipassword 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e052b8e72afbc6487e4d78c4b73d867fef83ae32
4
- data.tar.gz: 50e85068456f3ff78058a4696566364382fee670
3
+ metadata.gz: d5f7c8a3656ca4686749bd2b4d273cc1460d39ba
4
+ data.tar.gz: eb372de5e8f9ead660e3631e6b66c9c8ed34a158
5
5
  SHA512:
6
- metadata.gz: 0882792d59ec159595ad7be345eb282d0896e7ba9f07f9fc2318f2fd99b0a41e12989cddbdf6418484f501ea6da535d07c394e72555e5157f6f422a049aa7c8f
7
- data.tar.gz: 380ab3297e12bdf21e420655e5b4a83ff215c79c0389a2e50c714d59db186b882fb7b80e56103b379f57cb4c3d0a77e39581471fcc8def4cd3bd6ddb149e1d55
6
+ metadata.gz: 513e554cf46d322762dfbff65e764aea532ff2986de7af99770d9f84383b336b63af43492a5a95b63cb853f53cdd0f2bf0f33e190550fa0898ef955657fe07a0
7
+ data.tar.gz: c15f2b750cba4a41c170d2a983d74d8185665f3c0e70c44895ce268f7a1bdc54a1f7d713e8b7d1e5d58441ae9dd030e665b15f66bf6636ee98303b90f20ef5ad
@@ -0,0 +1,9 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - '2.1'
6
+ - '2.0'
7
+ - 1.9.3
8
+ - jruby
9
+ - rbx-2
data/Gemfile CHANGED
@@ -2,3 +2,9 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in omniauth-multipassword.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake'
7
+ gem 'rack-test'
8
+ gem 'rspec'
9
+ gem 'simplecov'
10
+ gem "codeclimate-test-reporter"
data/README.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # Omniauth::Multipassword
2
2
 
3
+ [![Build Status](https://travis-ci.org/jgraichen/omniauth-multipassword.svg?branch=master)](https://travis-ci.org/jgraichen/omniauth-multipassword)
4
+ [![Code Climate](https://codeclimate.com/github/jgraichen/omniauth-multipassword/badges/gpa.svg)](https://codeclimate.com/github/jgraichen/omniauth-multipassword)
5
+ [![Test Coverage](https://codeclimate.com/github/jgraichen/omniauth-multipassword/badges/coverage.svg)](https://codeclimate.com/github/jgraichen/omniauth-multipassword/coverage)
6
+
3
7
  **omniauth-multipassword** is a [OmniAuth](https://github.com/intridea/omniauth)
4
- strategy that allows to authenticate agains different password strategies at once.
8
+ strategy that allows to authenticate again different password strategies at once.
5
9
 
6
10
 
7
11
  ## Installation
data/Rakefile CHANGED
@@ -1,2 +1,5 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
@@ -42,7 +42,6 @@ module OmniAuth
42
42
  f.password_field "Password", password_id
43
43
  end.to_response
44
44
  end
45
-
46
45
  end
47
46
  end
48
47
  end
@@ -3,7 +3,7 @@ module Omniauth
3
3
  module VERSION
4
4
  MAJOR = 0
5
5
  MINOR = 4
6
- PATCH = 1
6
+ PATCH = 2
7
7
  STAGE = nil
8
8
 
9
9
  def self.to_s
@@ -11,7 +11,7 @@ module OmniAuth
11
11
  super(app, *args) do end
12
12
 
13
13
  if block.arity == 0
14
- instance_eval block
14
+ instance_eval &block
15
15
  else
16
16
  block.call self
17
17
  end
@@ -3,7 +3,7 @@ require File.expand_path('../lib/omniauth/multipassword/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Jan Graichen"]
6
- gem.email = ["jan.graichen@altimos.de"]
6
+ gem.email = ["jg@altimos.de"]
7
7
  gem.description = "A OmniAuth strategy to authenticate using different passwort strategies."
8
8
  gem.summary = "A OmniAuth strategy to authenticate using different passwort strategies."
9
9
  gem.homepage = "https://github.com/jgraichen/omniauth-multipassword"
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+ require 'rack/test'
3
+
4
+ describe OmniAuth::MultiPassword::Base do
5
+ let(:app) { double 'app' }
6
+ let(:args) { [] }
7
+ let(:block) { nil }
8
+
9
+ class OmniAuth::Strategy::OneTest
10
+ include OmniAuth::Strategy
11
+ include OmniAuth::MultiPassword::Base
12
+
13
+ def authenticate(username, password)
14
+ username == 'john' && password == 'secret'
15
+ end
16
+ end
17
+
18
+ let(:strategy) do
19
+ OmniAuth::Strategy::OneTest.new(app, *args, &block)
20
+ end
21
+
22
+ subject { strategy }
23
+
24
+ describe '#username_id' do
25
+ subject { strategy.username_id }
26
+
27
+ it 'defaults to :username' do
28
+ is_expected.to eq :username
29
+ end
30
+
31
+ context 'when configured' do
32
+ let(:args) { [{fields: [:user, :pass]}] }
33
+ it { is_expected.to eq :user }
34
+ end
35
+ end
36
+
37
+ describe '#password_id' do
38
+ subject { strategy.password_id }
39
+
40
+ it 'defaults to :password' do
41
+ is_expected.to eq :password
42
+ end
43
+
44
+ context 'when configured' do
45
+ let(:args) { [{fields: [:user, :pass]}] }
46
+ it { is_expected.to eq :pass }
47
+ end
48
+ end
49
+
50
+ describe 'single strategy' do
51
+ include Rack::Test::Methods
52
+
53
+ let(:app) do
54
+ Rack::Builder.new {
55
+ use OmniAuth::Test::PhonySession
56
+ use OmniAuth::Strategies::OneTest
57
+ run ->(env) { [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
58
+ }.to_app
59
+ end
60
+
61
+ it 'shows login FORM' do
62
+ get '/auth/onetest'
63
+
64
+ expect(last_response.body).to include '<form'
65
+ end
66
+
67
+ it 'redirect on wrong password' do
68
+ post '/auth/onetest/callback', username: 'john', password: 'wrong'
69
+ expect(last_response).to be_redirect
70
+ expect(last_response.headers['Location']).to eq '/auth/failure?message=invalid_credentials&strategy=onetest'
71
+ end
72
+
73
+ it 'authenticates john with correct password' do
74
+ post '/auth/onetest/callback', username: 'john', password: 'secret'
75
+ expect(last_response.body).to eq 'true'
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+ require 'rack/test'
3
+
4
+ describe OmniAuth::Strategies::MultiPassword do
5
+ include Rack::Test::Methods
6
+
7
+ class OmniAuth::Strategies::OneTest
8
+ include OmniAuth::Strategy
9
+ include OmniAuth::MultiPassword::Base
10
+
11
+ def authenticate(username, password)
12
+ username == 'john' && password == 'secret'
13
+ end
14
+ end
15
+
16
+ class OmniAuth::Strategies::TwoTest
17
+ include OmniAuth::Strategy
18
+ include OmniAuth::MultiPassword::Base
19
+
20
+ def authenticate(username, password)
21
+ username == 'jane' && password == '1234'
22
+ end
23
+ end
24
+
25
+ let(:app) do
26
+ Rack::Builder.new {
27
+ use OmniAuth::Test::PhonySession
28
+ use OmniAuth::Strategies::MultiPassword do
29
+ authenticator :one_test
30
+ authenticator :two_test
31
+ end
32
+ run ->(env) { [404, {'Content-Type' => 'text/plain'}, [env['omniauth.auth']['uid'].to_s]] }
33
+ }.to_app
34
+ end
35
+
36
+ it 'shows login FORM' do
37
+ get '/auth/multipassword'
38
+
39
+ expect(last_response.body).to include '<form'
40
+ end
41
+
42
+ it 'redirect on all failed strategies' do
43
+ post '/auth/multipassword/callback', username: 'paul', password: 'wrong'
44
+ expect(last_response).to be_redirect
45
+ expect(last_response.headers['Location']).to eq '/auth/failure?message=invalid_credentials&strategy=multipassword'
46
+ end
47
+
48
+ it 'authenticates john' do
49
+ post '/auth/multipassword/callback', username: 'john', password: 'secret'
50
+ expect(last_response.body).to eq 'john'
51
+ end
52
+
53
+ it 'authenticates jane' do
54
+ post '/auth/multipassword/callback', username: 'jane', password: '1234'
55
+ expect(last_response.body).to eq 'jane'
56
+ end
57
+ end
@@ -0,0 +1,30 @@
1
+ require 'rspec'
2
+ require 'simplecov'
3
+
4
+ if ENV['CI'] || (defined?(:RUBY_ENGINE) && RUBY_ENGINE != 'rbx')
5
+ begin
6
+ require 'codeclimate-test-reporter'
7
+ CodeClimate::TestReporter.start
8
+ rescue LoadError
9
+ end
10
+ SimpleCov.start
11
+ end
12
+
13
+ require 'omniauth-multipassword'
14
+
15
+ Dir[File.expand_path('spec/support/**/*.rb')].each {|f| require f }
16
+
17
+ # Disable omniauth logger
18
+ class NullLogger < Logger
19
+ def initialize(*args)
20
+ end
21
+
22
+ def add(*args, &block)
23
+ end
24
+ end
25
+
26
+ OmniAuth.config.logger = NullLogger.new
27
+
28
+ RSpec.configure do |config|
29
+ config.order = 'random'
30
+ end
metadata CHANGED
@@ -1,37 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-multipassword
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-24 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  description: A OmniAuth strategy to authenticate using different passwort strategies.
28
28
  email:
29
- - jan.graichen@altimos.de
29
+ - jg@altimos.de
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - .gitignore
34
+ - ".gitignore"
35
+ - ".travis.yml"
35
36
  - Gemfile
36
37
  - LICENSE
37
38
  - README.md
@@ -41,6 +42,9 @@ files:
41
42
  - lib/omniauth/multipassword/version.rb
42
43
  - lib/omniauth/strategies/multi_password.rb
43
44
  - omniauth-multipassword.gemspec
45
+ - spec/omniauth/multipassword/base_spec.rb
46
+ - spec/omniauth/strategy/multi_password_spec.rb
47
+ - spec/spec_helper.rb
44
48
  homepage: https://github.com/jgraichen/omniauth-multipassword
45
49
  licenses:
46
50
  - MIT
@@ -51,17 +55,17 @@ require_paths:
51
55
  - lib
52
56
  required_ruby_version: !ruby/object:Gem::Requirement
53
57
  requirements:
54
- - - '>='
58
+ - - ">="
55
59
  - !ruby/object:Gem::Version
56
60
  version: '0'
57
61
  required_rubygems_version: !ruby/object:Gem::Requirement
58
62
  requirements:
59
- - - '>='
63
+ - - ">="
60
64
  - !ruby/object:Gem::Version
61
65
  version: '0'
62
66
  requirements: []
63
67
  rubyforge_project:
64
- rubygems_version: 2.0.3
68
+ rubygems_version: 2.4.6
65
69
  signing_key:
66
70
  specification_version: 4
67
71
  summary: A OmniAuth strategy to authenticate using different passwort strategies.