Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

Basic provider route throws exception #367

Open
ghost opened this issue Sep 21, 2018 · 6 comments
Open

Basic provider route throws exception #367

ghost opened this issue Sep 21, 2018 · 6 comments

Comments

@ghost
Copy link

ghost commented Sep 21, 2018

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
Copy link
Author

ghost commented Sep 21, 2018

Due to dependency resolving problems, I can't put my finger on the exact commit that's introducing the error.
cd16266 is the last commit that I found has no problem with basic authentication. ef6b81a is the earliest commit that I could confirm for affected basic authentication.
I didn't check 8418466, cc8b1d9, b873200 due to failing dependency downloads, neither did i check 98036b9 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.

@joscha
Copy link
Owner

joscha commented Sep 24, 2018

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

@joscha
Copy link
Owner

joscha commented Sep 24, 2018

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

@joscha
Copy link
Owner

joscha commented Sep 24, 2018

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

@ghost
Copy link
Author

ghost commented Sep 27, 2018

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.

@joscha
Copy link
Owner

joscha commented Sep 27, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant