Skip to content

Improve handling of redirected URLs #34

Open

Description

@gRegorLove

Describe the bug

There is an edge case when:

  • A URL links the indieauth metadata using a relative URL, e.g. my site has <link rel="indieauth-metadata" href="/indieauth-metadata-endpoint/">
  • Start the indieauth process with an http URL that redirects to https: http://gregorlove.com
  • Call discoverMetadataEndpoint
    • This calls _discoverEndpoint which calls _fetchHead and _fetchBody
  • The p3k/http calls in _fetchBody and _fetchHead correctly follow the redirects and include the final URL in the url property.
  • The final URL is not returned to _discoverEndpoint, though. When it calls _extractEndpointFromHTML, it's using the original http URL to resolve the endpoint URL.
  • The result from discoverMetadataEndpoint is then http://gregorlove.com/indieauth-metadata-endpoint/ instead of https. This causes issuer validation to fail.

Potential fix

Add a new session value to store the final URL that p3k/http responds with and use that when resolving URLs after the fetch. This might require some additional security checks, e.g. "is the final URL still the same hostname that was entered?" Maybe not, though, since it already has validations for the authz endpoint, issuer, and token endpoint when completing.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions