Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@ on:
- main

jobs:
sbt-build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: coursier/cache-action@v6
- uses: olafurpg/setup-scala@v11
- name: Checkout
uses: actions/checkout@v3
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: adopt@1.11
distribution: corretto
java-version: 11
cache: sbt
- name: Build and Test
run: sbt ++test
run: sbt -v +test +publishLocal
- name: Check that example app compiles
working-directory: ./example/webapp
run: sbt -v +test
- name: Test Summary
uses: test-summary/action@v2
with:
paths: "test-results/**/TEST-*.xml"
if: always()
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ target/
.idea/
*.log
.bsp/

/test-results/
.DS_Store
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def projectWithPlayVersion(playVersion: PlayVersion) =
crossScalaVersions := Seq(scalaVersion.value) ++ (if (playVersion.supportsScala3) Seq("3.3.1") else Seq.empty),
scalacOptions ++= Seq("-feature", "-deprecation"),
Compile / unmanagedSourceDirectories += baseDirectory.value / playVersion.pekkoOrAkkaSrcFolder,
Test / testOptions +=
Tests.Argument(TestFrameworks.ScalaTest, "-u", s"test-results/scala-${scalaVersion.value}", "-o"),

libraryDependencies ++= Seq(
"com.gu.play-secret-rotation" %% "core" % "0.40",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AppComponents(context: ApplicationLoader.Context)
clientId = configuration.get[String]("your.clientId.config.path"),
clientSecret = configuration.get[String]("your.clientSecret.config.path"),
redirectUrl = configuration.get[String]("your.redirectUrl.config.path"),
domain = configuration.get[String]("your.apps-domain.config.path"),
domains = List(configuration.get[String]("your.apps-domain.config.path")),
antiForgeryChecker = AntiForgeryChecker.borrowSettingsFromPlay(httpConfiguration)
)

Expand All @@ -31,7 +31,7 @@ class AppComponents(context: ApplicationLoader.Context)
val googleServiceAccount = GoogleServiceAccount(googleCredential.getServiceAccountId, googleCredential.getServiceAccountPrivateKey, "service.account@mydomain.com")
val googleGroupChecker = new GoogleGroupChecker(googleServiceAccount)

val authAction = new AuthAction[AnyContent](googleAuthConfig, routes.Login.loginAction(), controllerComponents.parsers.default)(executionContext)
val authAction = new AuthAction[AnyContent](googleAuthConfig, routes.Login.loginAction, controllerComponents.parsers.default)(executionContext)

val login = new Login(requiredGoogleGroups, googleAuthConfig, googleGroupChecker, wsClient, controllerComponents)(executionContext)
val appController = new Application(authAction, requiredGoogleGroups, googleAuthConfig, googleGroupChecker, controllerComponents)(executionContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.gu.googleauth
import com.gu.googleauth.{AuthAction, Filters, GoogleAuthConfig, GoogleGroupChecker}
import play.api.mvc.Security.AuthenticatedRequest
import play.api.mvc._
import com.google.api.client.auth.oauth2.GoogleCredential

import scala.concurrent.ExecutionContext

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class Login(requiredGoogleGroups: Set[String], val authConfig: GoogleAuthConfig,
}

def logout = Action { implicit request =>
Redirect(routes.Application.index()).withNewSession
Redirect(routes.Application.index).withNewSession
}

override val failureRedirectTarget: Call = routes.Login.login()
override val defaultRedirectTarget: Call = routes.Application.authenticated()
override val failureRedirectTarget: Call = routes.Login.login
override val defaultRedirectTarget: Call = routes.Application.authenticated
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1>Authorised</h1>
<p><img class="avatar" src="@avatarUrl" alt="@request.user.firstName" /></p>
}
<p>The expiry time is @{Instant.ofEpochSecond(request.user.exp)}</p>
<p>You can go to the <a href="@routes.Login.login()">login page</a>
or <a href="@routes.Login.logout()">logout</a>.</p>
<p>You can go to the <a href="@routes.Login.login">login page</a>
or <a href="@routes.Login.logout">logout</a>.</p>
</body>
</html>
12 changes: 12 additions & 0 deletions example/webapp/app/views/index.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@(request: Request[AnyContent], error: Option[String] = None)

<html>
<head><title>Home</title></head>
<body>
<h1>Home page</h1>
<p>This is the home page of the example application.</p>
<p>You can go to the <a href="@routes.Login.login">login page</a>,
a <a href="@routes.Application.authenticated">page that requires authentication</a>,
or <a href="@routes.Login.logout">logout</a>.</p>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ <h1>Login Page</h1>
@error.map { message =>
<p>The error was: @message</p>
}
<form action="@routes.Login.loginAction()" method="get">
<form action="@routes.Login.loginAction" method="get">
<input value="Log In" type="submit">
</form>
<p>You can also go to a <a href="@routes.Application.authenticated()">page that requires authentication</a>
or <a href="@routes.Login.logout()">logout</a>.</p>
<p>You can also go to a <a href="@routes.Application.authenticated">page that requires authentication</a>
or <a href="@routes.Login.logout">logout</a>.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name := "play-googleauth-example"

scalaVersion := "2.12.16"
scalaVersion := "2.13.12"

libraryDependencies ++= Seq(
"com.gu" %% "play-googleauth" % version.value,
"com.gu.play-googleauth" %% "play-v30" % version.value,
ws
)

Expand Down
1 change: 1 addition & 0 deletions example/webapp/project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.9.7
2 changes: 2 additions & 0 deletions example/webapp/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Use the Play sbt plugin for Play projects
addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.0")
File renamed without changes.
1 change: 1 addition & 0 deletions example/webapp/version.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ThisBuild / version := "2.3.1-SNAPSHOT"
12 changes: 0 additions & 12 deletions play-v27/src/sbt-test/example/webapp/app/views/index.scala.html

This file was deleted.

This file was deleted.

5 changes: 0 additions & 5 deletions play-v27/src/sbt-test/example/webapp/project/plugins.sbt

This file was deleted.

1 change: 0 additions & 1 deletion play-v27/src/sbt-test/example/webapp/version.sbt

This file was deleted.