Respect "start_url" from manifest when launching web apps
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
Râu Cao
2023-11-20 13:30:23 +01:00
parent bdf5a18ad4
commit 9a9947f9ad
3 changed files with 91 additions and 8 deletions

View File

@@ -23,11 +23,23 @@ class RemoteStorageAuthorization < ApplicationRecord
after_destroy :remove_token_expiry_job
def url
# TODO use web app scope in addition to host/client_id
uri = URI.parse self.redirect_uri
"#{uri.scheme}://#{client_id}"
end
def launch_url
return url unless web_app && web_app.metadata[:start_url].present?
start_url = web_app.metadata[:start_url]
if start_url.match("^https?:\/\/")
return start_url.start_with?(url) ? start_url : url
else
path = start_url.gsub(/^\.\.\//, "").gsub(/^\.\//, "").gsub(/^\//, "")
"#{url}/#{path}"
end
end
def delete_token_from_redis
key = "authorizations:#{user.cn}:#{token}"
redis.srem? key, redis.smembers(key)