playframework / playframework/play-ws

StandaloneAhcWSRequest.createProxy should setUsePreemptiveAuth(true) for basic auth

Open
#276 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status:backlog
Dominant language
Scala
Stars
224
Forks
92
Avg merge
1d 19h
Merged PRs (30d)
28

Description

Play WS Version

1.1.10

API (Scala / Java / Neither / Both)

Scala

Expected Behavior

Requests that specify a Proxy with basic auth should setUsePreemptiveAuth(true) for the proxy realm.

Actual Behavior

Requests that specify a Proxy with basic auth never setUsePreemptiveAuth(true) for the proxy realm, causing the connection to fail.

Details / Steps to Reproduce

While unsuccessfully attempting to connect to a commercial proxy using basic auth I noticed that StandaloneAhcWSRequest is inconsistent in it's application of realm configuration; for non-proxy requests usePreemptiveAuth is always set to true for non DIGEST schemes, however, when making a proxy request, this logic is omitted.

Upon duplicating the scheme check logic in StandaloneAhcWSRequest.createProxy() my basic auth proxy requests began working.

This is the code I've been using to test:

  val proxy = DefaultWSProxyServer(
    host = "some.proxy.xx",
    port = 222,
    principal = Some("username"),
    password = Some("password"))

  wsClient
    .url("http://api.ipify.org")
    .withProxyServer(proxy)
    .get().map( _.body[String])

If someone with more knowledge about how this code should be working can validate my findings, I'd be happy to issue a PR with a fix :-)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/StandaloneAhcWSRequest.scala, comparing createProxy() with the non-proxy realm handling around line 354. Reproduce the issue with the provided DefaultWSProxyServer example and verify that basic-auth proxy requests connect successfully with preemptive authentication enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.