Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#55481 closed feature request (invalid)

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

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

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
5 years ago

  • Component Plugins → 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
5 years ago

  • Resolution → invalid
  • Status new → 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
5 years ago

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

#4 @desrosj
4 years ago

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