Uploaded image for project: 'Artifactory Binary Repository'
  1. Artifactory Binary Repository
  2. RTFACT-26216

Native browser redirect prevents windows Power Shell (Invoke-WebRequest command) from downloading a file

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 7.21.19, 7.29.8
    • Component/s: Artifactory
    • Labels:
    • Environment:
      • Tested on 7.21.12 
      • DB type - built in Derby.
      • On-Prem 
    • Location:
      External

      Description

      Problem description:  

      Native browser redirect prevents windows Power Shell (Invoke-WebRequest command) from downloading a file.

      Artifactory is not properly detecting the PowerShell user-agent and are treating it as a browser rather than a command-line tool

      [UPDATE]: Artifactory redirects request to /ui/native/ if user-agent starts with "Mozilla"

       

      What is the impact on the customer?

      Due to the Navie browser implemented recently, it breaks the Powershell Invoke-WebRequest command in Artifactory 7.21.12

      Invoke-WebRequest command results in an html response.

       

      For example, 

       (Invoke-WebRequest -Uri http://ART_URL:8082/artifactory/generic-local/a.txt).Content

      <!doctype html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=apple-touch-icon sizes=180x180 href=./apple-touch-icon.png><link rel=icon type=image/png sizes=32x32 href=./favicon-32x32.png><link rel=icon type=image/png sizes=16x16 href=./favicon-16x16.png><link rel=mask-icon href=./safari-pinned-tab.svg color=#f5f5f2><link rel="shortcut icon" href=./favicon.ico><title>JFrog</title><base href=/ui/ ><style>@keyframes heartbeatOut{from
      {opacity:1}
      50%{opacity:0;transform:scale(.8)}to{opacity:0;transform:scale(.8)}}@keyframes heartbeat{from
      {transform:scale3d(1,1,1)}
      50%{transform:scale3d(1.15,1.15,1.15)}to{transform:scale3d(1,1,1)}}.p
      .....
      ;</script><noscript><strong>We're sorry but jfrog webapp doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><link rel=stylesheet type=text/css href=/ui/webapp/css/vendorStyles.css><link rel=stylesheet type=text/css href=/ui/webapp/css/application.css><div id=app></div><script src=/ui/js/chunk-vendors.17d4df36.js></script><script src=/ui/js/app.3239ef01.js></script></body></html>
       
      

      What is the expected behavior? 

      Invoke-WebRequset should work as following.

      (Invoke-WebRequest -Uri http://ART_URL:8082/artifactory/generic-local/a.txt).Content

       

      asdfasdfsafd
      

       

       

       

      Steps to reproduce: 

      1)  upload a file to generic-local/a.txt  in Aritifactory 7.21.12 and set Allow Anonymous Access

      2)  run the following command in  Windows Powershell

         (Invoke-WebRequest -Uri http://ART_URL:8082/artifactory/generic-local/a.txt).Content

       

       

      Possible workaround: 

      1. Either stripping the user-agent at a load balancer level or need to change Artifactory uri such as  /ui/api/v1/download?repoKey=generic-local&path=a.txt

       (Invoke-WebRequest -Uri 'http://ART_URL:8082/ui/api/v1/download?repoKey=generic-local&path=a.txt').Content

      2. Disable redirect to UI for the native browser by setting the property below: (artifactory.system.property)
      artifactory.redirect.native.browser.requests.to.ui=false

      3. Override the user-agent (to one that doesn’t start with "Mozilla") when sending the request.
       

      Any relevant Stacktrace

       artifactory-request.log

      2021-08-04T20:18:57.220Z|31fb4dc0c9735471|IP_ADDRESS|non_authenticated_user|GET|/generic-local/a.txt|302|-1|0|0|Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.14393.4530
      

       

        Attachments

          Activity

              People

              Assignee:
              Unassigned
              Reporter:
              davids David Shin
              Votes:
              3 Vote for this issue
              Watchers:
              16 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Sync Status

                  Connection: RTFACT Sync
                  RTMID-26217 -
                  SYNCHRONIZED
                  • Last Sync Date: