0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SameSite属性を付与するwarをmavenで作成(Tomcat用)

Posted at

はじめに

SameSite属性の付与方法についてはいくつか方法があり、

  • Apacheの設定による方法
  • ソース埋め込みによる方法
  • Tomcat等アプリケーションサーバ側の設定による方法
  • warファイルに設定を組み込む方法

等がありますが、一番最後のwarファイルに組み込む方法について紹介します。

設定方法

ここでは、mavenプロジェクトであることを前提とします。
src/main/webapps/META-INF/context.xmlを作成します。

src/main/webapps/META-INF/context.xml
<Context>
    <!-- 設定値は"strict","lax","none","unset"のいずれか -->
    <CookieProcessor sameSiteCookies="strict" />
</Context>

warファイルに上記ファイルを含める方法

上記ファイルをwarファイル中の/META-INF/フォルダ配下に含める必要があります。

いつも通りにmvn packagesコマンドを実行するだけではwarファイルに対象ファイルを含むことはできないので、pom.xmlファイルに設定を追加する必要があります。

pom.xml
...
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <!-- バージョンは適宜設定 -->
  <version>x.x</version>
  <configuration>
    <containerConfigXML>src/main/webapp/META-INF/context.xml</containerConfigXML>
  </configuration>
</plugin>
...

以上で、SameSite属性を付与するwar(Tomcat用)を作成することができます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?