【问题标题】:Spring Webflow: Securing An Individual BindingSpring Webflow:保护单个绑定
【发布时间】:2016-03-15 09:36:54
【问题描述】:

因此,我在我的各种流定义中实现了<binder>,以确保从流中的每个页面绑定到模型的内容。因此,<binder> 部分可能如下所示:

<binder>
    <binding property="name" />
    <binding property="departmentId" />
    <binding property="phoneNumber" />
    <binding property="qualificationOverride" />
</binder>

我的问题是我不希望“qualificationOverride”绑定到模型,除非用户具有指定的角色 (ROLE_MANAGER)。

有人有什么想法吗?

杰森

【问题讨论】:

    标签: spring spring-webflow


    【解决方案1】:

    你可以做的是不绑定它,并在提交时从 requestParameters 获取值,然后进入决策状态,你可以使用安全检查权限并设置值。

    类似这样的东西(我还没有测试过):

    <view-state id="view" model="model">
        <binder>
            <binding property="name" />
            <binding property="departmentId" />
            <binding property="phoneNumber" />
            <!--<binding property="qualificationOverride" />-->
        </binder>
        <transition on="submit" to="bindIfManager">
            <set name="flowScope.qualificationOverride" value="requestParameters.qualificationOverride/>
        </transition>
    </view-state>
    
    <action-state id="bindIfManager">
        <!-- you will have to implement this, basically user.getAuthorities.contains(new SimpleGrantedAuthority(role))-->
        <evaluate expression="securityAction.isUserInRole(currentUser, 'ROLE_MANAGER')"/>
        <transition on="yes" to="finish">
            <set name="model.qualificationOverride" value="flowScope.qualificationOverride"/>
        </transition>
        <transition on="no" to="finish"/>
    </action-state>
    

    【讨论】:

    • 我试过了,但是如果中没有列出这些值,似乎没有直接在请求参数中。
    • 奇怪,我刚测试了一下,属性在requestParameters中
    • 您也可以尝试在表单中使用常规输入
    猜你喜欢
    • 2013-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-28
    • 1970-01-01
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    相关资源
    最近更新 更多