Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12627 from playframework/mergify/bp/2.9.x/pr-12626
- Loading branch information
Showing
7 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...lugin/src/sbt-test/play-sbt-plugin/jjwt-compatibility/app/controllers/HomeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package controllers; | ||
|
||
import play.mvc.*; | ||
|
||
public class HomeController extends Controller { | ||
|
||
public Result index(Http.Request req) { | ||
return ok("hello_world_" + req.session().get("foo").orElse("empty")) // This line tests session cookie parsing | ||
.addingToSession(req, "one", "two"); // This lines tests session cookie creation | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
dev-mode/sbt-plugin/src/sbt-test/play-sbt-plugin/jjwt-compatibility/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com> | ||
|
||
// See: | ||
// https://github.com/playframework/playframework/pull/12474 | ||
// https://github.com/playframework/playframework/pull/12624 | ||
val jjwtVersion = "0.12.5" | ||
val jjwts = Seq( | ||
"io.jsonwebtoken" % "jjwt-api", | ||
"io.jsonwebtoken" % "jjwt-impl" | ||
).map(_ % jjwtVersion) ++ Seq( | ||
("io.jsonwebtoken" % "jjwt-jackson" % jjwtVersion).excludeAll(ExclusionRule("com.fasterxml.jackson.core")) | ||
) | ||
|
||
lazy val root = (project in file(".")) | ||
.enablePlugins(PlayJava) | ||
.settings( | ||
name := "jjwt-compatibility", | ||
version := "1.0-SNAPSHOT", | ||
scalaVersion := ScriptedTools.scalaVersionFromJavaProperties(), | ||
updateOptions := updateOptions.value.withLatestSnapshots(false), | ||
update / evictionWarningOptions ~= (_.withWarnTransitiveEvictions(false).withWarnDirectEvictions(false)), | ||
PlayKeys.playInteractionMode := play.sbt.StaticPlayNonBlockingInteractionMode, | ||
libraryDependencies += guice, | ||
libraryDependencies ++= jjwts, | ||
InputKey[Unit]("makeRequestWithSessionCookie") := { | ||
val args = Def.spaceDelimited("<path> <status> <cookie> <words> ...").parsed | ||
val path :: status :: cookie :: assertions = args | ||
ScriptedTools.verifyResourceContains(path, status.toInt, assertions, "Cookie" -> s"PLAY_SESSION=$cookie") | ||
}, | ||
) | ||
|
4 changes: 4 additions & 0 deletions
4
dev-mode/sbt-plugin/src/sbt-test/play-sbt-plugin/jjwt-compatibility/conf/application.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This is the main configuration file for the application. | ||
# https://www.playframework.com/documentation/latest/ConfigFile | ||
|
||
play.http.secret.key="<Lt>v_F:bfRC=/YN8riEbEUAM1C:wT^1a92ywJ8>PI6Vb5c8Brq?b@y1HgzU2qgA" |
50 changes: 50 additions & 0 deletions
50
dev-mode/sbt-plugin/src/sbt-test/play-sbt-plugin/jjwt-compatibility/conf/logback.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<!-- https://www.playframework.com/documentation/latest/SettingsLogger --> | ||
|
||
<!DOCTYPE configuration> | ||
|
||
<configuration> | ||
<import class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"/> | ||
<import class="ch.qos.logback.classic.AsyncAppender"/> | ||
<import class="ch.qos.logback.core.FileAppender"/> | ||
<import class="ch.qos.logback.core.ConsoleAppender"/> | ||
|
||
<appender name="FILE" class="FileAppender"> | ||
<file>${application.home:-.}/logs/application.log</file> | ||
<encoder class="PatternLayoutEncoder"> | ||
<charset>UTF-8</charset> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="STDOUT" class="ConsoleAppender"> | ||
<!-- | ||
On Windows, enabling Jansi is recommended to benefit from color code interpretation on DOS command prompts, | ||
which otherwise risk being sent ANSI escape sequences that they cannot interpret. | ||
See https://logback.qos.ch/manual/layouts.html#coloring | ||
--> | ||
<!-- <withJansi>true</withJansi> --> | ||
<encoder class="PatternLayoutEncoder"> | ||
<charset>UTF-8</charset> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss} %highlight(%-5level) %cyan(%logger{36}) %magenta(%X{pekkoSource}) %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<appender name="ASYNCFILE" class="AsyncAppender"> | ||
<appender-ref ref="FILE"/> | ||
</appender> | ||
|
||
<appender name="ASYNCSTDOUT" class="AsyncAppender"> | ||
<appender-ref ref="STDOUT"/> | ||
</appender> | ||
|
||
<logger name="play" level="INFO"/> | ||
<logger name="application" level="DEBUG"/> | ||
|
||
<root level="WARN"> | ||
<appender-ref ref="ASYNCFILE"/> | ||
<appender-ref ref="ASYNCSTDOUT"/> | ||
</root> | ||
|
||
</configuration> |
3 changes: 3 additions & 0 deletions
3
dev-mode/sbt-plugin/src/sbt-test/play-sbt-plugin/jjwt-compatibility/conf/routes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com> | ||
|
||
GET / controllers.HomeController.index(request: Request) |
5 changes: 5 additions & 0 deletions
5
dev-mode/sbt-plugin/src/sbt-test/play-sbt-plugin/jjwt-compatibility/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (C) from 2022 The Play Framework Contributors <https://github.com/playframework>, 2011-2021 Lightbend Inc. <https://www.lightbend.com> | ||
|
||
updateOptions := updateOptions.value.withLatestSnapshots(false) | ||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % sys.props("project.version")) | ||
addSbtPlugin("com.typesafe.play" % "sbt-scripted-tools" % sys.props("project.version")) |
8 changes: 8 additions & 0 deletions
8
dev-mode/sbt-plugin/src/sbt-test/play-sbt-plugin/jjwt-compatibility/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
> run | ||
# First send a request with an invalid session cookie value: | ||
> makeRequestWithSessionCookie / 200 foo hello_world_empty | ||
# Next send a request with a valid session cookie value but it was encoded with a different secret: | ||
> makeRequestWithSessionCookie / 200 eyJhbGciOiJIUzI1MiJ9.eyJkYXRhIjp7ImNzcmZUb2tlbiI7IjVhMTIzMDY4YTE3NGVkMWZlMDkzMWVjZThmMmVkZDE5NWJiYjM2MCAtMTcxNTE1NDc0NDc2My0wMmNlMWQ2MDk2ZDgwYmJkYjBiZDhmOTgiLCJmb28iOiJiYXIifSwibmJmIjoxNzE1MTYwNTU3LCJpYXQiOjE3MTUxNjA1NTd9.N0LWvuPzslvbUsY8v19XXwW1KXKsW-pQY_zctWLgSkU hello_world_empty | ||
# Now send a request with a valid session cookie, encoded with the secret from application.conf, the session contains the key/value foo->bar | ||
> makeRequestWithSessionCookie / 200 eyJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7ImZvbyI6ImJhciJ9LCJuYmYiOjE3MTUxNzE3NjcsImlhdCI6MTcxNTE3MTc2N30.cA0x9_rsyctV1qiMvAydsJPMyrLah4qu0TaSmiVN0nQ hello_world_bar | ||
> playStop |