hubssolib 2.0.0 → 3.0.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
2
  SHA256:
3
- metadata.gz: 9309369683fa647e559c4a87d5569e215d25f472b2acdb6869b538807a42ecf2
4
- data.tar.gz: 6b4ffb49a16835ceac8436c6ebd5d9270fe9ea1af2d9c1de07616e2b38f5cd5e
3
+ metadata.gz: f418c1a21497375e396be12fd95387b6a436ed42c8145dc681ee041eded447a3
4
+ data.tar.gz: 06d7868acf059c7c9df758d960b508e6e063fb0f1b012ff520a549772079a486
5
5
  SHA512:
6
- metadata.gz: 8b4d75adcceea21ca4b95b49410a20667b7a1088e7f0bcf63e267699a779ba8e1ececcf2a5d5894274f7f12fe47eb4694bc948df912d625c86aece3dfc6551a7
7
- data.tar.gz: 7c6aea5a1261203b6c74872620cbb7195e53cb9b545df6dea252bb0c4dce7c25260891d0ee7ceca8b1a85da29fb8669a7fb8346202f972d3263e199efd1df26c
6
+ metadata.gz: fa015b2a0853402ee85b23c788bfd52a15cbda02c000ad0c6f6eba882e664393fe7927119f2b53c2f396d9b8f6d9337b85bdfa5fe50866e07a9fe7942b8700cf
7
+ data.tar.gz: 006b768e21fe802806c946062b0e74be65cad124833f861455f09f684887c09104f281450b08295bf9c17f472e1839c291b6f6422212cbf9717d03d8925ba3c6
data/CHANGELOG.md CHANGED
@@ -1,4 +1,35 @@
1
- ## Version 1 -> Version 2.0.0, 19-Apr-2020
1
+ ## 3.0.0, 28-Jan-2025
2
+
3
+ * The Hub "login indication" URL approach is now dropped, so layout templates **must be updated.**
4
+
5
+ In Hub v1 and v2, login indication was done via an image that was served by the Hub application itself, wrapped in a link that visited a "conditional login" endpoint which stored the return-to URL, ensured HTTPS was in use and visited either the log in, or log out page as required. In client applications it looked a bit like this:
6
+
7
+ ```html
8
+ <a class="img" href="<%= ENV['HUB_PATH_PREFIX'] %>/account/login_conditional">
9
+ <img src="<%= ENV['HUB_PATH_PREFIX'] %>/account/login_indication" alt="Account" height="22" width="90" />
10
+ </a>
11
+ ```
12
+
13
+ This dates back to a time when CSS support was not that widespread and RISC OS Open needed the web site to work well on web browsers available at the time. Things have improved enormously since then, so now a cleaner, pure CSS solution is used. This has the enormous advantage of requiring no image fetch request-response into the Hub application. Just use:
14
+
15
+ ```ruby
16
+ <%= hubssolib_account_link() %>
17
+ ```
18
+
19
+ ...in place of the markup above.
20
+
21
+
22
+
23
+ ## 2.1.0, 01-Jul-2022
24
+
25
+ * Use `HUB_QUIET_SERVER=yes ...` to quieten `$stdout` output from Hub server.
26
+ * Test coverage fixed (overlooked in v2.0.0 release).
27
+ * Maintenance `bundle update`.
28
+ * A few minor tidy-ups in the implementation.
29
+
30
+
31
+
32
+ ## Version 1.0.0 -> Version 2.0.0, 19-Apr-2020
2
33
 
3
34
  The public interface to applications is generally unchanged, but the cookie storage mechanism has been improved and is not compatible with v1 of Hub. You will need to use the newer Hub application, server and gem, but hopefully will find you don't need to change anything with your integrated applications.
4
35
 
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec # See hubssolib.gemspec
data/Gemfile.lock CHANGED
@@ -1,41 +1,69 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hubssolib (2.0.0)
4
+ hubssolib (3.0.0)
5
+ base64 (~> 0.2)
6
+ drb (~> 2.2)
5
7
 
6
8
  GEM
7
- remote: http://rubygems.org/
9
+ remote: https://rubygems.org/
8
10
  specs:
9
- diff-lcs (1.5.0)
10
- docile (1.4.0)
11
- rspec (3.11.0)
12
- rspec-core (~> 3.11.0)
13
- rspec-expectations (~> 3.11.0)
14
- rspec-mocks (~> 3.11.0)
15
- rspec-core (3.11.0)
16
- rspec-support (~> 3.11.0)
17
- rspec-expectations (3.11.0)
11
+ base64 (0.2.0)
12
+ date (3.4.1)
13
+ debug (1.10.0)
14
+ irb (~> 1.10)
15
+ reline (>= 0.3.8)
16
+ diff-lcs (1.5.1)
17
+ docile (1.4.1)
18
+ doggo (1.4.0)
19
+ rspec-core (~> 3.13)
20
+ drb (2.2.1)
21
+ io-console (0.8.0)
22
+ irb (1.15.1)
23
+ pp (>= 0.6.0)
24
+ rdoc (>= 4.0.0)
25
+ reline (>= 0.4.2)
26
+ pp (0.6.2)
27
+ prettyprint
28
+ prettyprint (0.2.0)
29
+ psych (5.2.3)
30
+ date
31
+ stringio
32
+ rdoc (6.11.0)
33
+ psych (>= 4.0.0)
34
+ reline (0.6.0)
35
+ io-console (~> 0.5)
36
+ rspec (3.13.0)
37
+ rspec-core (~> 3.13.0)
38
+ rspec-expectations (~> 3.13.0)
39
+ rspec-mocks (~> 3.13.0)
40
+ rspec-core (3.13.2)
41
+ rspec-support (~> 3.13.0)
42
+ rspec-expectations (3.13.3)
18
43
  diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.11.0)
20
- rspec-mocks (3.11.1)
44
+ rspec-support (~> 3.13.0)
45
+ rspec-mocks (3.13.2)
21
46
  diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.11.0)
23
- rspec-support (3.11.0)
24
- simplecov (0.21.2)
47
+ rspec-support (~> 3.13.0)
48
+ rspec-support (3.13.2)
49
+ simplecov (0.22.0)
25
50
  docile (~> 1.1)
26
51
  simplecov-html (~> 0.11)
27
52
  simplecov_json_formatter (~> 0.1)
28
- simplecov-html (0.12.3)
53
+ simplecov-html (0.13.1)
29
54
  simplecov_json_formatter (0.1.4)
55
+ stringio (3.1.2)
30
56
 
31
57
  PLATFORMS
32
58
  ruby
33
59
 
34
60
  DEPENDENCIES
61
+ debug (~> 1.1)
62
+ doggo (~> 1.4)
35
63
  hubssolib!
36
- rspec (~> 3.8)
37
- rspec-mocks (~> 3.8)
38
- simplecov (~> 0.16)
64
+ rspec (~> 3.13)
65
+ rspec-mocks (~> 3.13)
66
+ simplecov (~> 0.22)
39
67
 
40
68
  BUNDLED WITH
41
- 2.3.17
69
+ 2.6.2
data/README.md CHANGED
@@ -24,28 +24,10 @@ The latest version of the Hub gem source code is available at:
24
24
 
25
25
  ### The Hub library gem
26
26
 
27
- First of all, download and unpack the Hub gem sources. Change into the source directory (usually, `rails/gems/hubssolib`) and build with:
28
-
29
- ```sh
30
- gem build hubssolib.gemspec
31
- ```
32
-
33
- Install the Hub gem using the `gem` command in the usual fashion. For example, for version 1.0.0 of the library, issue the following command:
34
-
35
- ```sh
36
- gem install hubssolib-1.0.0.gem
37
- ```
38
-
39
- If you run multiple gem repositories you can instruct `gem` to install into a specific location using the `--install-dir` command line switch:
40
-
41
- ```sh
42
- gem install hubssolib-1.0.0.gem --install-dir=/home/username/gems
43
- ```
44
-
45
27
  Include in a project by adding this to your `Gemfile`:
46
28
 
47
29
  ```ruby
48
- gem 'hubssolib', '~> 1.0.0', :require => 'hub_sso_lib'
30
+ gem 'hubssolib', '~> 3.0', require: 'hub_sso_lib'
49
31
  ```
50
32
 
51
33
  ### The DRb server
@@ -55,7 +37,7 @@ The Hub DRb server consists of a small wrapper Ruby script which does most of it
55
37
  ```sh
56
38
  HUB_CONNECTION_URI="drbunix:/home/username/sockets/.hub_drb"
57
39
  export HUB_CONNECTION_URI
58
- ruby /home/username/hub/hub_sso_server.rb &
40
+ ruby /home/username/hubssolib/hub_sso_server.rb &
59
41
  ```
60
42
 
61
43
  The default is to use a file `.hub_drb` in the root of the current user's home directory. If you specify a custom URI, note that it _MUST_ start with `drbunix:`; the hub server must not be run on an IP port for security reasons.
data/hubssolib.gemspec CHANGED
@@ -4,11 +4,10 @@ spec = Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.name = 'hubssolib'
6
6
 
7
- s.version = '2.0.0'
7
+ s.version = '3.0.0'
8
8
  s.author = 'Andrew Hodgkinson and others'
9
9
  s.email = 'ahodgkin@rowing.org.uk'
10
- s.homepage = 'http://hub.pond.org.uk/'
11
- s.date = File.ctime('VERSION')
10
+ s.homepage = 'http://pond.org.uk/'
12
11
  s.summary = 'Cross-application single sign-on support library.'
13
12
  s.license = 'MIT'
14
13
 
@@ -23,9 +22,14 @@ spec = Gem::Specification.new do |s|
23
22
  EOF
24
23
 
25
24
  s.files = FileList['lib/**/*.rb', '[A-Z]*'].to_a
26
- s.required_ruby_version = '>= 2.5.9' # Not tested on earlier versions
25
+ s.required_ruby_version = '>= 3.0.0' # Not tested on earlier versions
27
26
 
28
- s.add_development_dependency 'simplecov', '~> 0.16'
29
- s.add_development_dependency 'rspec', '~> 3.8'
30
- s.add_development_dependency 'rspec-mocks', '~> 3.8'
27
+ s.add_dependency 'drb', '~> 2.2'
28
+ s.add_dependency 'base64', '~> 0.2'
29
+
30
+ s.add_development_dependency 'debug', '~> 1.1'
31
+ s.add_development_dependency 'simplecov', '~> 0.22'
32
+ s.add_development_dependency 'doggo', '~> 1.4'
33
+ s.add_development_dependency 'rspec', '~> 3.13'
34
+ s.add_development_dependency 'rspec-mocks', '~> 3.13'
31
35
  end
data/lib/hub_sso_lib.rb CHANGED
@@ -75,7 +75,7 @@ module HubSsoLib
75
75
  def self.deserialise_object(data)
76
76
  Marshal.load(Base64.strict_decode64(data)) rescue nil
77
77
  end
78
- end # Crypto class
78
+ end # Serialiser class
79
79
 
80
80
  #######################################################################
81
81
  # Class: Roles #
@@ -409,9 +409,10 @@ module HubSsoLib
409
409
 
410
410
  class SessionFactory
411
411
  def initialize
412
- puts "Session factory: Awaken"
413
-
412
+ @hub_be_quiet = ! ENV['HUB_QUIET_SERVER'].nil?
414
413
  @hub_sessions = {}
414
+
415
+ puts "Session factory: Awaken" unless @hub_be_quiet
415
416
  end
416
417
 
417
418
  # Get a session using a given key (a UUID). Generates a new session if
@@ -426,7 +427,7 @@ module HubSsoLib
426
427
  # The returned object is proxied via DRb - it is shared between processes.
427
428
  #
428
429
  # +key+:: Session key; lazy-initialises a new session under this key
429
- # if none is found, then immeediately rotates it.
430
+ # if none is found, then immediately rotates it.
430
431
  #
431
432
  # +remote_ip+:: Request's remote IP address. If there is an existing
432
433
  # session which matches this, it's returned. If there is an
@@ -434,23 +435,25 @@ module HubSsoLib
434
435
  # invalid and discarded.
435
436
  #
436
437
  def get_hub_session_proxy(key, remote_ip)
437
- retrieve_existing = @hub_sessions.has_key?(key)
438
- message = retrieve_existing ? 'Retrieving' : 'Created'
439
- new_key = SecureRandom.uuid
438
+ hub_session = @hub_sessions[key]
439
+ message = hub_session.nil? ? 'Created' : 'Retrieving'
440
+ new_key = SecureRandom.uuid
440
441
 
441
- puts "#{message} session for key #{key} and rotating to #{new_key}"
442
+ unless @hub_be_quiet
443
+ puts "#{ message } session for key #{ key } and rotating to #{ new_key }"
444
+ end
442
445
 
443
- if retrieve_existing
444
- hub_session = @hub_sessions[key]
445
- if remote_ip != hub_session.session_ip
446
- puts "WARNING: IP address changed from #{hub_session.session_ip} to #{remote_ip} -> discarding session"
447
- hub_session = @hub_sessions[key] = HubSsoLib::Session.new
446
+ unless hub_session.nil? || hub_session.session_ip == remote_ip
447
+ unless @hub_be_quiet
448
+ puts "WARNING: IP address changed from #{ hub_session.session_ip } to #{ remote_ip } -> discarding session"
448
449
  end
449
450
 
450
- else
451
- hub_session = @hub_sessions[key] = HubSsoLib::Session.new
452
- hub_session.session_ip = remote_ip
451
+ hub_session = nil
452
+ end
453
453
 
454
+ if hub_session.nil?
455
+ hub_session = HubSsoLib::Session.new
456
+ hub_session.session_ip = remote_ip
454
457
  end
455
458
 
456
459
  @hub_sessions.delete(key)
@@ -483,7 +486,7 @@ module HubSsoLib
483
486
 
484
487
  module Server
485
488
  def hubssolib_launch_server
486
- puts "Server: Starting at #{ HUB_CONNECTION_URI }"
489
+ puts "Server: Starting at #{ HUB_CONNECTION_URI }" unless ENV['HUB_QUIET_SERVER'].nil?
487
490
 
488
491
  @@hub_session_factory = HubSsoLib::SessionFactory.new
489
492
  DRb.start_service(HUB_CONNECTION_URI, @@hub_session_factory, { :safe_level => 1 })
@@ -515,6 +518,27 @@ module HubSsoLib
515
518
  !!self.hubssolib_current_user
516
519
  end
517
520
 
521
+ # Returns markup for a link that leads to Hub's conditional login endpoint,
522
+ # inline-styled as a red "Log in" or green "Account" button. This can be
523
+ # used in page templates to avoid needing any additional images or other
524
+ # such resources and using pure HTML + CSS for the login indication.
525
+ #
526
+ def hubssolib_account_link
527
+ logged_in = self.hubssolib_logged_in?()
528
+
529
+ text, klass, style = if logged_in
530
+ ['Account', 'hubssolib_logged_in', 'border: 1px solid #050; color: #050; background: #efe;']
531
+ else
532
+ ['Log in', 'hubssolib_logged_out', 'border: 1px solid #500; color: #500; background: #fee;']
533
+ end
534
+
535
+ style << ' display: block; width: 88px; height; 20px;'
536
+ style << ' text-align: center; line-height: 20px;'
537
+ style << ' font: sans-serif; font-size: 10pt'
538
+
539
+ "<a href=\"#{HUB_PATH_PREFIX}/account/login_conditional\" class=\"#{klass}\" style=\"#{style}\">#{text}</a>".html_safe()
540
+ end
541
+
518
542
  # Check if the user is authorized to perform the current action. If calling
519
543
  # from a helper, pass the action name and class name; otherwise by default,
520
544
  # the current action name and 'self.class' will be used.
@@ -819,7 +843,7 @@ module HubSsoLib
819
843
  keys = ordered_keys | hash.keys
820
844
 
821
845
  keys.each do | key |
822
- compiled_data[ 'hub' ][ key ] = hash[ key ] if hash.has_key?( key )
846
+ compiled_data['hub'][key] = hash[key] if hash.key?(key)
823
847
  end
824
848
 
825
849
  if defined?( flash )
@@ -827,7 +851,7 @@ module HubSsoLib
827
851
  keys = ordered_keys | hash.keys
828
852
 
829
853
  keys.each do | key |
830
- compiled_data[ 'standard' ][ key ] = hash[ key ] if hash.has_key?( key )
854
+ compiled_data['standard'][key] = hash[key] if hash.key?(key)
831
855
  end
832
856
  end
833
857
 
@@ -852,6 +876,7 @@ module HubSsoLib
852
876
  :hubssolib_current_user,
853
877
  :hubssolib_unique_name,
854
878
  :hubssolib_logged_in?,
879
+ :hubssolib_account_link,
855
880
  :hubssolib_authorized?,
856
881
  :hubssolib_privileged?,
857
882
  :hubssolib_flash_data
metadata CHANGED
@@ -1,57 +1,112 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubssolib
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Hodgkinson and others
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-06-30 00:00:00.000000000 Z
10
+ date: 2025-01-28 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: drb
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.2'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '2.2'
26
+ - !ruby/object:Gem::Dependency
27
+ name: base64
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.2'
40
+ - !ruby/object:Gem::Dependency
41
+ name: debug
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.1'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.1'
13
54
  - !ruby/object:Gem::Dependency
14
55
  name: simplecov
15
56
  requirement: !ruby/object:Gem::Requirement
16
57
  requirements:
17
58
  - - "~>"
18
59
  - !ruby/object:Gem::Version
19
- version: '0.16'
60
+ version: '0.22'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.22'
68
+ - !ruby/object:Gem::Dependency
69
+ name: doggo
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.4'
20
75
  type: :development
21
76
  prerelease: false
22
77
  version_requirements: !ruby/object:Gem::Requirement
23
78
  requirements:
24
79
  - - "~>"
25
80
  - !ruby/object:Gem::Version
26
- version: '0.16'
81
+ version: '1.4'
27
82
  - !ruby/object:Gem::Dependency
28
83
  name: rspec
29
84
  requirement: !ruby/object:Gem::Requirement
30
85
  requirements:
31
86
  - - "~>"
32
87
  - !ruby/object:Gem::Version
33
- version: '3.8'
88
+ version: '3.13'
34
89
  type: :development
35
90
  prerelease: false
36
91
  version_requirements: !ruby/object:Gem::Requirement
37
92
  requirements:
38
93
  - - "~>"
39
94
  - !ruby/object:Gem::Version
40
- version: '3.8'
95
+ version: '3.13'
41
96
  - !ruby/object:Gem::Dependency
42
97
  name: rspec-mocks
43
98
  requirement: !ruby/object:Gem::Requirement
44
99
  requirements:
45
100
  - - "~>"
46
101
  - !ruby/object:Gem::Version
47
- version: '3.8'
102
+ version: '3.13'
48
103
  type: :development
49
104
  prerelease: false
50
105
  version_requirements: !ruby/object:Gem::Requirement
51
106
  requirements:
52
107
  - - "~>"
53
108
  - !ruby/object:Gem::Version
54
- version: '3.8'
109
+ version: '3.13'
55
110
  description: |2
56
111
  The Hub SSO Library supports single sign-on across multiple Rails
57
112
  applications on the same host. The Hub application provides account
@@ -69,14 +124,12 @@ files:
69
124
  - Gemfile
70
125
  - Gemfile.lock
71
126
  - README.md
72
- - VERSION
73
127
  - hubssolib.gemspec
74
128
  - lib/hub_sso_lib.rb
75
- homepage: http://hub.pond.org.uk/
129
+ homepage: http://pond.org.uk/
76
130
  licenses:
77
131
  - MIT
78
132
  metadata: {}
79
- post_install_message:
80
133
  rdoc_options: []
81
134
  require_paths:
82
135
  - lib
@@ -84,15 +137,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
84
137
  requirements:
85
138
  - - ">="
86
139
  - !ruby/object:Gem::Version
87
- version: 2.5.9
140
+ version: 3.0.0
88
141
  required_rubygems_version: !ruby/object:Gem::Requirement
89
142
  requirements:
90
143
  - - ">="
91
144
  - !ruby/object:Gem::Version
92
145
  version: '0'
93
146
  requirements: []
94
- rubygems_version: 3.2.3
95
- signing_key:
147
+ rubygems_version: 3.6.2
96
148
  specification_version: 4
97
149
  summary: Cross-application single sign-on support library.
98
150
  test_files: []
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 2.0.0 (19-Apr-2020)