jaliss / securesocial

A module that provides OAuth, OAuth2 and OpenID authentication for Play Framework applications
http://www.securesocial.ws
Apache License 2.0
1.19k stars 512 forks source link

Support for play 2.5 #582

Closed malterb closed 7 years ago

malterb commented 8 years ago

As far as I can see, and if you ignore deprecation, securesocial is compatible with Play 2.5 in scala. Java needs a couple of things rewritten. Is a 2.5 version planned?

ozw-sei commented 8 years ago

+1

EnverOsmanov commented 8 years ago

I had following error with Play 2.5, Guice and SecureSocial 3.0-M4. Fixed with adding play.sbt.PlayImport.filters to libraryDependencies in build.sbt file.

[error] application - 

! @6pi0kg52j - Internal server error, for (GET) [/] ->

play.api.UnexpectedException: Unexpected exception[NoSuchMethodError: play.utils.Reflect$.bindingsFromConfiguration(Lplay/api/Environment;Lplay/api/PlayConfig;Ljava/lang/String;Ljava/lang/String;Lplay/utils/Reflect$SubClassOf;Lplay/utils/Reflect$SubClassOf;Lscala/reflect/ClassTag;Lscala/reflect/ClassTag;)Lscala/collection/Seq;]
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:174)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:126)
    at scala.Option.map(Option.scala:146)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:126)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:124)
    at scala.util.Success.flatMap(Try.scala:231)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:124)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:116)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
    at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.NoSuchMethodError: play.utils.Reflect$.bindingsFromConfiguration(Lplay/api/Environment;Lplay/api/PlayConfig;Ljava/lang/String;Ljava/lang/String;Lplay/utils/Reflect$SubClassOf;Lplay/utils/Reflect$SubClassOf;Lscala/reflect/ClassTag;Lscala/reflect/ClassTag;)Lscala/collection/Seq;
    at play.filters.csrf.CSRF$ErrorHandler$.bindingsFromConfiguration(csrf.scala:213)
    at play.filters.csrf.CSRFModule.bindings(csrf.scala:228)
    at play.api.inject.guice.GuiceableModuleConversions$class.guice(GuiceInjectorBuilder.scala:335)
    at play.api.inject.guice.GuiceableModule$.guice(GuiceInjectorBuilder.scala:269)
    at play.api.inject.guice.GuiceableModuleConversions$$anon$3$$anonfun$guiced$2.apply(GuiceInjectorBuilder.scala:314)
    at play.api.inject.guice.GuiceableModuleConversions$$anon$3$$anonfun$guiced$2.apply(GuiceInjectorBuilder.scala:314)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
    at scala.collection.immutable.List.map(List.scala:285)
    at play.api.inject.guice.GuiceableModuleConversions$$anon$3.guiced(GuiceInjectorBuilder.scala:314)
    at play.api.inject.guice.GuiceableModule$$anonfun$guiced$1.apply(GuiceInjectorBuilder.scala:291)
    at play.api.inject.guice.GuiceableModule$$anonfun$guiced$1.apply(GuiceInjectorBuilder.scala:291)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:241)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:241)
    at scala.collection.immutable.List.flatMap(List.scala:344)
    at play.api.inject.guice.GuiceableModule$.guiced(GuiceInjectorBuilder.scala:291)
    at play.api.inject.guice.GuiceBuilder.createModule(GuiceInjectorBuilder.scala:166)
    at play.api.inject.guice.GuiceApplicationBuilder.applicationModule(GuiceApplicationBuilder.scala:117)
    at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:181)
    at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:123)
    at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:158)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1$$anonfun$2.apply(DevServerStart.scala:155)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:155)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:126)
    at scala.Option.map(Option.scala:146)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:126)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:124)
    at scala.util.Success.flatMap(Try.scala:231)
    at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:124)
kildievr commented 8 years ago

https://github.com/jaliss/securesocial/pull/587 I think my pull request will fix most Play 2.5 migration problems/

fedeoasi commented 8 years ago

I am using securesocial 3.0-M4 with play 2.5.3 (although this also happens downgrading to 2.5.0). I am trying to customize the login controller as follows:

class CustomLoginController @Inject() (override implicit val env: MyRuntimeEnvironment) extends BaseLoginPage

When hitting the login page, I get is the following error:

1) Error injecting constructor, java.lang.NoSuchMethodError: securesocial.core.SecureSocial.JSON(Lplay/api/mvc/Codec;)Ljava/lang/String;
  at controllers.CustomLoginController.<init>(SecureSocialControllers.scala:13)
  while locating controllers.CustomLoginController

1 error
    at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1025)
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$5$$anonfun$apply$5.apply(Routes.scala:434)
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$5$$anonfun$apply$5.apply(Routes.scala:434)
    at play.core.routing.HandlerInvokerFactory$$anon$12$$anon$13.call(HandlerInvoker.scala:95)
    at play.core.routing.TaggingInvoker.call(HandlerInvoker.scala:39)
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$5.apply(Routes.scala:434)
    at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$5.apply(Routes.scala:434)
    at play.core.routing.GeneratedRouter.call(GeneratedRouter.scala:93)
    at router.Routes$$anonfun$routes$1.applyOrElse(Routes.scala:433)
    at router.Routes$$anonfun$routes$1.applyOrElse(Routes.scala:405)
Caused by: java.lang.NoSuchMethodError: securesocial.core.SecureSocial.JSON(Lplay/api/mvc/Codec;)Ljava/lang/String;
    at securesocial.core.SecureSocial$class.$init$(SecureSocial.scala:47)
    at controllers.CustomLoginController.<init>(SecureSocialControllers.scala:13)
    at controllers.CustomLoginController$$FastClassByGuice$$9d2279bd.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:61)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:105)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:267)
    at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)

Digging a bit I found that JSON in play.api.http.ContentTypes was changed from def JSON(implicit codec: Codec) = withCharset(MimeTypes.JSON) to val JSON = MimeTypes.JSON in the 2.5.0 release.

I tried to work around the problem by redefining the def JSON(implicit codec: Codec) method, but no luck. I am thinking that securesocial needs to be compiled against the 2.5 version for it to work. Any ideas?

markusz commented 8 years ago

@fedeoasi Have you found a solution to the problem? I'm running into the same errors now and would really appreciate a pointer in the right direction

Will this be fixed anytime soon?

fedeoasi commented 8 years ago

@markusz: I have reverted the play version used by my project to 2.4.6, the latest play version that still has play.api.http.ContentTypes.JSON as a method that takes the implicit codec.

I haven't tried it out, but after a quick look at #587 I think it will fix the problem because it upgrades the play dependency to 2.5.1 (in project/plugins.sbt).

sdk451 commented 8 years ago

To make Securesocial java compatible with play 2.5, the BaseUserService methods would need to migrate from F.Promise to java.util.concurrent.CompletableStage (see https://www.playframework.com/documentation/2.5.x/JavaMigration25). This allows java users to implement an override of BaseUserService.

resamsel commented 8 years ago

+1, would love to see this happening!

jaliss commented 7 years ago

I just pushed 3.0-M6 and master with support for 2.5. Sample apps are working fine. Please open new issues if problems arise. Thanks!