小编Pet*_*ter的帖子

一段时间后,身份验证 cookie 在反应 SPA 中消失

我们有一个用 React 编写的 SPA 和用于托管的 ASP.net 核心。

为了验证应用程序,我们使用 IdentityServer4 并使用 cookie。客户端根据示例配置,这里描述:https : //github.com/IdentityServer/IdentityServer4/tree/main/samples/Quickstarts/4_JavaScriptClient/src

为了验证用户,一切正常。它将被重定向到登录页面。登录后,重定向到 SPA 就完成了。身份验证 cookie 按预期设置:

  • HttpOnly = 真
  • 安全 = 真
  • SameSite = 无
  • Expires / Max-age = 登录后一周

出于身份验证的原因,cookie 也用于其他 MVC(.net core 和 MVC 5)应用程序。在 SPA 中,我们还使用 SignalR,它需要 cookie 进行身份验证。

我们的问题:

在浏览器中闲置大约 30 分钟并进行刷新或导航后,身份验证 cookie(仅此而已,其他仍然存在)将自动从浏览器中消失。然后用户必须再次登录。为什么这会与 SPA 一起发生?

代码

完整代码可以在github中找到

客户

片段 UserService.ts

const openIdConnectConfig: UserManagerSettings = {
  authority: baseUrls.person,
  client_id: "js",
  redirect_uri: joinUrl(baseUrls.spa, "signincallback"),
  response_type: "code",
  scope: "openid offline_access profile Person.Api Translation.Api",
  post_logout_redirect_uri: …
Run Code Online (Sandbox Code Playgroud)

cookies reactjs openid-connect asp.net-core identityserver4

12
推荐指数
1
解决办法
1202
查看次数

Windows 上的 sh shell 脚本导致错误:/dev/tty: 没有这样的设备或地址

在 Windows 上,我想在 git commit-msg 中运行以下脚本:

MSG="$1"
if ! grep -s -qE "#[0-9]" "$MSG";then
    exec < /dev/tty
    cat "$MSG"
    echo "Your commit message does not contain a reference to a work item. Continue? [y/n]"
    read -s -n 1 sure
    if [[ $sure == "y" ]]; then
        exit 0
    else
        echo "Aborting commit..."
        exit 1
    fi
fi
Run Code Online (Sandbox Code Playgroud)

当我使用 Git 扩展时它运行良好。

但是,当我想直接从 Visual Studio(团队资源管理器或 Git 更改)提交时,会出现以下消息的错误:

Your git-hook, '.git/hooks/commit-msg' (line 23) is not supported, likely because it expects interactive console support./r/nSee your …
Run Code Online (Sandbox Code Playgroud)

git sh githooks

5
推荐指数
1
解决办法
3479
查看次数

Azure 构建管道:dotnet 构建失败:FileNotFoundException:无法加载文件或程序集“TechTalk.SpecFlow,版本 = 3.1.0.0

使用任务dotnet build的构建管道开始失败,因为 Build Engine 版本最近从 16.4.0+ 更改为 16.5.0+。

nuget 包SpecFlow依赖于库TechTalk.SpecFlow

异常看起来像:

C:\Users\VssAdministrator\.nuget\packages\specflow.tools.msbuild.generation\3.1.89\build\SpecFlow.Tools.MsBuild.Generation.targets(93,5): Error MSB4018: The "GenerateFeatureFileCodeBehindTask" task failed unexpectedly.
    System.IO.FileNotFoundException: Could not load file or assembly 'TechTalk.SpecFlow, Version=3.1.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41'. The system cannot find the file specified.
Run Code Online (Sandbox Code Playgroud)

我所做的调查(没有帮助):

  • 将 SpecFlow 版本升级到最新版本
  • 使用 3.1 将 SpecFlow 的版本降级到第一个
  • 将程序集TechTalk.SpecFlow显式添加到项目中
  • 使用自托管构建代理
    • 在文件系统中TechTalk.SpecFlow在 3.1.0.0 版本中可用

有任何想法吗?

asp.net specflow azure-devops

4
推荐指数
1
解决办法
769
查看次数