hubssolib 3.8.2 → 4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b90f9617fc1a625f402510ee5497d4d357f914d7f35284e6c1e25b62ae07f4b
4
- data.tar.gz: 450ead4d1423e6b42fd6a0aba65fdf043d6c5e3a6c3dc1b7b04412b2fcd4e65c
3
+ metadata.gz: b1c0cc452aa9f993bae6898c2b2096df8a331fc9994150342a145635ccf37c75
4
+ data.tar.gz: d5e3012bd64bb3baed92ecf46115f0ed39e4c1df5cf86981f455f8aa361781a0
5
5
  SHA512:
6
- metadata.gz: 1a03c285659733df8dd98c93faaf458549229c8a096cba58c797c04139788bddf2592c2a12b99a5c87d02ffac4a936db703317d4957ec48d25790a21eb3ddadb
7
- data.tar.gz: b392255f66a678625bab09ec613d69f77ab8cf60818764fcc4b2b55028e317854e24e8125a527ccac598b6845ba10f794524ffa82579a2f5ef30258fafbba887
6
+ metadata.gz: 97735fe3f0a68c0cf4bc07b6b0ed2d7d7f36a41d2c2b7a45b889fbca6e008aa2af44b54f632b8860b41ee2774dd1d6d632c48710e29b14e2bfd0dbb613d1dd3a
7
+ data.tar.gz: 6b0c0aa270b61701fc9fbac4d0e984a5770e0fde58685ec4a16e91cdf40e415a7924246cee023dc17a4e4d9f7bfc9f340aa1d264b2fa573886eeaed86e8632e2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 4.0.0 and 4.0.1, 24-Jul-2026
2
+
3
+ * Despite the major version bump, this is a maintenance release for client apps. Integration for all Hub features including the Hub Trust mechanism is unchanged.
4
+ * If you do not use Hub Trust features at all, then this is also only a maintenance release for the Hub app itself and nothing more is needed to run the entire Hub assembly.
5
+ * If you do use Hub Trust features, then note that the way in which you launch the Trust Server, which previously auto-launched with the Hub app but was prone to being killed or otherwise terminating without warning, has changed. In a manner similar to the separately-launched and reliable Session server, the Trust server must be separately launched. This is done with a Rake task so that the Trust server has full access to the Hub app environment.
6
+
7
+ 4.0.1 just updated Gemspec metadata without any other changes - I didn't realise you couldn't yank & republish the same version anymore in RubyGems, so was forced to bump the patch version.
8
+
1
9
  ## 3.8.2, 17-May-2025
2
10
 
3
11
  * General maintenance update.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hubssolib (3.8.2)
4
+ hubssolib (4.0.0)
5
5
  base64 (~> 0.2)
6
6
  drb (~> 2.2)
7
7
 
@@ -85,9 +85,9 @@ GEM
85
85
  base64 (0.3.0)
86
86
  bigdecimal (4.1.2)
87
87
  builder (3.3.0)
88
- concurrent-ruby (1.3.6)
88
+ concurrent-ruby (1.3.8)
89
89
  connection_pool (3.0.2)
90
- crass (1.0.6)
90
+ crass (1.0.7)
91
91
  date (3.5.1)
92
92
  debug (1.11.1)
93
93
  irb (~> 1.10)
@@ -97,11 +97,11 @@ GEM
97
97
  doggo (1.4.0)
98
98
  rspec-core (~> 3.13)
99
99
  drb (2.2.3)
100
- erb (6.0.4)
100
+ erb (6.0.6)
101
101
  erubi (1.13.1)
102
- globalid (1.3.0)
102
+ globalid (1.4.0)
103
103
  activesupport (>= 6.1)
104
- i18n (1.14.8)
104
+ i18n (1.15.2)
105
105
  concurrent-ruby (~> 1.0)
106
106
  io-console (0.8.2)
107
107
  irb (1.18.0)
@@ -109,24 +109,24 @@ GEM
109
109
  prism (>= 1.3.0)
110
110
  rdoc (>= 4.0.0)
111
111
  reline (>= 0.4.2)
112
- json (2.19.5)
112
+ json (2.21.1)
113
113
  logger (1.7.0)
114
- loofah (2.25.1)
114
+ loofah (2.25.2)
115
115
  crass (~> 1.0.2)
116
116
  nokogiri (>= 1.12.0)
117
- mail (2.9.0)
117
+ mail (2.9.1)
118
118
  logger
119
119
  mini_mime (>= 0.1.1)
120
120
  net-imap
121
121
  net-pop
122
122
  net-smtp
123
- marcel (1.1.0)
123
+ marcel (1.2.1)
124
124
  mini_mime (1.1.5)
125
125
  mini_portile2 (2.8.9)
126
126
  minitest (6.0.6)
127
127
  drb (~> 2.0)
128
128
  prism (~> 1.5)
129
- net-imap (0.6.4)
129
+ net-imap (0.6.6)
130
130
  date
131
131
  net-protocol
132
132
  net-pop (0.1.2)
@@ -136,16 +136,13 @@ GEM
136
136
  net-smtp (0.5.1)
137
137
  net-protocol
138
138
  nio4r (2.7.5)
139
- nokogiri (1.19.3)
139
+ nokogiri (1.19.4)
140
140
  mini_portile2 (~> 2.8.2)
141
141
  racc (~> 1.4)
142
- pp (0.6.3)
142
+ pp (0.6.4)
143
143
  prettyprint
144
144
  prettyprint (0.2.0)
145
145
  prism (1.9.0)
146
- psych (5.3.1)
147
- date
148
- stringio
149
146
  racc (1.8.1)
150
147
  rack (3.2.6)
151
148
  rack-session (2.1.2)
@@ -173,8 +170,8 @@ GEM
173
170
  activesupport (>= 5.0.0)
174
171
  minitest
175
172
  nokogiri (>= 1.6)
176
- rails-html-sanitizer (1.7.0)
177
- loofah (~> 2.25)
173
+ rails-html-sanitizer (1.7.1)
174
+ loofah (~> 2.25, >= 2.25.2)
178
175
  nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
179
176
  railties (8.1.3)
180
177
  actionpack (= 8.1.3)
@@ -186,9 +183,14 @@ GEM
186
183
  tsort (>= 0.2)
187
184
  zeitwerk (~> 2.6)
188
185
  rake (13.4.2)
189
- rdoc (7.2.0)
186
+ rbs (4.0.3)
187
+ logger
188
+ prism (>= 1.6.0)
189
+ tsort
190
+ rdoc (8.0.0)
190
191
  erb
191
- psych (>= 4.0.0)
192
+ prism (>= 1.6.0)
193
+ rbs (>= 4.0.0)
192
194
  tsort
193
195
  reline (0.6.3)
194
196
  io-console (~> 0.5)
@@ -212,7 +214,6 @@ GEM
212
214
  simplecov_json_formatter (~> 0.1)
213
215
  simplecov-html (0.13.2)
214
216
  simplecov_json_formatter (0.1.4)
215
- stringio (3.2.0)
216
217
  thor (1.5.0)
217
218
  timeout (0.6.1)
218
219
  tsort (0.2.0)
@@ -220,11 +221,11 @@ GEM
220
221
  concurrent-ruby (~> 1.0)
221
222
  uri (1.1.1)
222
223
  useragent (0.16.11)
223
- websocket-driver (0.8.0)
224
+ websocket-driver (0.8.2)
224
225
  base64
225
226
  websocket-extensions (>= 0.1.0)
226
227
  websocket-extensions (0.1.5)
227
- zeitwerk (2.7.5)
228
+ zeitwerk (2.8.2)
228
229
 
229
230
  PLATFORMS
230
231
  ruby
data/README.md CHANGED
@@ -30,18 +30,17 @@ Include in a project by adding this to your `Gemfile`:
30
30
  gem 'hubssolib', '~> 3.0', require: 'hub_sso_lib'
31
31
  ```
32
32
 
33
- ### The DRb server
33
+ ### The DRb Session Server
34
34
 
35
- The Hub DRb server consists of a small wrapper Ruby script which does most of its work using the Hub gem. To run the server, you need to first specify a DRb connection URI in the `HUB_CONNECTION_URI` environment variable. Usually, this is a Unix domain socket and so lives in a location of your choice in the local filesystem. Run the server by running `ruby` on the `hub_sso_server.rb` file in the Hub archive. For example:
35
+ The Hub DRb Session Server consists of a small wrapper Ruby script which does most of its work using the Hub gem. The server needs to know the DRb connection URI that works for your system. A Unix-domain socket using a socket file `~/.hub_drb` is chosen as the default, but can override this with the `HUB_CONNECTION_URI` environment variable. If you specify a custom URI, note that it _MUST_ start with `drbunix:`; the Session Server must not be run on an IP port for security reasons.
36
+
37
+ The server Ruby script has its own `Gemfile`, so after a `bundle install` inside the folder where `hub_sso_server.rb` lives, run with something like this:
36
38
 
37
39
  ```sh
38
- HUB_CONNECTION_URI="drbunix:/home/username/sockets/.hub_drb"
39
- export HUB_CONNECTION_URI
40
- ruby /home/username/hubssolib/hub_sso_server.rb &
40
+ HUB_CONNECTION_URI="drbunix:/home/username/sockets/.hub_drb" \
41
+ bundle exec ruby /home/username/hubssolib/server/hub_sso_server.rb &
41
42
  ```
42
43
 
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.
44
-
45
44
  ### The Hub application
46
45
 
47
46
  Finally you can install the Hub application using whatever mechanism you prefer to application installation. See ample documentation elsewhere on the Web for information on installing Ruby On Rails applications — Hub itself contains the default rails README file with quite a lot of information in it.
@@ -472,16 +471,24 @@ $ bundle exec rails c
472
471
 
473
472
  The trust mechanism involves a fair amount of effort on the integrating app's side but it can be very useful if you have a site where, despite your best efforts, sometimes spam/bot accounts manage to get inside and try to flood the system with spam. It's just one of many different potential protection and mitigation mechanisms that your site might choose to employ.
474
473
 
475
- **SERVER NOTE:** The Trust DRb server runs inside the Hub application, which runs using Puma as a server by default. The Trust server is started within the Hub application's `puma.rb` configuration file, because it needs to make sure it runs once, after booting, and is not destroyed by worker fork teardown/standup. If you aren't going to use Puma, you'll need to find a way to set this up; you'll want code akin to this in `app/hub/config/application.rb`:
474
+ ### The DRb Trust Server
476
475
 
477
- ```ruby
478
- if defined? Rails::Server
479
- Rails::Application::Finisher.initializer 'uk.org.pond.hubssolib.trustserver' do
480
- Thread.new do
481
- HubSsoLib::Trust.launch_server()
482
- end
483
- end
484
- end
476
+ In a similar fashion to the DRb Session Server, there is a Trust Server which must be launched so that applications using the mechanism describe above have something to "talk" to (with the underlying mechanics taken care of by the Hub gem). In Hub v3, this was managed by the Hub app itself but process management and lifecycles can be complex in a Rails app and the approach was unreliable. Since Hub v4 there is a much more reliable, separately-launched command, just like with the Session Server.
477
+
478
+ Untrusted action data is stored in the Hub app database and the Hub app will send notification e-mails out to moderators for each untrusted action event, so the DRb Trust Server is run via a Rake task that's part of the Hub app and uses its configured environment. The same environment variables that you pass to launch the Hub application should therefore be passed to the Rake task. As a bare minimum, make sure that `HUB_PATH_PREFIX` is set to the full URL needed to access the root path of the Hub application's web interface, as this is used when generating URLs in notification e-mails.
479
+
480
+ The default location of the Unix-domain DRb server socket is `~/.hub_trust_drb` but you can override it with `HUB_TRUST_CONNECTION_URI`. As with the Session Server, if you specify a custom URI, note that it _MUST_ start with `drbunix:`; the Trust Server must not be run on an IP port for security reasons.
481
+
482
+ ```sh
483
+ HUB_TRUST_CONNECTION_URI="drbunix:/home/username/sockets/.hub_trust_drb" \
484
+ HUB_PATH_PREFIX="https://www.example.com/hub" \
485
+ bundle exec bin/rails hub_trust:server &
485
486
  ```
486
487
 
487
- ...but that only works if the code would be run once and never torn down (a one-process server setup). There are many different Ruby web server approaches and it's not possible to be more specific; you just need to read the documentation about lifecycles and callbacks for the server you choose.
488
+ You can silence `$stdout` with `HUB_QUIET_SERVER=yes`, or if wishing to instead capture output to log files, the Rails `log` folder is a good place to put them:
489
+
490
+ ```sh
491
+ HUB_TRUST_CONNECTION_URI="drbunix:/home/username/sockets/.hub_trust_drb" \
492
+ HUB_PATH_PREFIX="https://www.example.com/hub" \
493
+ bundle exec bin/rails hub_trust:server 1>> "log/trust_server_stdout.log" 2>> "logs/trust_server_stderr.log" &
494
+ ```
Binary file
data/hubssolib.gemspec CHANGED
@@ -4,13 +4,15 @@ spec = Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.name = 'hubssolib'
6
6
 
7
- s.version = '3.8.2'
7
+ s.version = '4.0.1'
8
8
  s.author = 'Andrew Hodgkinson and others'
9
9
  s.email = 'ahodgkin@rowing.org.uk'
10
10
  s.homepage = 'http://pond.org.uk/'
11
11
  s.summary = 'Cross-application single sign-on support library.'
12
12
  s.license = 'MIT'
13
13
 
14
+ s.metadata["source_code_uri"] = "https://gitlab.riscosopen.org/website/hubssolib"
15
+
14
16
  s.description = <<-EOF
15
17
  The Hub SSO Library supports single sign-on across multiple Rails
16
18
  applications on the same host. The Hub application provides account
data/lib/hub_sso_lib.rb CHANGED
@@ -927,51 +927,56 @@ module HubSsoLib
927
927
  return File.exist?(path)
928
928
  end
929
929
 
930
- # Start the trust server. This should only ever be called by the Hub Rails
931
- # application, which implements HubSsoLib::Trust::Server.
932
- #
933
- def self.launch_server
934
- uri = self.get_trust_server_connection_uri()
935
- already_running = self.already_running?
930
+ module Server
931
+ def hubssolib_launch_trust_server
932
+ ::HubSsoLib::Trust::Server::Runner.run
933
+ end
936
934
 
937
- unless ENV['HUB_QUIET_SERVER'] == 'yes'
938
- message = unless already_running
939
- "Trust server: Starting at #{ uri }"
940
- else
941
- "Trust server: Already running at at #{ uri }"
942
- end
935
+ class Runner
936
+ QUEUE = ::Queue.new
943
937
 
944
- puts message
945
- end
938
+ def self.run
939
+ uri = ::HubSsoLib::Trust.get_trust_server_connection_uri()
940
+ already_running = ::HubSsoLib::Trust.already_running?
946
941
 
947
- unless already_running
948
- loop do
949
- DRb.start_service(uri, ::HubSsoLib::Trust::Server.new)
950
- DRb.thread.join # Keep the thread alive...
951
- end # ...but auto-restart if e.g. DRb.stop_service() is invoked
952
- end
953
- end
942
+ unless ENV['HUB_QUIET_SERVER'] == 'yes'
943
+ message = unless already_running
944
+ "Trust server: Starting at #{ uri }"
945
+ else
946
+ "Trust server: Already running at at #{ uri }"
947
+ end
954
948
 
955
- # Obtain a connection to the trust server. This is called by any client
956
- # code that needs to talk to the server which must, at the time called, be
957
- # running via startup within the Hub Rails application.
958
- #
959
- # The returned object is an instance of ::HubSsoLib::Trust::Server, which
960
- # is defined inside the Hub Rails application. See there for details.
961
- #
962
- def self.get_trust_object
963
- HUB_MUTEX.synchronize do
964
- begin
965
- DRb.current_server
966
- rescue DRb::DRbServerNotFound
967
- DRb.start_service()
949
+ puts message
950
+ end
951
+
952
+ Signal.trap('INT' ) { QUEUE << :INT }
953
+ Signal.trap('TERM') { QUEUE << :TERM }
954
+
955
+ DRb.start_service(uri, ::HubApp::Trust::ActionManager.new, { :safe_level => 1 })
956
+
957
+ QUEUE.pop
958
+
959
+ self.shutdown()
960
+ exit
961
+
962
+ rescue => e
963
+ Sentry.capture_exception(e) if defined?(Sentry) && Sentry.respond_to?(:capture_exception)
964
+ raise
968
965
  end
969
966
 
970
- @@trust_object ||= DRbObject.new_with_uri(self.get_trust_server_connection_uri())
971
- end
967
+ def self.shutdown
968
+ unless ENV['HUB_QUIET_SERVER'] == 'yes'
969
+ puts "Server: Graceful shutdown..."
970
+ end
972
971
 
973
- return @@trust_object
974
- end
972
+ DRb.stop_service
973
+
974
+ unless ENV['HUB_QUIET_SERVER'] == 'yes'
975
+ puts "Server: ...completed."
976
+ end
977
+ end
978
+ end # Runner class
979
+ end # Server module
975
980
  end
976
981
 
977
982
  #######################################################################
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hubssolib
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.2
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Hodgkinson and others
@@ -138,12 +138,14 @@ files:
138
138
  - Gemfile
139
139
  - Gemfile.lock
140
140
  - README.md
141
+ - hubssolib-4.0.0.gem
141
142
  - hubssolib.gemspec
142
143
  - lib/hub_sso_lib.rb
143
144
  homepage: http://pond.org.uk/
144
145
  licenses:
145
146
  - MIT
146
- metadata: {}
147
+ metadata:
148
+ source_code_uri: https://gitlab.riscosopen.org/website/hubssolib
147
149
  rdoc_options: []
148
150
  require_paths:
149
151
  - lib
@@ -158,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
160
  - !ruby/object:Gem::Version
159
161
  version: '0'
160
162
  requirements: []
161
- rubygems_version: 4.0.10
163
+ rubygems_version: 4.0.16
162
164
  specification_version: 4
163
165
  summary: Cross-application single sign-on support library.
164
166
  test_files: []