问题:Where to configure session timeout in Spartacus

答案

我假设您使用 Hybris OAuth 服务器的默认身份验证流程(密码流程)。 在这种情况下,会话长度是通过后台的 OAuth 客户端设置来控制的。

但是,要知道会话何时到期,您可以检查令牌有效负载 (AuthStorageService.getToken)。属性之一是到期时间,可用于了解会话何时实际结束。

Marcin is correct. Spartacus is 100% API driven, interacting with Commerce backend by sending request to configured endpoints. These endpoints require an access token to be sent with the request, and this access token needs to be retrieved by following the Client Credentials Flow that is defined by the OAuth specification.

As long as you log in successfully, you can find access token issued by Commerce backend in Chrome dev tools, application tab -> Local storage as highlighted below:

the field expires_at stores the value of exact date and time when token will be expired.

you can use the code below in console to convert it to human readable string:

new Date(1627660784476).toGMTString();

You can control the token time-to-live value via configuration in backoffice by property: oauth2.accessTokenValiditySeconds

See document for detail:

https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2105/en-US/3d3ea6a4d5fa486aa324ce278fa2afc3.html?q=oauth2.accessTokenValiditySeconds

if you need to code in Spartacus to know when the token will be expired, inject AuthStorageService in your app.module.ts, and then access expires_at property of result returned by getToken method.

export class AppModule {constructor(private authService: AuthStorageService){const token: Observable<AuthToken> = this.authService.getToken();token.subscribe((token) => console.log('expire at:' , token.expires_at));}
}

更多Jerry的原创文章,尽在:“汪子熙”:

SAP Spartacus 会使用 Session timeout 吗?相关推荐

  1. SAP Spartacus SSR模式启用失败的一个原因:SSR rendering exceeded timeout

    https://github.com/SAP/spartacus/issues/10638 错误消息:SSR rendering exceeded timeout, fallbacking to CS ...

  2. SAP Spartacus Session affinity

    参见这个讨论. 后端运行在多个 pods/节点时,当子序列请求过早进入时,后端将无法跨集群发送缓存失效请求.此外,如果多个请求分散在多个节点上,则会消耗延迟和不必要的资源. 对于单个客户端,Spart ...

  3. SAP Spartacus 的会话管理 Session Management

    官网 从一开始,Spartacus 就包含了客户端身份验证和用户身份验证. 尽管这对于 Web 应用程序来说并不常见,但对于 Spartacus 来说是必须的,因为后者需要使用 OCC API. 客户 ...

  4. 如何运行 SAP Spartacus cypress 端到端测试

    首先在本地启动 Spartacus instance, 比如执行 b2c.bat: 进入文件夹:projects/storefrontapp-e2e yarn install: 然后 yarn cy: ...

  5. 给基于SAP Spartacus 3.4.1 版本的 Storefront 添加对服务器端渲染的支持

    这个 Storefront 的本地地址:C:\Code\SPA\spa3.1\mystore31 基于的 SAP Spartacus 版本:大于 3.1.3,小于 4.0: 查看 package-lo ...

  6. SAP Spartacus 和 SmartEdit 集成的一些 bug

    我正在尝试使用 spartacus 和 smartedit,特别是我有兴趣查看选择分阶段产品目录版本的预览模式是否工作正常,但显然不是-我看不到对我在 stage 版本上做的属性,如果我查看浏览器发送 ...

  7. SAP Spartacus 服务器端渲染处理内存泄漏的准则

    开启服务器端渲染(SSR) 的 SAP Spartacus 实例,运行在 CCV2 Pod 里,当下列情况出现时,可能会造成 pod 的重启: resource allocation for SSR ...

  8. SAP Spartacus 用户认证的实现

    文章目录 UserAuthModule Authentication Flow AuthService Storing Tokens and User Identifiers 用户认证的典型流程和包含 ...

  9. SAP Spartacus i18n 的文本,和翻译相关的话题:internationalization

    存储在这个config对象里: 英文版的资源源代码如下: {"fallbackLang":"en","debug":false," ...

最新文章

  1. 用结构体实现一个电话本
  2. ArrayList 源码阅读记录
  3. windows server2008R2 64位 配置 mysql-8.0.15-winx64
  4. mina android 服务器,MINA框架----------android客户端与服务器端
  5. php uncaught thrown,PHP异常详解
  6. tee 和 ree分别是什么意思?
  7. Linux脚本中$#、$0、$1、$@、$*、$$、$?
  8. BFS(广度优先搜索)
  9. 主存和cache每一块相等_CPU中的Cache实现原理
  10. 我的代码第一次运行时的样子
  11. android hook 模拟点击_手把手讲解 Android Hook-实现无清单启动Activity
  12. 【转】HeadFirst 组合模式+迭代器错误原因以及解决代码
  13. 评论安装_评论送|机电安装监理质量控制要点130页
  14. 编译报错:/usr/bin/ld: /usr/local/lib/libgflags.a(gflags.cc.o): relocation R_X86_64_32S against `.rodata‘
  15. mysql连接被拒绝 密码也对_MYSQL密码正确,却依然显示拒绝连接
  16. USACO-Section 3.2 Feed Ratios(枚举)
  17. Photoshop辅助线和标尺的技巧
  18. 给初学者:用VB写外挂 ———— 序言
  19. 数据库设计实例 教务管理系统
  20. 2.4G与5GWiFi频段的区别

热门文章

  1. linux kill命令详解
  2. 在WordPress中添加简书风格的连载目录和文章导航
  3. Flutter:尝试撸一个具有惯性跟阻力的旋转控件或用传感器控制其旋转
  4. 一个表单验证引发的深思!!!
  5. iOS Block 知识点拾遗
  6. 课后作业之字符串加密
  7. 升级Python后yum不可用的解决方案
  8. indexOf和binarySearch的对比
  9. 润乾报表实现无数据源的规则报表及改进
  10. spring简单入门,入门案列的执行流程,图例