play-authenticate icon indicating copy to clipboard operation
play-authenticate copied to clipboard

Basic provider route throws exception

Open ghost opened this issue 5 years ago • 6 comments

Opening http://localhost:9000/authenticate/basic (thus the examples HTTP basic auth) causes the following error on samples/java/play-authenticate-usage@3f70e03:

[error] application - 

! @79b3ccanf - Internal server error, for (GET) [/authenticate/basic] ->
 
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[NoSuchElementException: No value present]]
	at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:251)
	at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:178)
	at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:363)
	at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:361)
	at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:413)
	at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:37)
	at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)
	at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
	at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
Caused by: java.util.NoSuchElementException: No value present
	at java.util.Optional.get(Optional.java:135)
	at com.feth.play.module.pa.providers.wwwauth.WWWAuthenticateProvider.authenticate(WWWAuthenticateProvider.java:102)
	at com.feth.play.module.pa.PlayAuthenticate.handleAuthentication(PlayAuthenticate.java:388)
	at com.feth.play.module.pa.controllers.Authenticate.authenticate(Authenticate.java:20)
	at router.Routes$$anonfun$routes$1.$anonfun$applyOrElse$16(Routes.scala:622)
	at play.core.routing.HandlerInvokerFactory$$anon$3.resultCall(HandlerInvoker.scala:134)
	at play.core.routing.HandlerInvokerFactory$$anon$3.resultCall(HandlerInvoker.scala:133)
	at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$8$$anon$2$$anon$1.invocation(HandlerInvoker.scala:108)
	at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:88)
	at play.http.DefaultActionCreator$1.call(DefaultActionCreator.java:31)

I've tried debugging and I didn't figure where's the problem, maybe as I'm new to the framework too. I'm going to test previous versions and will report any findings. I appreciate any help.

ghost avatar Sep 21 '18 09:09 ghost

Due to dependency resolving problems, I can't put my finger on the exact commit that's introducing the error. cd162660da13fdf0a1abfc778c492383e708a660 is the last commit that I found has no problem with basic authentication. ef6b81a2f9deca9bf5ea1781b526fe784ea9279b is the earliest commit that I could confirm for affected basic authentication. I didn't check 8418466c5aad0c7a10e54ad4a444f4f9a88184a2, cc8b1d9d30d119e3f0021f71ead9da245d2f0e99, b87320028452a943a1251fba69743affd5aea96d due to failing dependency downloads, neither did i check 98036b90693c85bf855b544a3361b64cb5efa590 due to a failing build with sbt run.

When I authenticated successfully in an unaffected version, affected versions redirected from http://localhost:9000/authenticate/basic without prompting an error. Of course, resetting the browser session got back the error prompt.

ghost avatar Sep 21 '18 12:09 ghost

hmm, the diff from cd16266 to ef6b81a is not terrible and it shouldn't be the form changes.

joscha avatar Sep 24 '18 14:09 joscha

Ah, I think I found it - its the Optionals handling.

joscha avatar Sep 24 '18 14:09 joscha

I pushed a fix in 02138d9, can you please give that a try @adpes?

joscha avatar Sep 24 '18 14:09 joscha

I pushed a fix in 02138d9, can you please give that a try @adpes?

Unfortunately, I do still experience the issue.

How can I make sure that contents of folders respectively code or samples/java/play-authenticate-usage/modules/ are used in the example? I reckon mismatching byte-code and source-code when debugging. What's the difference in commenting the line

  // Comment the next line for local development of the Play Authentication core:
  // Use the latest release version when copying this code, e.g. "0.9.0"
  "com.feth" %% "play-authenticate" % "0.9.0-SNAPSHOT"

and uncommenting the line

  //  Uncomment the next line for local development of the Play Authenticate core:
  //lazy val playAuthenticate = project.in(file("modules/play-authenticate")).enablePlugins(PlayJava)

for sbt's dependencies? There are pgp and routing errors thrown with the commented and uncommentented line, respectively.

ghost avatar Sep 27 '18 08:09 ghost

Ah yes, there are a few places in the various files of the sample where it says Comment here - you need to find all of them for it to use the local code. Alternatively, can you check if the commit with the fix produced a snapshot build? It should have, then you can just replace the release version with he snapshot version and it should work as well.

Cheers, Joscha

On Thu., 27 Sep. 2018, 18:45 adpes, [email protected] wrote:

I pushed a fix in 02138d9 https://github.com/joscha/play-authenticate/commit/02138d9b25a3d9ec6f0d04d2de97b4fb243801dc, can you please give that a try @adpes https://github.com/adpes?

Unfortunately, I do still experience the issue.

How can I make sure that contents of folders respectively code or samples/java/play-authenticate-usage/modules/ are used in the example? I reckon mismatching byte-code and source-code when debugging. What's the difference between commenting the line

// Comment the next line for local development of the Play Authentication core: // Use the latest release version when copying this code, e.g. "0.9.0" "com.feth" %% "play-authenticate" % "0.9.0-SNAPSHOT"

for sbt's dependencies? There are routing errors thrown with the commented line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/joscha/play-authenticate/issues/367#issuecomment-425009764, or mute the thread https://github.com/notifications/unsubscribe-auth/AALehkrCEiQmcMjfdAs2QfzjUVO7CgyBks5ufJAhgaJpZM4Wzvr9 .

joscha avatar Sep 27 '18 22:09 joscha