当用户的角色改变时,HTTP BasicAuthentication不会立即意识到。我该怎么办?

StackOverflow https://stackoverflow.com/questions/4593736

  •  15-10-2019
  •  | 
  •  

我已经在JBOSSAS 5.1 GA上部署了一个Web服务。要使用HTTP基本身份验证,请按照以下方式注释SBC类:

    @Stateless
    @SecurityDomain(value = "MyWSSecurity")
    @RolesAllowed(value = "WebserviceUser")
    @WebContext(contextRoot="/MyWS", urlPattern="/*", authMethod="BASIC", transportGuarantee="NONE", secureWSDLAccess=true)
    @WebService(endpointInterface = "MyWS")
    public class MyWSImpl implements MyWS {

      public String doSomething() {
        return "something";
      }
    }

通常,这可以正常工作。但是以下Szenario困扰了我。

在角色Web服务器中处于角色的用户致电该服务。

Web服务的角色现在已从用户中删除。

问题:他仍然可以打电话给服务。

我想这是发生的,因为用户凭据和角色存储在服务器端的HTTPSESPENT对象中。服务器重新启动后,拨打服务的用户被拒绝。

我该怎么办?

问候

编辑:问题不仅适用于JBOSSWS EJB3 WebServices,而是使用JAAS身份验证的任何内容。

有帮助吗?

解决方案

找到了2种适合我的解决方案。

解决方案1)更改JAAS缓存的默认超时

您可以通过编辑$ jboss_home/server/default/conf/jboss-service.conf来执行此操作。找到文件的一部分,在此处配置JaasseCurityManager mbean,然后将属性defaultCachetimeOut更改为可接受的小值(60秒对我来说是可以的)。如果要完全禁用安全凭证的缓存,请将值设置为0。

<!-- JAAS security manager and realm mapping -->
   <mbean code="org.jboss.security.plugins.JaasSecurityManagerService"
      <!-- 
         skipped some configuration
      -->

      <!-- DefaultCacheTimeout: Specifies the default timed cache policy timeout
      in seconds.
      If you want to disable caching of security credentials, set this to 0 to
      force authentication to occur every time. This has no affect if the
      AuthenticationCacheJndiName has been changed from the default value.
      -->
       <attribute name="DefaultCacheTimeout">60</attribute>
      <!-- DefaultCacheResolution: Specifies the default timed cache policy
      resolution in seconds. This controls the interval at which the cache
      current timestamp is updated and should be less than the DefaultCacheTimeout
      in order for the timeout to be meaningful. This has no affect if the
      AuthenticationCacheJndiName has been changed from the default value.
      -->
      <attribute name="DefaultCacheResolution">30</attribute>
      <!-- 
         skipped some configuration
      -->
   </mbean>

解决方案2:每当用户的角色更改时,请在Jaassecuritymanager mbean上调用方法flushauthenticationcache(“ mywssecurity”)。

问候

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top