2017-01-13 13 views
1

Play Scalaプロジェクトのにapplication.confがあります。Play Scalaアプリケーションでの秘密鍵の使用方法

# See http://www.playframework.com/documentation/latest/ApplicationSecret for more details. 
application.secret="........" 

コントローラまたはサービスでの使用方法を教えてください。

application.secretで試してみましたが、エラーvalue secret is not a member of controllers.Applicationが返されます。 play.crypto.secretで、それはプレイがapplication.confキーからのアクセス設定キーにConfigurationオブジェクトを提供 object crypto is not a member of package play

答えて

3

できます。

Configurationオブジェクトを再生する方法は次のとおりです。

class HomeController @Inject() (configuration: play.api.Configuration) extends Controller { 
    def foo = Action { 

    val appSecretString = configuration.underlying.getString("application.secret") 

    //do something with app secret 
    Ok(appSecretString) //app secret should not be exposed, just trying to show it on browser, but do not do this in production 
    } 
} 
+1

ありがとうございました。私は 'secretKey'を持っています –

+0

@PareshNagoreあなたがそれを好きなら受け入れます – pamu