11# Pan Domain Authentication
2+
23[ ![ Maven Central] ( https://maven-badges.herokuapp.com/maven-central/com.gu/pan-domain-auth-core_2.11/badge.svg )] ( https://maven-badges.herokuapp.com/maven-central/com.gu/pan-domain-auth-core_2.11 )
34
45Pan domain authentication provides distributed authentication for multiple webapps running in the same domain. Each
@@ -43,8 +44,8 @@ The `pan-domain-auth-core` library provides the core utilities to load the domai
4344check if the user has mutlifactor auth turned on (see below). Note this does not include the Google oath dance code or cookie setting
4445as these vary based on web framework being used by implementing apps.
4546
46- The ` pan-domain-auth-play ` libraries ( ` 2-4-0 ` and ` 2-5 ` ) provide an implementation for play apps. There is an auth action that can be applied to the
47- endpoints in you appliciation that will do checking and setting of the cookie and will give you the Google authentication mechanism
47+ The ` pan-domain-auth-play_2-6 ` library provide an implementation for play apps. There is an auth action that can be applied to the
48+ endpoints in your application that will do checking and setting of the cookie and will give you the Google authentication mechanism
4849and callback. This is the only framework specific implementation currently (due to play being the framework predominantly used at the
4950guardian), this can be used as reference if you need to implement another framework implementation. This library is for applications
5051that need to be able to issue and verify logins which is likely to include user-facing applications.
@@ -54,12 +55,12 @@ Additionally the nginx directory provides an example of how to set up an nginx c
5455apps locally as if they were all on the same domain (also useful for testing)
5556
5657The ` pan-domain-auth-verification ` , ` pan-domain-auth-core ` and ` pan-domain-auth-play ` libraries are available on maven central
57- cross compiled for scala 2.10.4 and 2.11.1 . to include them via sbt:
58+ cross compiled for scala 2.11.12 and 2.12.4 . to include them via sbt:
5859
5960### To verify logins
6061
6162```
62- "com.gu" %% "pan-domain-auth-verification" % "0.3 .0"
63+ "com.gu" %% "pan-domain-auth-verification" % "0.6 .0"
6364```
6465
6566To verify a login, you'll need to read the user's cookie value and verify its integrity. This is done using the
@@ -118,13 +119,13 @@ provided helper `PublicSettings.getPublicKey(domain)` helper function.
118119### If your application needs to issue logins
119120
120121```
121- "com.gu" %% "pan-domain-auth-core" % "0.3 .0"
122+ "com.gu" %% "pan-domain-auth-core" % "0.6 .0"
122123```
123124
124125or
125126
126127```
127- "com.gu" %% "pan-domain-auth-play_2-5 " % "0.3 .0"
128+ "com.gu" %% "pan-domain-auth-play_2-6 " % "0.6 .0"
128129```
129130
130131In both cases you will need to set up a few things, see ` Requirements ` below.
@@ -241,9 +242,13 @@ package controllers
241242
242243import com .gu .pandomainauth .action .AuthActions
243244import com .gu .pandomainauth .model .AuthenticatedUser
245+ import play .api .mvc .ControllerComponents
246+ import play .api .Configuration
244247
245248trait PanDomainAuthActions extends AuthActions {
246249
250+ def config : Configuration
251+
247252 override def validateUser (authedUser : AuthenticatedUser ): Boolean = {
248253 (authedUser.user.email endsWith (" @guardian.co.uk" )) && authedUser.multiFactor
249254 }
@@ -267,7 +272,8 @@ package controllers
267272
268273import play .api .mvc ._
269274import scala .concurrent .Future
270- import scala .concurrent .ExecutionContext .Implicits .global
275+ import play .api .Configuration
276+ import akka .actor .ActorSystem
271277
272278class Login (
273279 override val controllerComponents : ControllerComponents ,
@@ -291,9 +297,10 @@ Add the `AuthAction` or `ApiAuthAction` to any endpoints you with to require an
291297``` scala
292298package controllers
293299
294- import scala .concurrent .ExecutionContext .Implicits .global
295300import lib ._
296301import play .api .mvc ._
302+ import play .api .Configuration
303+ import akka .actor .ActorSystem
297304
298305
299306class Application (
@@ -302,6 +309,11 @@ class Application(
302309 override val wsClient : WSClient ,
303310 override val panDomainSettings : PanDomainAuthSettingsRefresher
304311) extends AbstractController (controllerComponents) with PanDomainAuthActions {
312+ class Application (
313+ override val controllerComponents : ControllerComponents ,
314+ override val config : Configuration ,
315+ override val actorSystem : ActorSystem
316+ ) extends AbstractController (controllerComponents) with PanDomainAuthActions {
305317
306318 def loginStatus = AuthAction { request =>
307319 val user = request.user
0 commit comments