omniauth-ibmisam 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7fec4a33325b6d2e600298c4d70aa2237ad0dd2d
4
+ data.tar.gz: e68e6589fd88293a3c85ddaad08e7a3d2982ed70
5
+ SHA512:
6
+ metadata.gz: e2b66bc377d50b61c8a5ba7ee5948709a37584f2f6d270ac1fccc75acc6c709f8fc2b9f6deab2c9253b9f9cda1c68ee895ab3212e3a20bb2a709fd205355e42b
7
+ data.tar.gz: a4b093bb6d2ed88bf42c4244092dc266e25f4208e767c9cdd07a691a0cdc547cc0e9f7c95db80909c1100e8bbcba0a54d790d344d84f7c8e009b232cfda9ec3d
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-ibmisam (0.0.1)
5
+ omniauth (~> 1.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ byebug (9.0.6)
11
+ diff-lcs (1.2.5)
12
+ hashie (3.4.6)
13
+ omniauth (1.3.1)
14
+ hashie (>= 1.2, < 4)
15
+ rack (>= 1.0, < 3)
16
+ rack (2.0.1)
17
+ rack-test (0.6.3)
18
+ rack (>= 1.0)
19
+ rspec (3.5.0)
20
+ rspec-core (~> 3.5.0)
21
+ rspec-expectations (~> 3.5.0)
22
+ rspec-mocks (~> 3.5.0)
23
+ rspec-core (3.5.4)
24
+ rspec-support (~> 3.5.0)
25
+ rspec-expectations (3.5.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-mocks (3.5.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.5.0)
31
+ rspec-support (3.5.0)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ byebug
38
+ omniauth-ibmisam!
39
+ rack-test (~> 0.6)
40
+ rspec (~> 3.5)
41
+
42
+ BUNDLED WITH
43
+ 1.13.6
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 IFAD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # OmniAuth IBM-ISAM Strategy
2
+
3
+ This is a OmniAuth 1.0 compatible strategy.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-ibmisam'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-ibmisam
18
+
19
+ ## Usage
20
+
21
+ Use like any other OmniAuth strategy:
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :ibmisam, name: 'ibmisam', header_type: 'identity'
26
+ end
27
+ ```
28
+
29
+ ### Configuration Options
30
+
31
+ #### Optional
32
+
33
+ Non required options:
34
+
35
+ * `name` - Defaults to `'ibmisam'`. This becomes part of the authentication request path: `/auth/[name]`.
36
+ * `header_type` - Defaults to `'identity'`. Can be `'eai'` or `'identity'`.
37
+ * `'eai'`: a header named `'am-eai-user-id'` is expected to contain the user id (user's email).
38
+ * `'identity'` (default): a header named `'iv-user'` is expected to contain the user id (user's email).
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
47
+
@@ -0,0 +1,2 @@
1
+ require 'omniauth/ibmisam/version'
2
+ require 'omniauth/strategies/ibmisam'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Ibmisam
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1,47 @@
1
+ require 'omniauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Ibmisam
6
+ include OmniAuth::Strategy
7
+
8
+ option :header_type, 'identity'
9
+ option :name, 'ibmisam'
10
+
11
+ LOGOUT_PATH = '/pkmslogout'
12
+
13
+ HEADER_NAMES = { identity: 'iv-user', eai: 'am-eai-user-id' }
14
+
15
+ def request_phase
16
+ if uid
17
+ redirect callback_path
18
+ else
19
+ [401, {}, ["Unauthorized (Missing external authentication)"]]
20
+ end
21
+ end
22
+
23
+ uid do
24
+ HEADER_NAMES.keys.include?(header_type) ? request.env[rack_header] : nil
25
+ end
26
+
27
+ class ConfigurationError < StandardError; end
28
+
29
+ def self.validate_options(options)
30
+ if options.has_key?(:header_type) && !HEADER_NAMES.keys.include?(options[:header_type].to_sym)
31
+ raise(ConfigurationError, "Invalid option: #{options[:header_type]} for IBMISAM header_type. Use one of: #{HEADER_NAMES.keys.join(', ')}")
32
+ end
33
+ end
34
+
35
+ private
36
+ def header_type
37
+ options.header_type.to_sym
38
+ end
39
+
40
+ def rack_header
41
+ header = HEADER_NAMES[header_type]
42
+ @rack_header ||= "HTTP_#{header.gsub('-','_')}".upcase
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ require 'omniauth/ibmisam/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "omniauth-ibmisam"
7
+ gem.version = OmniAuth::Ibmisam::VERSION
8
+ gem.date = %q{2017-01-16}
9
+ gem.authors = ["Thimios Dimopulos"]
10
+ gem.email = ["e.dimopoulos@ifad.org"]
11
+ gem.summary = %q{IBM ISAM Strategy for OmniAuth}
12
+ gem.description = "An omniauth strategy to be used with IBM ISAM."
13
+ gem.homepage = "https://github.com/ifad/omniauth-ibmisam"
14
+ gem.licenses = ['MIT']
15
+
16
+ gem.require_paths = ["lib"]
17
+ gem.files = `git ls-files`.split("\n")
18
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+
20
+ gem.add_dependency 'omniauth', '~> 1.3'
21
+
22
+ gem.add_development_dependency "rspec", "~> 3.5"
23
+ gem.add_development_dependency "rack-test", '~> 0.6'
24
+ gem.add_development_dependency "byebug", '~> 9.0'
25
+ end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Ibmisam, type: :strategy do
4
+ include Rack::Test::Methods
5
+
6
+ let(:name) { "ibmisam" }
7
+
8
+ let(:request_path) { "/auth/" + name }
9
+
10
+ let(:callback_path) { "/auth/" + name + "/callback" }
11
+
12
+ let(:app) do
13
+ strategy_name = name
14
+ Rack::Builder.new do |b|
15
+ b.use OmniAuth::Test::PhonySession
16
+ b.use OmniAuth::Strategies::Ibmisam, name: strategy_name, header_type: :identity
17
+ b.run lambda { |env|
18
+ [200, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]]
19
+ }
20
+ end.to_app
21
+ end
22
+
23
+ let(:unauthorized_message) { "Unauthorized (Missing external authentication)" }
24
+
25
+ describe '#request_phase' do
26
+ subject { last_response }
27
+
28
+ context 'without a header' do
29
+ before { get request_path }
30
+
31
+ it 'does not authenticate' do
32
+ expect(last_response.body).to eq unauthorized_message
33
+ end
34
+ end
35
+
36
+ context 'with a header that has no value' do
37
+ before do
38
+ header('iv-user', nil)
39
+ get request_path
40
+ end
41
+
42
+ it 'responds with failure' do
43
+ expect(last_response.status).to eq 401
44
+ end
45
+
46
+ it 'includes unauthorized message' do
47
+ expect(last_response.body).to eq unauthorized_message
48
+ end
49
+ end
50
+
51
+ context 'with a header that has a value' do
52
+ before do
53
+ header('iv-user', 'test@example.com')
54
+ get request_path
55
+ end
56
+
57
+ it 'redirects' do
58
+ expect(last_response.status).to eq 302
59
+ end
60
+
61
+ it 'redirects to the callback' do
62
+ expect(last_response.location).to eq callback_path
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ require 'bundler/setup'
2
+ require 'rack/test'
3
+ require 'omniauth/ibmisam'
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-ibmisam
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Thimios Dimopulos
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '9.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '9.0'
69
+ description: An omniauth strategy to be used with IBM ISAM.
70
+ email:
71
+ - e.dimopoulos@ifad.org
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE
80
+ - README.md
81
+ - lib/omniauth/ibmisam.rb
82
+ - lib/omniauth/ibmisam/version.rb
83
+ - lib/omniauth/strategies/ibmisam.rb
84
+ - omniauth-ibmisam.gemspec
85
+ - spec/omniauth/strategies/ibmisam_spec.rb
86
+ - spec/spec_helper.rb
87
+ homepage: https://github.com/ifad/omniauth-ibmisam
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.5.1
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: IBM ISAM Strategy for OmniAuth
111
+ test_files:
112
+ - spec/omniauth/strategies/ibmisam_spec.rb
113
+ - spec/spec_helper.rb