1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ASP.NET Core アプリの Cookie に secure フラグを立てる

Last updated at Posted at 2020-04-21

ASP.NET Core アプリの Cookie に secure フラグを立てる

# 以下の記事が書かれた時の版数は .NET Core 3.1 (3.1.201), ASP.NET Core 3.1 (3.1.3) となります.

セキュリティ監査とかで secure フラグを立てないといけない人向け.

Startup.cs を開き、先頭に using Microsoft.AspNetCore.Http; を追加. 次に ConfigureServices メソッドに

services.Configure<CookiePolicyOptions>(options =>
{
    options.Secure = CookieSecurePolicy.Always;
});

を追加する. 最後に Configure メソッドに

app.UseCookiePolicy();

を追加する. どの行に設定するのがベストなのかはわからないが、app.UseStaticFiles(); の次の行において動作することだけは確認した.

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?