标签: security-constraint

仅限JSP/Servlet访问特定用户

我正在开发一个网络应用程序.我希望能够让一些朋友看到它,但不会有其他人偶然发现这个网址.我要打开一个登陆页面,然后是一个简单的密码框.输入正确的密码后,我只需将其记录在会话中,并像往常一样公开网站,以便其他时间保持浏览器打开状态.

有没有标准的方法来做到这一点?我将为我的webapp添加额外的代码以支持这一点,我不确定是否已经有一种内置的方法(我正在使用java servlet).

谢谢

jsp servlets security-constraint

4
推荐指数
1
解决办法
3889
查看次数

web.xml中的多个安全性约束无法正常工作

我正在升级一个Web应用程序(Servlet 3.0/Tomcat 7),它需要在大多数页面上进行基本身份验证.该应用程序有一小组监视servlet,其中没有一个应该受到保护.在我web.xml,我目前有以下security-constraint块(私人信息替换为字母表):

<security-constraint>
    <display-name>Security Constraint</display-name>
    <web-resource-collection>
        <web-resource-name>Protected Area</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>CN=A,OU=B,OU=C,OU=D,DC=E,DC=F</role-name>
    </auth-constraint>
</security-constraint>

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Unprotected Pages</web-resource-name>
        <url-pattern>/health/*</url-pattern>
    </web-resource-collection>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

在"健康"路径中有三个端点:

  • /health/monitor/status
  • /health/monitor/version
  • /health/monitor/version/xml

当我访问任version一端点时,系统不会提示我输入凭据(如预期的那样).但是,当我访问该status页面时,浏览器向我提供了一个基本的身份验证框.当我点击"取消"时,我被允许正常加载页面.同样,如果我已经登录,状态屏幕将不会再次提示我,直到我的登录过期.

我意识到这可以通过不部署安全内容来解决/*,但移动它将是很多工作改变硬编码路径和测试(这是一个非常古老的应用程序).​​.....我还有5或6个以上做.如果有必要,我愿意这样做,但我想知道这是否可行而不改变任何安全内容路径.我有在监视servlet的路径完全的自由.

这似乎与Tomcat 7有关- 多个安全约束不起作用,而不是完全失败只是我的一个端点失败,我觉得很奇怪.我花了一些时间搜索,它看起来像我正在做的应该工作......但事实并非如此.

我正在使用web-app3.0版,部署到Tomcat 7(尝试过7.0.42和7.0.47版).我已经尝试改变security-constraint块的顺序.

思考?

这是我的全部web.xml参考(注意监视servlet是通过Java注释管理的,因此不存在):

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
     xmlns="http://java.sun.com/xml/ns/javaee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
     http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

<display-name>TPS</display-name>

<servlet>
    <servlet-name>CFMLServlet</servlet-name>
    <servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
    <init-param>
      <param-name>configuration</param-name>
      <param-value>/WEB-INF/railo/</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet>
    <servlet-name>AMFServlet</servlet-name> …
Run Code Online (Sandbox Code Playgroud)

tomcat servlets tomcat7 security-constraint

4
推荐指数
1
解决办法
2万
查看次数

&lt;security-constraint&gt; &lt;url-pattern&gt; 和 web.xml 中的 * 字符

使用 Spring for Security,我可以使用以下代码运行程序。

<intercept-url pattern="/web/admin**/**" access="ROLE_ADMIN" requires-channel="https"/>
<intercept-url pattern="/web/**/" access="ROLE_USER,ROLE_ADMIN" requires-channel="https"/>
Run Code Online (Sandbox Code Playgroud)

我目前正在尝试在 web.xml 中执行此操作。使用 JBOSS 部署 .war 文件。下面是我所拥有的,网址模式是导致我出现第一个安全约束问题的原因。这些页面位于,并命名为 /web/adminarchive /web/adminsettings /web/adminstuff 等... Spring 中的上面的代码按照我想要的方式处理它,URL 是 /web/admin**/** 到捕获所有管理页面。我注释掉了 /* 部分,因为我知道它有效,只留下了管理部分。使用该结构不会引发任何错误,它只是根本不提示登录。

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Name</web-resource-name>
        <url-pattern>/web/admin**/**</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>ROLE_ADMIN</role-name>
    </auth-constraint>
</security-constraint>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Name</web-resource-name>
        <url-pattern>/*</url-pattern>
        <http-method>GET</http-method>
        <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
        <role-name>ROLE_USER</role-name>
    </auth-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

web.xml war url-pattern jboss6.x security-constraint

4
推荐指数
1
解决办法
2万
查看次数

Web.xml:url-pattern标签是否相互关联?

   <servlet-mapping>
      <servlet-name>myName</servlet-name>
      <url-pattern>/aName</url-pattern>
   </servlet-mapping>

    <security-constraint>

            <web-resource-collection>

                    ...

                    <url-pattern>
                            /*
                    </url-pattern>

            </web-resource-collection>

             ...

    </security-constraint>
Run Code Online (Sandbox Code Playgroud)

这是web.xml的摘录(使用它来配置jboss/tomcat webservice).只是想知道url-patternin web-resource-collection是否相对于url-patternin servlet-mapping.

xml jboss tomcat web.xml security-constraint

3
推荐指数
2
解决办法
5746
查看次数

欢迎文件忽略安全性约束

我的web.xml:

    <context-param>
            <param-name>javax.faces.PROJECT_STAGE</param-name>
            <param-value>Development</param-value>
        </context-param>

        <welcome-file-list>
            <welcome-file>/secured/secure.xhtml</welcome-file>
        </welcome-file-list>

        <servlet>
            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
            <servlet-name>Faces Servlet</servlet-name>
            <url-pattern>*.xhtml</url-pattern>
        </servlet-mapping>

        <context-param>
            <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
            <param-value>true</param-value>
        </context-param> 
    <security-constraint>
        <web-resource-collection>
          <web-resource-name>Restricted</web-resource-name>
          <url-pattern>/secured/*</url-pattern>
          <http-method>GET</http-method>
          <http-method>POST</http-method>
        </web-resource-collection>
        <auth-constraint>
          <role-name>ADMIN</role-name>
        </auth-constraint>
      </security-constraint>
<login-config>
     <auth-method>FORM</auth-method>
     <realm-name>jdbc-realm</realm-name>
     <form-login-config>
       <form-login-page>/public/login.xhtml</form-login-page>
       <form-error-page>/public/error.xhtml</form-error-page>
     </form-login-config>
   </login-config>
Run Code Online (Sandbox Code Playgroud)

我希望我的网络应用程序将未经授权的用户重定向到登录页面.有趣的事情我有这个工作,但我做了一些愚蠢的更改,现在访问localhost:8080我总是看到secure.xhtml即使没有登录.localhost:8080/secured/secure.xhtml重定向很好.

jsf servlets security-constraint welcome-file

3
推荐指数
1
解决办法
3181
查看次数

如何在 Java 应用程序中禁用不安全的 HTTP 方法

我有一个用 Restful webservice 和 java 开发的 web 应用程序。我正在使用泽西图书馆。我的团队在应用程序上运行了 Appscan 工具。该工具显示在 https:///AppName/ 上启用了不安全的 HTTP 方法。

编辑: 1.我想知道如何在此处禁用 DELETE 方法。2.当我向服务器发出选项请求时,它不应该在标题中的允许方法中列出删除方法。提前致谢。

java rest tomcat servlets security-constraint

1
推荐指数
1
解决办法
5890
查看次数

Spring Boot HTTPS和重定向

我使用Spring STS和Pivotal 3.1服务器(端口8080和8443)我在盒子上还有一个单独的tomcat 7实例,它运行在80和443上.

我使用Spring Boot 1.2.4版本.

我希望应用程序自动将所有请求重定向到https - 我没有使用嵌入式tomcat实例.

以前使用spring我在web.xml中有标签,它工作得很好.

我怎么能用弹簧靴来实现同样的目的呢?

谢谢,阿德里安

java spring tomcat security-constraint spring-boot

0
推荐指数
1
解决办法
3286
查看次数