3

我正在使用 Apache Shiro 开发基于 EJB 的 Web 服务来进行用户访问管理。我将新发布的 Apache Shiro 1.5.0 版添加到我的 Maven 项目中,以利用新的sameSitecookie 属性。然后我将sameSite属性的配置添加到我的shiro.ini文件中:

sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager
# configure properties (like session timeout) here if desired
sessionManager.sessionIdCookieEnabled = true
sessionManager.sessionIdCookie.path = /
sessionManager.sessionIdCookie.httpOnly = true
sessionManager.sessionIdCookie.secure = ${MY_WILDFLY_SHIRO_COOKIE_SECURE}
sessionManager.sessionIdCookie.name = mycookie
sessionManager.sessionIdCookie.domain = ${MY_WILDFLY_SHIRO_COOKIE_DOMAIN}
sessionManager.sessionIdCookie.sameSite = NONE

但是,如果我尝试编译它(使用 Maven),我会收到以下错误消息:

[ERROR] Failed to execute goal org.wildfly.plugins:wildfly-maven-plugin:2.0.1.Final:deploy (default-cli) on project api: Failed to execute goal deploy: {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-1" => {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"api.war\".undertow-deployment" => "java.lang.RuntimeException: org.apache.shiro.config.ConfigurationException: Unable to set property 'sessionIdCookie.sameSite' with value [NONE] on object of type org.apache.shiro.web.session.mgt.DefaultWebSessionManager.  If 'NONE' is a reference to another (previously defined) object, prefix it with '$' to indicate that the referenced object should be used as the actual value.  For example, $NONE
[ERROR]     Caused by: java.lang.RuntimeException: org.apache.shiro.config.ConfigurationException: Unable to set property 'sessionIdCookie.sameSite' with value [NONE] on object of type org.apache.shiro.web.session.mgt.DefaultWebSessionManager.  If 'NONE' is a reference to another (previously defined) object, prefix it with '$' to indicate that the referenced object should be used as the actual value.  For example, $NONE
[ERROR]     Caused by: org.apache.shiro.config.ConfigurationException: Unable to set property 'sessionIdCookie.sameSite' with value [NONE] on object of type org.apache.shiro.web.session.mgt.DefaultWebSessionManager.  If 'NONE' is a reference to another (previously defined) object, prefix it with '$' to indicate that the referenced object should be used as the actual value.  For example, $NONE
[ERROR]     Caused by: org.apache.commons.beanutils.ConversionException: Default conversion to org.apache.shiro.web.servlet.Cookie$SameSiteOptions failed.
[ERROR]     Caused by: org.apache.commons.beanutils.ConversionException: Can't convert value '' to type class org.apache.shiro.web.servlet.Cookie$SameSiteOptions"}}}}

我试过的:

  • 在 POM 文件中手动导入最新版本的 Apache BeanUtils
  • NONE用单引号和双引号写
  • 使用完全限定名称 org.apache.shiro.web.servlet.Cookie.SameSiteOptions.NONE而不仅仅是NONE

如何配置shiro.ini文件以使 Shiro 的会话 cookie 的sameSite属性设置为NONE

4

1 回答 1

1

我可以重现你的错误,我有一个修复它。

Jira 在这里:

https://issues.apache.org/jira/browse/SHIRO-739

问候,

于 2020-01-28T21:04:56.420 回答