Project

General

Profile

Actions

Bug #38424

closed

katello gives wrong HTTP response code on oauth2 request against registry token endpoint

Added by Martin Spiessl over 1 year ago. Updated 6 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
API
Target version:
Difficulty:
Triaged:
Yes
Fixed in Releases:
Found in Releases:

Description

When accessing a container registry, some clients like helm will try to authenticate using oauth2 token authentication (a POST request against the v2/token endpoint, cf. https://docker-docs.uclv.cu/registry/spec/auth/oauth/) before falling back to regular token authentication (a GET request against the v2/token endpoint, cf. https://docker-docs.uclv.cu/registry/spec/auth/token/). The spec says the following:

Note: Not all token servers implement oauth2. If the request to the endpoint returns 404 using the HTTP POST method, refer to Token Documentation for using the HTTP GET method supported by all token servers.

However, in katello we currently return 415 (Unsupported Media Type) on the POST request, because the media type check is not disabled for the token endpoint (but it is for others like upload blob), and the POST request contains data with media type application/x-www-form-urlencoded while the check only allows json. As a result, clients (like helm) are confused and will not try the regular token authentication with the GET request.

The following curl request can be used to test the response (replace foreman.example.com with your foreman instance, orgname with your orgname, productname with your product name for the container registry, and containername is arbitrary, as is username and password):

curl -k -X POST "https://forman.example.com/v2/token" -H "Content-Type: application/x-www-form-urlencoded" --data-urlencode "scope=repository:orgname/productname/containername:pull,push repository:registry:pull,push" --data-urlencode "grant_type=password" --data-urlencode "username=myuser" --data-urlencode "password=mypassword" --data-urlencode "service=foreman.example.com" -w "\\n%{http_code}\\n"

This will yield the following output: {
"error": {"message":"Media type in 'Content-Type: application/x-www-form-urlencoded' is unsupported in API v2 for POST and PUT requests. Please use 'Content-Type: application/json'."}
}

415

Actions #1

Updated by The Foreman Bot over 1 year ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/11389 added
Actions #2

Updated by Quinn James over 1 year ago

  • Category set to API
  • Target version set to Katello 4.17.0
  • Triaged changed from No to Yes
Actions #3

Updated by Pavan Soma Shekar over 1 year ago

  • Target version changed from Katello 4.17.0 to Katello 4.19.0
Actions #4

Updated by Partha Aji 12 months ago

  • Status changed from Ready For Testing to New
  • Red Hat JIRA set to SAT-34045
Actions #5

Updated by Samir Jha 9 months ago

  • Target version changed from Katello 4.19.0 to Katello 4.20.0
Actions #6

Updated by The Foreman Bot 7 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/11653 added
Actions #7

Updated by The Foreman Bot 7 months ago

  • Fixed in Releases Katello 4.21.0 added
Actions #8

Updated by Anonymous 7 months ago

  • Status changed from Ready For Testing to Closed
Actions #9

Updated by The Foreman Bot 7 months ago

  • Pull request deleted (https://github.com/Katello/katello/pull/11389, https://github.com/Katello/katello/pull/11653)
Actions #10

Updated by Pavan Soma Shekar 7 months ago

  • Red Hat JIRA changed from SAT-34045 to SAT-42278
  • Pull request https://github.com/Katello/katello/pull/11653 added
Actions #11

Updated by Ian Ballou 6 months ago

  • Fixed in Releases Katello 4.20.0 added
  • Fixed in Releases deleted (Katello 4.21.0)
Actions

Also available in: Atom PDF