Skip to content

Commit

Permalink
detect aspera one
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-martin committed Feb 24, 2025
1 parent a2cb2a8 commit 2eb749c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/aspera/api/aoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def api_base_url(organization: 'api', api_domain: SAAS_DOMAIN_PROD)

# split host of http://myorg.asperafiles.com in org and domain
def split_org_domain(uri)
Aspera.assert_type(uri, URI)
raise "No host found in URL.Please check URL format: https://myorg.#{SAAS_DOMAIN_PROD}" if uri.host.nil?
parts = uri.host.split('.', 2)
Aspera.assert(parts.length == 2){"expecting a public FQDN for #{PRODUCT_NAME}"}
Expand Down
12 changes: 6 additions & 6 deletions lib/aspera/cli/plugins/aoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def detect(base_url)
base_url = "#{base_url}.#{Api::AoC::SAAS_DOMAIN_PROD}" unless base_url.include?('.')
# AoC is only https
return nil unless base_url.start_with?('https://')
res_http = Rest.new(base_url: base_url, redirect_max: 10).call(operation: 'GET')[:http]
# Any AoC is on this domain
return nil unless res_http.uri.host.end_with?(Api::AoC::SAAS_DOMAIN_PROD)
Log.log.debug{"AoC Main page: #{res_http.body.include?(Api::AoC::PRODUCT_NAME)}"}
base_url = res_http.uri.to_s if res_http.uri.path.include?('/public')
res_http = Rest.new(base_url: base_url, redirect_max: 0).call(operation: 'GET', subpath: 'auth/ping', return_error: true)[:http]
return nil if res_http['Location'].nil?
redirect_uri = URI.parse(res_http['Location'])
od = Api::AoC.split_org_domain(URI.parse(base_url))
return nil unless redirect_uri.path.end_with?("oauth2/#{od[:organization]}/login")
# either in standard domain, or product name in page
return {
version: 'SaaS',
version: base_url.include?(Api::AoC::SAAS_DOMAIN_PROD) ? 'SaaS' : 'Self-managed',
url: base_url
}
end
Expand Down

0 comments on commit 2eb749c

Please sign in to comment.