shib-rack 0.3.0 → 0.4.0

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
- SHA1:
3
- metadata.gz: ee8836c8686e810b738093267b1e87d260e7110b
4
- data.tar.gz: 8ecab14fcabfcfffa8fe4db416d62614c391f82d
2
+ SHA256:
3
+ metadata.gz: ca0cc87599b9b1fbbf3ca438be67ed5f5721424a9f8336f5e3b0cea657f74855
4
+ data.tar.gz: da104a3eca3c6af72ab5b6d377107835f7d7ed4593ce62f2fb9d9180cdaa6c4e
5
5
  SHA512:
6
- metadata.gz: cf42df46df9c220c4cd8ebd2fa2229deaf7ad01103f427128554db3849579c3bfcdbb445a11997aa383c2687fcabb6fd2514610d70af0db8178bcb464e4d0d5b
7
- data.tar.gz: 23ed96de7c8a8acb9b2d8a8bc9d5c178b78a1e18b4f8d2334afb2bb92de0a67020bc2d0fc058ff45181e7151ec4f4b70a837e229f3814bc473966df3cf40046c
6
+ metadata.gz: 54677c9f744f091ab69d4e28a51f4c352d8b32ba5967d4b517677288d4c285afb53328a58d68eda34c161544bcfd333cadab07f3e22525343fa62e397f7c28a1
7
+ data.tar.gz: 397dd0fbec7d4d5fe73bc7eac86068fe34568fe22f9cf05d9193abc3c728c99e576ee295baffc3b6011607737af771b982dfcaf3ed1c5eaa14e920370987a3e0
@@ -3,8 +3,9 @@ inherit_gem:
3
3
 
4
4
  AllCops:
5
5
  TargetRailsVersion: 4.0
6
+ TargetRubyVersion: 2.4.2
6
7
 
7
- Style/FileName:
8
+ Naming/FileName:
8
9
  Exclude:
9
10
  - lib/shib-rack.rb
10
11
 
data/README.md CHANGED
@@ -2,20 +2,12 @@
2
2
 
3
3
  [![Gem Version][GV img]][Gem Version]
4
4
  [![Build Status][BS img]][Build Status]
5
- [![Dependency Status][DS img]][Dependency Status]
6
- [![Code Climate][CC img]][Code Climate]
7
- [![Coverage Status][CS img]][Code Climate]
8
5
 
9
6
  [Gem Version]: https://rubygems.org/gems/shib-rack
10
7
  [Build Status]: https://codeship.com/projects/145971
11
- [Dependency Status]: https://gemnasium.com/ausaccessfed/shib-rack
12
- [Code Climate]: https://codeclimate.com/github/ausaccessfed/shib-rack
13
8
 
14
9
  [GV img]: https://img.shields.io/gem/v/shib-rack.svg
15
10
  [BS img]: https://img.shields.io/codeship/5cdcef80-e343-0133-84a6-5a988fa7d930/develop.svg
16
- [DS img]: https://img.shields.io/gemnasium/ausaccessfed/shib-rack.svg
17
- [CC img]: https://img.shields.io/codeclimate/github/ausaccessfed/shib-rack.svg
18
- [CS img]: https://img.shields.io/codeclimate/coverage/github/ausaccessfed/shib-rack.svg
19
11
 
20
12
  [Shibboleth SP](http://shibboleth.net) authentication plugin for Rack-based web
21
13
  applications. Contains Rails-specific extensions for consumption by Rails
@@ -24,7 +16,7 @@ applications.
24
16
  Author: Shaun Mangelsdorf
25
17
 
26
18
  ```
27
- Copyright 2016, Australian Access Federation
19
+ Copyright 2018, Australian Access Federation
28
20
 
29
21
  Licensed under the Apache License, Version 2.0 (the "License");
30
22
  you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ module ShibRack
23
23
 
24
24
  def add_attribute_mapping(attr, mapper)
25
25
  raise "Conflicting mapping for `#{attr}`" if attribute_mappings[attr]
26
+
26
27
  attribute_mappings[attr] = mapper
27
28
  end
28
29
 
@@ -8,19 +8,23 @@ module ShibRack
8
8
  # sample identities for local testing.
9
9
  class DevelopmentHandler < Handler
10
10
  class <<self
11
- attr_writer :identities
11
+ attr_writer :identities, :login_redirect
12
12
 
13
13
  def identities
14
14
  @identities ||= load_identities
15
15
  end
16
16
 
17
+ def login_redirect(env)
18
+ @login_redirect ||= "#{env['SCRIPT_NAME']}/development"
19
+ end
20
+
17
21
  def resolve_identity(shared_token)
18
22
  identities.find { |i| i['HTTP_AUEDUPERSONSHAREDTOKEN'] == shared_token }
19
23
  end
20
24
 
21
25
  def load_identities
22
26
  require 'yaml'
23
- yaml = File.read(File.expand_path('../identities.yml', __FILE__))
27
+ yaml = File.read(File.expand_path('identities.yml', __dir__))
24
28
 
25
29
  YAML.safe_load(yaml)['identities'].map do |identity|
26
30
  identity.reduce({}) { |a, (k, v)| a.merge("HTTP_#{k.upcase}" => v) }
@@ -52,7 +56,7 @@ module ShibRack
52
56
  end
53
57
 
54
58
  env['rack.session']['original_params'] = params
55
- [302, { 'Location' => "#{env['SCRIPT_NAME']}/development" }, []]
59
+ [302, { 'Location' => DevelopmentHandler.login_redirect(env) }, []]
56
60
  end
57
61
 
58
62
  def restore_original_query(env)
@@ -72,7 +76,7 @@ module ShibRack
72
76
  end
73
77
 
74
78
  def development_html
75
- <<~EOF
79
+ <<~HTML
76
80
  <!doctype html>
77
81
  <html>
78
82
  <head><title>Development Login</title></head>
@@ -81,7 +85,7 @@ module ShibRack
81
85
  #{identities_html}
82
86
  </body>
83
87
  </html>
84
- EOF
88
+ HTML
85
89
  end
86
90
 
87
91
  def identities_html
@@ -89,7 +93,7 @@ module ShibRack
89
93
  end
90
94
 
91
95
  def identity_html(identity)
92
- <<~EOF
96
+ <<~HTML
93
97
  <form method="get" action="login">
94
98
  <hr/>
95
99
  <pre>#{JSON.pretty_generate(identity)}</pre>
@@ -97,7 +101,7 @@ module ShibRack
97
101
  value="#{identity['HTTP_AUEDUPERSONSHAREDTOKEN']}"/>
98
102
  <button type="submit">Log In</button>
99
103
  </form>
100
- EOF
104
+ HTML
101
105
  end
102
106
  end
103
107
  end
@@ -20,6 +20,7 @@ module ShibRack
20
20
  def handler
21
21
  return 'ShibRack::DevelopmentHandler' if configuration[:development_mode]
22
22
  return 'ShibRack::TestHandler' if configuration[:test_mode]
23
+
23
24
  'ShibRack::Handler'
24
25
  end
25
26
  end
@@ -5,7 +5,6 @@ module ShibRack
5
5
  # Shibboleth SP.
6
6
  class Handler
7
7
  attr_reader :error_handler
8
- private :error_handler
9
8
 
10
9
  def initialize(opts)
11
10
  @receiver = constantize(opts[:receiver])
@@ -15,6 +14,7 @@ module ShibRack
15
14
  def call(env)
16
15
  return login(env) if env['PATH_INFO'] == '/login'
17
16
  return logout(env) if env['PATH_INFO'] == '/logout'
17
+
18
18
  [404, {}, ["Not found: #{env['PATH_INFO']}"]]
19
19
  end
20
20
 
@@ -32,7 +32,7 @@ module ShibRack
32
32
 
33
33
  def login(env)
34
34
  receiver.receive(env)
35
- rescue => e
35
+ rescue StandardError => e
36
36
  error_handler.handle(env, e)
37
37
  end
38
38
 
@@ -42,6 +42,7 @@ module ShibRack
42
42
 
43
43
  def constantize(klass_name)
44
44
  return nil if klass_name.nil?
45
+
45
46
  klass_name.split('::').reduce(Kernel) { |acc, elem| acc.const_get(elem) }
46
47
  end
47
48
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShibRack
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
5
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
5
  require 'shib_rack/version'
7
6
 
@@ -22,8 +21,8 @@ Gem::Specification.new do |spec|
22
21
 
23
22
  spec.add_development_dependency 'aaf-gumboot'
24
23
 
25
- spec.add_development_dependency 'rack-test'
26
24
  spec.add_development_dependency 'faker'
25
+ spec.add_development_dependency 'rack-test'
27
26
  spec.add_development_dependency 'rails', '~> 4.2'
28
27
  spec.add_development_dependency 'sqlite3'
29
28
 
@@ -33,7 +32,7 @@ Gem::Specification.new do |spec|
33
32
 
34
33
  spec.add_development_dependency 'guard'
35
34
  spec.add_development_dependency 'guard-bundler'
36
- spec.add_development_dependency 'guard-rubocop'
37
35
  spec.add_development_dependency 'guard-rspec'
36
+ spec.add_development_dependency 'guard-rubocop'
38
37
  spec.add_development_dependency 'simplecov'
39
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shib-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaun Mangelsdorf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-26 00:00:00.000000000 Z
11
+ date: 2018-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rack-test
42
+ name: faker
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: faker
56
+ name: rack-test
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: guard-rubocop
168
+ name: guard-rspec
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -179,7 +179,7 @@ dependencies:
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
- name: guard-rspec
182
+ name: guard-rubocop
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
185
  - - ">="
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  version: '0'
255
255
  requirements: []
256
256
  rubyforge_project:
257
- rubygems_version: 2.6.12
257
+ rubygems_version: 2.7.7
258
258
  signing_key:
259
259
  specification_version: 4
260
260
  summary: Rack middleware for Shibboleth SP authentication