SecureSocial Activator Template
This is an application to see how to use Play 2/Scala, Slick and SecureSocial together. It uses Slick 2.0.0 and an in memory H2 database by default.
The blog post is at http://blog.lunatech.com/2013/07/04/play-securesocial-slick
Adding OAuth secret codes
SecureSocial requires keys and secrets to authenticate with OAuth providers. We obviously can't commit those.
To add these secrets to your configuration, copy
secrets.conf and fill in the blanks.
secrets.conf file is included from application.conf, and not from
securesocial.conf, since it also contains the Play application secret.
Configuration of SecureSocial is at http://securesocial.ws/guide/configuration.html
Setup and running
- Generate an application secret in
application.secret(easiest way is to create a new Play app, then copy it)
- Set up your mail server or leave
smtp.mock=trueset in secrets.conf (you will have to look at console for output).
To run with Activator:
Download Activator or
brew install typesafe-activatoror
To run natively:
- Make sure you have Play 2.2.1 installed.
Running with OAuth providers:
Here, we need to use a callback, so we use ngrok to expose the internal service, and don't really need nginx (but it's a good habit to use it).
- Register for any external OAuth services you want to authenticate.
- Put the oauth credentials into
play.pluginsto use the OAuth plugins you registered (a complete list is in
- Download and install nginx (
brew install nginxif you're on a Mac).
- Download and install ngrok from https://ngrok.com -- this allows OAuth callbacks to happen if need be.
- Start the play server (as above).
- Start ngrok with
- Modify the server_name in
conf/nginx.confto point to your ngrok URL (i.e. ei3fawekemf.ngrok.com)
nginx.confto the nginx configuration directory with appropriate file name, i.e. /usr/local/etc/nginx/play.conf
- Start nginx with
nginx -c /usr/local/etc/nginx/play.conf(to stop, use
nginx -s stop).
- Go to the public URL of your application, i.e. http://ei3fawekemf.ngrok.com
- Go to Twitter, enter the callback URL as http://ei3fawekemf.ngrok.com/authenticate/twitter
- Try to login with Twitter, etc.
Note that you can also use HTTPS with ngrok and it will be correctly set up with a valid SSL certificate (which makes SSL testing much easier). You can also examine HTTP requests in ngrok by going to http://localhost:4040/.