diff --git a/README.md b/README.md index 5753f69..0888d00 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,19 @@ The S3 API is available at http://localhost:3900 (region `garage`). If you want to start over with a fresh storage, delete the `garage-data` volume as well as the container. +#### Accessing remoteStorage from another machine + +remoteStorage clients force HTTPS for any host except `localhost`, and browsers +block plain-HTTP requests to a LAN IP as mixed content. To connect to the dev +remoteStorage from a browser on another machine (including production apps such +as Inspektor), forward the ports over SSH and connect as `localhost`: + + ssh -N -L 3000:localhost:3000 -L 4567:localhost:4567 @ + +Then use `@localhost:3000` as the remoteStorage address in the client. +WeFinger discovery and storage requests are served through the forwarded ports, +so no TLS setup is needed. + ### Adding npm modules to use with Stimulus controllers The following command downloads the specified npm module to `vendor/javascript` diff --git a/app/controllers/services/rs_auths_controller.rb b/app/controllers/services/rs_auths_controller.rb index f9376d8..2fff161 100644 --- a/app/controllers/services/rs_auths_controller.rb +++ b/app/controllers/services/rs_auths_controller.rb @@ -22,9 +22,12 @@ class Services::RsAuthsController < Services::BaseController end def launch_app - user_address = Rails.env.development? ? - "#{current_user.cn}@localhost:3000" : - current_user.address + user_address = + if Rails.env.development? + "#{current_user.cn}@#{request.host_with_port}" + else + current_user.address + end launch_url = "#{@auth.launch_url}#remotestorage=#{user_address}" diff --git a/app/controllers/webfinger_controller.rb b/app/controllers/webfinger_controller.rb index a8e00f7..175fe5a 100644 --- a/app/controllers/webfinger_controller.rb +++ b/app/controllers/webfinger_controller.rb @@ -88,8 +88,14 @@ class WebfingerController < WellKnownController end def remotestorage_link - auth_url = new_rs_oauth_url(@username, host: Setting.rs_accounts_domain) - storage_url = "#{Setting.rs_storage_url}/#{@username}" + auth_url = + if Rails.env.development? + new_rs_oauth_url(@username) + else + new_rs_oauth_url(@username, host: Setting.rs_accounts_domain) + end + + storage_url = "#{remotestorage_storage_base_url}/#{@username}" { rel: "http://tools.ietf.org/id/draft-dejong-remotestorage", @@ -103,4 +109,12 @@ class WebfingerController < WellKnownController } } end + + def remotestorage_storage_base_url + return Setting.rs_storage_url unless Rails.env.development? + + uri = URI.parse(Setting.rs_storage_url) + uri.host = request.host + uri.to_s + end end