Class: HubSsoLib::Trust
- Inherits:
-
Object
- Object
- HubSsoLib::Trust
- Defined in:
- lib/hub_sso_lib.rb
Overview
Class: Trust #
#
Purpose: Allow other applications to call into the Hub Rails #
application to tell it about untrusted user operations. #
The application can then store the details, e-mail #
moderators and in due course call back to the originating #
other application to move the user action forwards. #
#
The external API is HubSsoLib::Trust::Server, implemented #
by the Hub Rails application, not this gem. #
#
Author: A.D.Hodgkinson #
#
History: 19-Mar-2025 (ADH): Created #
Class Method Summary collapse
-
.get_trust_object ⇒ Object
Obtain a connection to the trust server.
-
.get_trust_server_connection_uri ⇒ Object
Return the DRb endpoint URI for the trust server.
-
.launch_server ⇒ Object
Start the trust server.
Class Method Details
.get_trust_object ⇒ Object
Obtain a connection to the trust server. This is called by any client code that needs to talk to the server which must, at the time called, be running via startup within the Hub Rails application.
The returned object is an instance of ::HubSsoLib::Trust::Server, which is defined inside the Hub Rails application. See there for details.
898 899 900 901 902 903 904 905 906 907 908 909 910 |
# File 'lib/hub_sso_lib.rb', line 898 def self.get_trust_object HUB_MUTEX.synchronize do begin DRb.current_server rescue DRb::DRbServerNotFound DRb.start_service() end @@trust_object ||= DRbObject.new_with_uri(self.get_trust_server_connection_uri()) end return @@trust_object end |
.get_trust_server_connection_uri ⇒ Object
Return the DRb endpoint URI for the trust server.
861 862 863 |
# File 'lib/hub_sso_lib.rb', line 861 def self.get_trust_server_connection_uri HUB_TRUST_CONNECTION_URI end |
.launch_server ⇒ Object
Start the trust server. This should only ever be called by the Hub Rails application, which implements HubSsoLib::Trust::Server.
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 |
# File 'lib/hub_sso_lib.rb', line 868 def self.launch_server uri = self.get_trust_server_connection_uri() path = URI.parse(uri).path already_running = File.exist?(path) unless ENV['HUB_QUIET_SERVER'] == 'yes' = unless already_running "Trust server: Starting at #{ uri }" else "Trust server: Already running at at #{ uri }" end puts end unless already_running loop do DRb.start_service(uri, ::HubSsoLib::Trust::Server.new) DRb.thread.join # Keep the thread alive... end # ...but auto-restart if e.g. DRb.stop_service() is invoked end end |