Playframework authentication && user management sample using: Scala, Silhouette, Vuejs
The goal of this project is to have starter project that covers basic authentication && user management functionality.
This is a Scala Playframework application that utilizes Silhouette as authentication library and Vuejs for frontend.
See Demo on Heroku. Loading can take a while because it uses Heroku free dyno which is turned on/off every time
if there is no activity for some time.
Although this project uses VueJs on frontend it’s easy to port to Angular/ReactJs/etc because frontend part it fully
decoupled. Just replace code in vue
directory for anything you like and it will work.
On running application in prod
mode, all frontend sources are compiled and moved to public
directory where PlayFramework treats them as static assets.
On running application in dev
mode, all frontend sources are proxied from Webpack server by PlayFramework, so hot reloading and other stuff work without magic.
Make sure you have sbt
and npm
installed
Create devEnv.conf
file in <project_root>/conf
directory and specify there your keys. See example below
play.filters.headers.contentSecurityPolicy = "*"
silhouette {
csrfStateItemHandler.signer.key="..."
oauth1TokenSecretProvider.signer.key="..."
oauth1TokenSecretProvider.crypter.key="..."
authenticator.sharedSecret="..."
}
sendgrid.api.key = "..."
play.crypto.secret="..."
recaptcha.secretKey = "..."
Run backend sbt run
Make sure you have RECAPTCHA_SITEKEY environment variable or export it export RECAPTCHA_SITEKEY="..."
Install frontend dependencies and run frontend cd vui && npm install && npm run serve
Open your http://localhost:9000/ in your browser. That’s PlayFramework bakend server which proxies all frontend assets so
Hot
npm run build
sbt compile stage
(frontend resources will be copied)