Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#55481 closed feature request (invalid)

Add custom headers for `update_plugins_{$hostname}` filter's package

Reported by: natsumesou's profile natsumesou Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords:
Focuses: Cc:

Description

This update_plugins_{$hostname} filter may aim to update private plugins, but this feature has no authentication logic.
When I add to GitHub's release zipball URL to this filter, I can update only public repository's zipball.
So I think this filter need custom headers to package's URL(e.g. Authorization header).

Thank you.

Change History (4)

#1 @pbiron
3 years ago

  • Component changed from Plugins to Upgrade/Install
  • Keywords reporter-feedback added

@natsumesou Thank you for the ticket...and welcome to Trac.

If I understand what you problem is, you can use the http_request_args filter to add the Authentication header.

You should be able to do something like (note: the following code has not been tested):

add_filter(
  'http_request_args',
  function( $parsed_args, $url ) {
    if ( MY_UPDATE_URL === $url ) {
      if ( empty( $parsed_args['headers'] ) ) {
        $parsed_args['headers'] = array();
      }

      $parsed_args['headers']['AUTHORIZATION'] = MY_AUTH_HEADER_VALUE;
    }

    return $parsed_args;
  },
  10,
  2
);

where MY_UPDATE_URL and MY_UPDATE_URL are just placeholders (and not to be interpreted as PHP constants) and should be replaced by whatever your use case requires.

#2 @natsumesou
3 years ago

  • Resolution set to invalid
  • Status changed from new to closed

@pbiron Thank you for your advice.
I was able to update my private repo's zipball by your sample.
I'm sorry for bothering you.

#3 @pbiron
3 years ago

No bother at all. Glad you got your problem solved!

#4 @desrosj
3 years ago

  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Version trunk deleted
Note: See TracTickets for help on using tickets.