[scala 2.5.0] Crypto deprecation - play.crypto.secret not found

358 views
Skip to first unread message

Andy Czerwonka

unread,
Mar 15, 2016, 12:30:22 PM3/15/16
to play-framework
I've taken on a migration to 2.5.0, and while I read that Crypto is deprecated, I'd argue it's now broken. I managed to move over most of my global state (GlobalSettings, Configuration, etc) to the DI framework. Now when I run my application, I do get warnings that Crypto is deprecated so I was going to start on that. Prior to and change in that area, I now have a problem in that 2.5.0 can't find 'play.crypto.secret', which is clearly there in the application.conf.

[error] - akka.actor.OneForOneStrategy - No configuration setting found for key 'play.crypto.secret'
com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'play.crypto.secret'
at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:152)
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170)
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:176)
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:176)
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:193)
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:198)
at com.typesafe.config.impl.SimpleConfig.getIsNull(SimpleConfig.java:208)
at play.api.ConfigLoader$$anon$4.load(Configuration.scala:1075)
at play.api.ConfigLoader$$anon$4.load(Configuration.scala:1073)
at play.api.PlayConfig.get(Configuration.scala:916)
at play.api.PlayConfig$$anonfun$getDeprecated$2.apply(Configuration.scala:960)
at scala.Option.getOrElse(Option.scala:121)
at play.api.PlayConfig.getDeprecated(Configuration.scala:959)
at play.api.libs.crypto.CryptoConfigParser.get$lzycompute(Crypto.scala:494)
at play.api.libs.crypto.CryptoConfigParser.get(Crypto.scala:465)
at play.api.libs.Crypto$$anonfun$crypto$1.apply(Crypto.scala:58)
at play.api.libs.Crypto$$anonfun$crypto$1.apply(Crypto.scala:55)
at scala.Option.fold(Option.scala:158)
at play.api.libs.Crypto$.crypto(Crypto.scala:63)
at play.api.libs.Crypto$.decryptAES(Crypto.scala:86)
at models.Site$.findByApiKey(Site.scala:146)

Andy Czerwonka

unread,
Mar 25, 2016, 12:04:24 PM3/25/16
to play-framework
If anyone is curious, I put a small project together to demonstrate the issue.

Greg Methvin

unread,
Mar 25, 2016, 4:18:02 PM3/25/16
to play-framework
Hi Andy,

The problem is that the application isn't started yet at that point. Actually the specific exception you're getting is misleading. We really should just throw an exception if there is no application in scope, but instead we try to create a Crypto instance, which fails because there's no configuration. So technically there is a bug but even if we fixed it it wouldn't work.

I would suggest creating the actor with dependency injection, or simply passing a Crypto instance to that actor when you create it. It would also probably work to set an initial delay in the scheduler to make sure the application is initialized, but that is not really a robust solution.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/a027cdfa-3958-4c94-a379-469a59c30575%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Senior Software Engineer

Reply all
Reply to author
Forward
0 new messages