Redirect every HTTP request to HTTPS

只谈情不闲聊 提交于 2019-12-10 20:18:35

问题


I know, the answer is the following:

<security-constraint> 
    <web-resource-collection> 
        <web-resource-name>All resources</web-resource-name> 
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

and it works pretty good, but only if it is the only one security-constraint in the web.xml.

As soon as I add a second security-constraint, something like this:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Admin section</web-resource-name>
        <url-pattern>/admin/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>USER</role-name>
    </auth-constraint>
</security-constraint>

redirection stops working for URLs that point to the admin section (in this case the application shows a login form).

Is there a way to enable redirection globally via web.xml or wildfly configuration?

PS: tested with wildfly 8.2


回答1:


Did you try to add "user-data-constraint" to the second "security-constraint"?



来源:https://stackoverflow.com/questions/27302201/redirect-every-http-request-to-https

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!