2013-07-21 2 views
1

웹 응용 프로그램에서 나머지 API를 통해 자원을 시작/관리하려면 다른 웹 서비스 (개발/관리)를 호출해야합니다. 웹 서비스는 tomcat6에서 실행됩니다. POST 요청이 통과하지만 GET 요청이 금지되어 있음을 브라우저 로그에서 볼 수 있습니다. 웹 서비스 자체에서 동일한 호출을하면 문제가 발생하지 않습니다. 내가 tomcat6에 대한 교차 원산지 필터를 정의하고 지원되는 방법에서 GET을 언급했으나 여전히 문제가 지속됩니다.POST 요청이 정상적으로 처리되는 동안 GET 요청이 금지됩니다.

web.xml에서 응용 프로그램 서버 수준 자체에서이 방식으로 교차점 필터를 정의했습니다. http://software.dzhuvinov.com/cors-filter.html에서 CORS 필터 라이브러리를 사용하고 있습니다. "금지 된 오류의 이야기를 - 이것은 tomcat6 서버이며, 필터는

이상하게
<filter> 
    <filter-name>CORS</filter-name> 
    <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class> 
    <init-param> 
    <param-name>cors.allowOrigin</param-name> 
     <param-value>*</param-value> 
    </init-param> 
    <init-param> 
    <param-name>cors.supportedMethods</param-name> 
     <param-value>GET, POST, HEAD, PUT, DELETE, OPTIONS</param-value> 
    </init-param> 
    <init-param> 
    <param-name>cors.supportedHeaders</param-name> 
    <param-value>*</param-value> 
    </init-param> 
</filter> 

<filter-mapping> 
    <filter-name>CORS</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

, 웹 서비스는 수락 POST 호출을 다음과 같이 ($ TOMCAT6_HOME/conf의/web.xml 파일)에 정의되어 있지만 GET 요청에, 그 (403)를 던지고있다 지정된 자원에 대한 액세스가 금지되었습니다. " 다음과 같이 GET 호출에 대한

헤더는

Request URL:https://remote.vm.mycompany.com/remote/tunnel?read:c2faeb31-4147-49e8-b8d3-53d89496e5ca:0 
Request Method:GET 
Status Code:403 Forbidden 
Request Headersview source 
Accept:*/* 
Accept-Encoding:gzip,deflate,sdch 
Accept-Language:en-US,en;q=0.8 
Connection:keep-alive 
Host:remote.vm.mycompany.com 
Origin:https://ec2-184-72-200-91.compute-1.amazonaws.com 
Referer:https://ec2-184-72-200-91.compute-1.amazonaws.com/ 
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36 
Query String Parametersview sourceview URL encoded 
read:c2faeb31-4147-49e8-b8d3-53d89496e5ca:0: 
Response Headersview source 
Access-Control-Allow-Credentials:true 
Access-Control-Allow-Origin:https://ec2-184-72-200-91.compute-1.amazonaws.com 
Content-Length:961 
Content-Type:text/html;charset=utf-8 
Date:Sun, 21 Jul 2013 17:17:37 GMT 
Server:Apache-Coyote/1.1 

톰캣 액세스 로그는

여기
- - - [21/Jul/2013:17:17:37 +0000] POST /remote/tunnel?connect HTTP/1.1 200 - 
- - - [21/Jul/2013:17:17:37 +0000] GET /remote/tunnel?read:c2faeb31-4147-49e8-b8d3-53d89496e5ca:0 HTTP/1.1 403 - 

는 로그의에서 어떤 단서를 제공 GET 요청이 금지 된 공개하지만 does't 내 서블릿 코드. 나는 (라이선스 GPL) here

아마도 내가 무엇을 놓치고 수

입니다 GuacamoleHTTPTunnelServlet에 대한 guacamole (웹 서비스와 같은 HTML5 VNC 클라이언트)

package com.mycompany.html5remote; 

import java.util.Arrays; 

import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpSession; 

import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 

import net.sourceforge.guacamole.GuacamoleException; 
import net.sourceforge.guacamole.net.GuacamoleSocket; 
import net.sourceforge.guacamole.net.GuacamoleTunnel; 
import net.sourceforge.guacamole.net.InetGuacamoleSocket; 
import net.sourceforge.guacamole.protocol.ConfiguredGuacamoleSocket; 
import net.sourceforge.guacamole.protocol.GuacamoleClientInformation; 
import net.sourceforge.guacamole.protocol.GuacamoleConfiguration; 
import net.sourceforge.guacamole.servlet.GuacamoleHTTPTunnelServlet; 
import net.sourceforge.guacamole.servlet.GuacamoleSession; 

public class HttpTunnel extends GuacamoleHTTPTunnelServlet { 

    private Logger logger = LoggerFactory.getLogger(HttpTunnel.class); 

    @Override 
    protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException { 

     HttpSession httpSession = request.getSession(true); 
     logger.info("Inside doConnect Method."); 


     GuacamoleClientInformation info = new GuacamoleClientInformation(); 

     String hostname = request.getParameter("hostname"); 
     String protocol = request.getParameter("protocol"); 

     // Create socket 
     GuacamoleConfiguration config = new GuacamoleConfiguration(); 
     config.setProtocol(protocol); 
     config.setParameter("hostname", hostname); 
     //config.setParameter("hostname", "ec2-184-73-104-108.compute-1.amazonaws.com"); 
     if("vnc".equals(protocol)){ 
      config.setParameter("port", "5901"); 
     }else if ("rdp".equals(protocol)){ 
      config.setParameter("port", "3389"); 
     }else{ 
      config.setParameter("port", "22"); 
     } 

     logger.info("Set the configuration. Creating the socket connection now.."); 

     // Return connected socket 
     GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
       new InetGuacamoleSocket("localhost", 4822), 
       config, info 
     ); 

     logger.info("Successfully created socket connection."); 


     // Create tunnel from now-configured socket 
     GuacamoleTunnel tunnel = new GuacamoleTunnel(socket); 

     // Attach tunnel 
     GuacamoleSession session = new GuacamoleSession(httpSession); 
     session.attachTunnel(tunnel); 
     logger.info("Done"); 
     return tunnel; 

    } 

} 

문서를 통합하려고? 단서를 찾을 수있는 다른 곳이 있습니까? 제발 도와주세요

+0

가능한 경우 컨트롤러 또는 서블릿 코드를 첨부 할 수 있습니까? – Karthikeyan

+0

@ Karthikeyan 서블릿 코드를 업데이트했습니다. get/post 요청이 부모 클래스에 정의되어있는 일반 간단한 서블릿 – Ram

답변

0

web.xml에 구성된 http 메서드와 관련된 보안 제약이 있습니까? 귀하의 요청을 필터링하기 위해 별도의 API를 사용하는 이유는 무엇입니까?

+0

나는 초보자입니다. 내가 틀렸다면 나를 수정하십시오. 웹 서비스에서 크로스 원본 필터를 정의하지 않으면 요청이 브라우저가 아닌 다른 것으로부터 오는 경우 요청을 처리하지 못한다는 것을 알았습니다. 원하는 모든 것은 다른 웹 서버에서 GET 및 POST 요청을 보낼 수 있습니다. 더 나은 방법이 있다면 도와주세요. – Ram

+0

나는 일반적으로 클라이언트에 따라 그 차이를 보지 못합니다. 주로 그들이 말하는 프로토콜을 기반으로합니다 – junkiecoder

+0

cors.allowOrigin에 GET 요청을 보내는 도메인이 없을 때 CORs 필터가 403 오류 코드를 throw합니다. – junkiecoder

관련 문제