<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>239944</bug_id>
          
          <creation_ts>2022-05-01 08:29:21 -0700</creation_ts>
          <short_desc>Safari does not persist the Authorization header on redirect</short_desc>
          <delta_ts>2024-09-18 09:09:52 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>230935</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=56716</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="lmx">906529775</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>ap</cc>
    
    <cc>beidson</cc>
    
    <cc>biafrajr</cc>
    
    <cc>bs</cc>
    
    <cc>mike</cc>
    
    <cc>nanilasyukia</cc>
    
    <cc>sandrarobel45</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1865724</commentid>
    <comment_count>0</comment_count>
    <who name="lmx">906529775</who>
    <bug_when>2022-05-01 08:29:21 -0700</bug_when>
    <thetext>Sorry, my English is not good, the following content is generated by translation software.

I describe the problem I have:

In Safari, I send a request via fetch:

/api/user/list?page=1&amp;page_size=10

Because the path is wrong, the status code returned by the server is 301, and a new request path is given:

/api/user/list/?page=1&amp;page_size=10

After Safari receives 301, it automatically sends a new request, but does not bring the Authorization request header.

My expectation is to bring the Authorization request header when redirecting, what should I do? Looking forward to your reply, thanks.

Note: When redirecting, the Chrome browser will take the Authorization request with it.

The full request log is below:

First request(Has Authorization request header):

Request
GET /api/user/list?page=1&amp;page_size=10
Authorization: Bearer xxxxxxxxxxxx
Referer: https://test.com/api/user/list?page=1&amp;page_size=10
Accept: */*
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15
Cache-Control: no-cache
Pragma: no-cache
X-OA-ID: 10004572

------

Response to first request:

Redirect Response
301 Moved Permanently
Location: /api/user/list/?page=1&amp;page_size=10
Date: Sun, 01 May 2022 09:29:24 GMT
Referrer-Policy: same-origin

------

Redirects automatically sent by Safari(No Authorization header):

Request
GET /api/user/list/?page=1&amp;page_size=10 HTTP/1.1
Accept: */*
Pragma: no-cache
Cookie: xxxxxxxxxxxx
Referer: https://test.com/api/user/list
Cache-Control: no-cache
Host: test.com
Accept-Language: en-US,en;q=0.9
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
X-OA-ID: 10004572

------


I found 2 similar questions on stackoverflow, but none were solved.

https://stackoverflow.com/questions/71311305/how-to-prevent-safari-from-dropping-the-authorization-header-when-following-a-sa

https://stackoverflow.com/questions/57974176/safari-does-not-persist-the-authorization-header-on-redirect</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1866401</commentid>
    <comment_count>1</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2022-05-04 02:26:43 -0700</bug_when>
    <thetext>It seems to make sense to keep the authorization header for same origin redirections.
It would be good to check where we are dropping the header (WebKit networking code or CFNetwork).

See https://github.com/whatwg/fetch/issues/944 for WhatWG fetch discussion.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1866402</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-05-04 02:26:54 -0700</bug_when>
    <thetext>&lt;rdar://problem/92721299&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1869228</commentid>
    <comment_count>3</comment_count>
      <attachid>459426</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2022-05-16 08:04:43 -0700</bug_when>
    <thetext>Created attachment 459426
Example</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1869229</commentid>
    <comment_count>4</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2022-05-16 08:06:37 -0700</bug_when>
    <thetext>I uploaded an example which seems to show that the Authorisation header is being preserved on same origin redirections.

@lmx, on which Safari version are you? Can you try Safari Tech Preview?
Can you provide a repro case (public or privately at youenn@apple.com) or look at the provided example to see what is different?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1869666</commentid>
    <comment_count>5</comment_count>
    <who name="lmx">906529775</who>
    <bug_when>2022-05-17 07:01:31 -0700</bug_when>
    <thetext>@youenn fablet

Hello, I uploaded the code here.
https://github.com/mrlmx/safari-redirect-demo


You can also test through this online demo.
https://safari-redirect-demo.vercel.app</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1869674</commentid>
    <comment_count>6</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2022-05-17 07:45:04 -0700</bug_when>
    <thetext>Testing in Safari Tech Preview on macOS Monterey, I get the list of users with https://github.com/mrlmx/safari-redirect-demo:
lmx:18
foo:17
bar:16

@lmx, which version of Safari and iOS/macOS are you testing on?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1869677</commentid>
    <comment_count>7</comment_count>
    <who name="lmx">906529775</who>
    <bug_when>2022-05-17 07:53:02 -0700</bug_when>
    <thetext>@youenn fablet

Neither of my two Macs works properly. This is the corresponding version.

---

macOS Monterey
Version 12.1 (21C52)

Safari
Version 15.2 (17612.3.6.1.6)

---

macOS Big Sur
Version 11.3(20E232)

Safari
Version 14.1 (16611.1.21.161.3)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1869920</commentid>
    <comment_count>8</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2022-05-17 22:56:27 -0700</bug_when>
    <thetext>This is now fixed in latest Safari macOS 12.3

*** This bug has been marked as a duplicate of bug 230935 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1869928</commentid>
    <comment_count>9</comment_count>
    <who name="lmx">906529775</who>
    <bug_when>2022-05-17 23:42:01 -0700</bug_when>
    <thetext>Thank you(In reply to youenn fablet from comment #8)
&gt; This is now fixed in latest Safari macOS 12.3
&gt; 
&gt; *** This bug has been marked as a duplicate of bug 230935 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1981354</commentid>
    <comment_count>10</comment_count>
    <who name="derben">bs</who>
    <bug_when>2023-09-29 12:10:16 -0700</bug_when>
    <thetext>I’m still experiencing this issue on Safari for iOS on my IPhone SE 2020 running iOS 16.6.1. Shouldn’t this be fixed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1981363</commentid>
    <comment_count>11</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2023-09-29 12:34:13 -0700</bug_when>
    <thetext>Yes, it&apos;s supposed to have been fixed. Could you please file a new bug from scratch, with precise steps to reproduce and any additional information?</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>459426</attachid>
            <date>2022-05-16 08:04:43 -0700</date>
            <delta_ts>2022-05-16 08:04:43 -0700</delta_ts>
            <desc>Example</desc>
            <filename>0001-example.patch</filename>
            <type>text/plain</type>
            <size>2991</size>
            <attacher name="youenn fablet">youennf</attacher>
            
              <data encoding="base64">RnJvbSA3ODU1OWM4ZmFjO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