Skip to content

Commit

Permalink
all: Play 3.0 (#595)
Browse files Browse the repository at this point in the history
- account for akka -> pekko change.
 - account for com.typesafe.com -> org.playframework groupId change.
 - remove duplicated code for scala compatibility.
 - downgrade guice as Play uses version 6.
  • Loading branch information
ahjohannessen committed Nov 3, 2023
1 parent 2e673d1 commit bfdd408
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 78 deletions.
8 changes: 4 additions & 4 deletions play-pac4j_2.13/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.pac4j</groupId>
<artifactId>play-pac4j-parent</artifactId>
<version>12.0.0-PLAY2.9-SNAPSHOT</version>
<version>12.0.0-PLAY3.0-SNAPSHOT</version>
</parent>

<artifactId>play-pac4j_2.13</artifactId>
Expand All @@ -15,13 +15,13 @@

<dependencies>
<dependency>
<groupId>com.typesafe.play</groupId>
<groupId>org.playframework</groupId>
<artifactId>play_${scala.version}</artifactId>
<version>${play.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.typesafe.play</groupId>
<groupId>org.playframework</groupId>
<artifactId>play-cache_${scala.version}</artifactId>
<version>${play.version}</version>
<scope>provided</scope>
Expand All @@ -34,7 +34,7 @@

<!-- tests -->
<dependency>
<groupId>com.typesafe.play</groupId>
<groupId>org.playframework</groupId>
<artifactId>play-test_${scala.version}</artifactId>
<version>${play.version}</version>
<scope>test</scope>
Expand Down

This file was deleted.

This file was deleted.

8 changes: 4 additions & 4 deletions play-pac4j_3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.pac4j</groupId>
<artifactId>play-pac4j-parent</artifactId>
<version>12.0.0-PLAY2.9-SNAPSHOT</version>
<version>12.0.0-PLAY3.0-SNAPSHOT</version>
</parent>

<artifactId>play-pac4j_3</artifactId>
Expand All @@ -15,13 +15,13 @@

<dependencies>
<dependency>
<groupId>com.typesafe.play</groupId>
<groupId>org.playframework</groupId>
<artifactId>play_${scala.version}</artifactId>
<version>${play.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.typesafe.play</groupId>
<groupId>org.playframework</groupId>
<artifactId>play-cache_${scala.version}</artifactId>
<version>${play.version}</version>
<scope>provided</scope>
Expand All @@ -34,7 +34,7 @@

<!-- tests -->
<dependency>
<groupId>com.typesafe.play</groupId>
<groupId>org.playframework</groupId>
<artifactId>play-test_${scala.version}</artifactId>
<version>${play.version}</version>
<scope>test</scope>
Expand Down
10 changes: 0 additions & 10 deletions play-pac4j_3/src/main/scala/org/pac4j/play/scala/ScalaCompat.scala

This file was deleted.

16 changes: 3 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<artifactId>play-pac4j-parent</artifactId>
<packaging>pom</packaging>
<name>pac4j parent for Play</name>
<version>12.0.0-PLAY2.9-SNAPSHOT</version>
<version>12.0.0-PLAY3.0-SNAPSHOT</version>
<url>https://github.com/pac4j/play-pac4j</url>

<licenses>
Expand All @@ -38,16 +38,6 @@
</developers>

<repositories>
<repository>
<id>typesafe</id>
<name>typesafe-releases</name>
<url>https://repo.typesafe.com/typesafe/releases</url>
</repository>
<repository>
<id>Akka Snapshot Repository</id>
<name>Akka Snapshot Repository</name>
<url>https://repo.akka.io/snapshots/</url>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
Expand All @@ -63,9 +53,9 @@

<properties>
<pac4j.version>6.0.0-RC10-SNAPSHOT</pac4j.version>
<play.version>2.9.0</play.version>
<play.version>3.0.0</play.version>
<java.version>17</java.version>
<guice.version>7.0.0</guice.version>
<guice.version>6.0.0</guice.version>
<shiro.version>1.12.0</shiro.version>
<ehcache.version>2.10.9.2</ehcache.version>
<scalatest.version>3.2.17</scalatest.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.pac4j.play.filters

import akka.stream.Materializer
import org.apache.pekko.stream.Materializer
import org.pac4j.core.adapter.FrameworkAdapter
import org.pac4j.core.config.Config
import org.pac4j.core.util.CommonHelper
Expand All @@ -14,7 +14,7 @@ import play.api.{Configuration, Logger}
import play.mvc

import javax.inject.{Inject, Singleton}
import scala.compat.java8.FutureConverters.CompletionStageOps
import scala.jdk.FutureConverters._
import scala.concurrent.{ExecutionContext, Future}
import scala.util.Failure

Expand Down Expand Up @@ -107,7 +107,7 @@ class SecurityFilter @Inject()(configuration: Configuration, config: Config)
val futureResult: Future[Result] =
securityAction
.call(parameters, rule.clients, rule.authorizers, rule.matchers)
.toScala
.asScala
.flatMap[Result](calculateResult)

futureResult.andThen { case Failure(ex) => log.error("Exception during authentication procedure", ex) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.pac4j.core.profile.{ProfileManager, UserProfile}
import org.pac4j.play.context.PlayFrameworkParameters
import play.api.mvc.RequestHeader

import ScalaCompat.Converters._
import scala.jdk.CollectionConverters._

/**
* This is a helper which can be used to access the current user profile from a twirl template.
Expand Down
6 changes: 3 additions & 3 deletions shared/src/main/scala/org/pac4j/play/scala/Security.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ trait Security[P<:UserProfile] extends BaseController {
case class SecureAction[P <: UserProfile, ContentType, R[X]>:AuthenticatedRequest[P, X]<:Request[X]](
clients: String, authorizers: String, matchers: String, parser: BodyParser[ContentType], config: Config
)(implicit implicitExecutionContext: ExecutionContext) extends ActionBuilder[R, ContentType] {
import ScalaCompat.Converters._
import scala.compat.java8.FutureConverters._
import scala.jdk.CollectionConverters._
import scala.jdk.FutureConverters._
import scala.concurrent.Future
import org.pac4j.play.scala.SecureAction._

Expand Down Expand Up @@ -70,7 +70,7 @@ case class SecureAction[P <: UserProfile, ContentType, R[X]>:AuthenticatedReques
def invokeBlock[A](request: Request[A], block: R[A] => Future[Result]): Future[Result] = {
val secureAction = new org.pac4j.play.java.SecureAction(config)
val parameters = new PlayFrameworkParameters(request)
secureAction.call(parameters, clients, authorizers, matchers).toScala.flatMap[play.api.mvc.Result] {
secureAction.call(parameters, clients, authorizers, matchers).asScala.flatMap[play.api.mvc.Result] {
case holder: PlayWebContextResultHolder =>
val webContext = holder.getPlayWebContext
val sessionStore = config.getSessionStoreFactory.newSessionStore(parameters)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.pac4j.play.filters

import akka.Done
import org.apache.pekko.Done
import play.api

import scala.collection.mutable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.pac4j.play.filters

import akka.actor.ActorSystem
import akka.stream.{ActorMaterializer, Materializer}
import org.apache.pekko.actor.ActorSystem
import org.apache.pekko.stream.{ActorMaterializer, Materializer}
import com.typesafe.config.ConfigFactory
import org.junit.Test
import org.junit.runner.RunWith
Expand Down

0 comments on commit bfdd408

Please sign in to comment.