Uploaded image for project: 'Red Hat 3scale API Management'
  1. Red Hat 3scale API Management
  2. THREESCALE-9408

oauth_authorize endpoint generates invalid XML response

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • SaaS, 2.13.1 GA
    • Backend
    • False
    • Hide

      None

      Show
      None
    • False
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started

      Bug's Description:

      The API endpoint /transactions/oauth_authorize.xml generates invalid XML if the configured redirect-url contains an ampersand (&). In that scenario, the XML returned contains an ampersand and therefore it's not a valid XML file since "&" is a reserved character in XML spec so must be escaped [1].

      Steps to reproduce:

      1. Create application for a product that uses OpenID Connect as authentication.
      2. Edit redirect URL of created application
      3. Set a redirect URL that contains an ampersand (&)
        i.e.
            https://example.com?foo=bar&foo2=bar2

      4. Using the service ID, backend token of the API which the application was created on and the app_id of the application, call the endpoint /transactions/oauth_authorize.xml

        i.e
            curl -v  -X GET "https://example3scale-url/transactions/oauth_authorize.xml?service_token=AAAAAAA&service_id=2555417970930&access_token=BBBBBBB&app_id=161314cc"

       

      Current behavior:

      Element status/application/redirect_url shows an ampersand (&) therefore not encoding is applied.

      <?xml version="1.0" encoding="UTF-8"?>
      <status>
        <authorized>true</authorized>
        <application>
          <id>3205577c</id>
          <key>303e42f0149760701983c6679f082e8f</key>
          <redirect_url>https://example.com?foo=bar&foo2=bar2</redirect_url>
        </application>
        <plan>neo-basic</plan>
      </status>

      Expected behavior:

      Element status/application/redirect_url contains the XML encoded variant of the ampersand (&)

      <?xml version="1.0" encoding="UTF-8"?>
      <status>
        <authorized>true</authorized>
        <application>
          <id>3205577c</id>
          <key>303e42f0149760701983c6679f082e8f</key>
          <redirect_url>https://example.com?foo=bar&amp;foo2=bar2</redirect_url>
        </application>
        <plan>neo-basic</plan>
      </status>

      [1] https://www.w3.org/TR/2004/REC-xml-20040204/

              Unassigned Unassigned
              rhn-support-icaldero Ivan Calderon Clemente
              Joan Lledo Joan Lledo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: