hello people, i worked all the night and i get this, when i use curl fromm the console in this way, i get the following //----------------------------------------------------------------------------------------------- F:\>curl -v -d "username=admin&password=123456" http://localhost/geoserver/j_spring_security_check
* Adding handle: conn: 0x720948 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0x720948) send_pipe: 1, recv_pipe: 0 * About to connect() to localhost port 80 (#0) * Trying ::1... * Connected to localhost (::1) port 80 (#0) > POST /geoserver/j_spring_security_check HTTP/1.1 > User-Agent: curl/7.30.0 > Host: localhost > Accept: */* > Content-Length: 32 > Content-Type: application/x-www-form-urlencoded > * upload completely sent off: 32 out of 32 bytes < HTTP/1.1 302 Found < Date: Tue, 18 Jun 2013 05:35:42 GMT * Server Jetty(6.1.8) is not blacklisted < Server: Jetty(6.1.8) < Expires: Thu, 01 Jan 1970 00:00:00 GMT < Location: http://localhost/geoserver/web < Content-Length: 0 < Set-Cookie: JSESSIONID=1wscsu7aqv0f7;Path=/geoserver < * Connection #0 to host localhost left intact //----------------------------------------------------------------------------------------------- and when i create a session with this JSESSIONID content that return this it works, i do this with firebug, but with the function it get different JSESSIONID, i dont know what to do , cause my function is fine and the log file of my function write this in the file GeoserverPHP.log: //----------------------------------------------------------------------------------------------- * About to connect() to localhost port 80 (#0) * Trying 127.0.0.1... * connected * Connected to localhost (127.0.0.1) port 80 (#0) > POST /geoserver/j_spring_security_check HTTP/1.1 Host: localhost Accept: */* Content-type: application/x-www-form-urlencoded Content-length: 37 * upload completely sent off: 37 out of 37 bytes < HTTP/1.1 302 Found < Date: Tue, 18 Jun 2013 07:47:53 GMT < Server: Jetty(6.1.8) < Expires: Thu, 01 Jan 1970 00:00:00 GMT < Location: http://localhost/geoserver/web < Content-Length: 0 < Set-Cookie: JSESSIONID=1qjoy35u1w0ly;Path=/geoserver < * Connection #0 to host localhost left intact # Unsuccessful cURL request to http://localhost/geoserver/j_spring_security_check [302] * Closing connection #0 //----------------------------------------------------------------------------------------------- and the function is this: //----------------------------------------------------------------------------------------------- public static function loginGeoserver($username, $password) { $logfh = fopen("GeoserverPHP.log", 'w') or die("can't open log file"); $post_data['username'] = $username; $post_data['password'] = $password; foreach ($post_data as $key => $value) { $post_items[] = $key . '=' . $value; } $post_string = implode('&', $post_items); $curl_connection = curl_init('http://' . master::$host . '/geoserver/j_spring_security_check'); // Optional settings for debugging curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); /*curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); */ curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); //option to return string //curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl_connection, CURLOPT_VERBOSE, true); curl_setopt($curl_connection, CURLOPT_STDERR, $logfh); // logs curl messages curl_setopt($curl_connection, CURLOPT_HTTPHEADER,array("Content-type: application/x-www-form-urlencoded", "Content-length: ".strlen($post_string))); /*curl_setopt($curl_connection, CURLOPT_HTTPHEADER, array("Content-type: application/xml")); */ curl_setopt($curl_connection, CURLOPT_POST, True); /*$passwordStr = "admin:master32"; curl_setopt($curl_connection, CURLOPT_USERPWD, $passwordStr);*/ curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); //curl_setopt($curl_connection, CURLOPT_POSTFIELDS, "username=admin&password=master32"); $result = curl_exec($curl_connection); $arrInfo = curl_getinfo($curl_connection); $successCode = 201; $url = $arrInfo['url']; if ($arrInfo['http_code'] != $successCode) { $msgStr = "# Unsuccessful cURL request to "; $msgStr .= $url." [". $arrInfo['http_code']. "]\n"; fwrite($logfh, $msgStr); } else { $msgStr = "# Successful cURL request to ".$url."\n"; fwrite($logfh, $msgStr); } fwrite($logfh, $result."\n"); curl_close($curl_connection); fclose($logfh); // close logfile //ini_set("user_agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1"); $headers = get_headers($arrInfo['url']); print_r($arrInfo); print_r("\n"); print_r("\n"); die(print_r($headers)); parse_str($url, $output); $trans = array("." => "_"); $base = strtr(master::$host, $trans); if (master::getLoggedUser() != null) { if (master::getLoggedUser()->tieneRol("Operador")) $str = "http://" . $base . "/geoserver/web/;jsessionid"; $str = "http://" . $base . "/geoserver/;jsessionid"; curl_close($curl_connection); if (!empty($output[$str])) { } else { //header('Location: /geoportal/index.php?page=home.home&Error=GeoserverDown'); header('Location: /personal/index.php?page=inicio&Error=GeoserverDown'); } setcookie('JSESSIONID', $output[$str], 0, '/geoserver'); setcookie('JSESSIONID', $output[$str], 0, '/'); } else { return null; } } //----------------------------------------------------------------------------- and i get this when in php the process die() to see the content of the variables: //------------------------------------------------------------------------------- Array ( [url] => http://localhost/geoserver/j_spring_security_check [content_type] => [http_code] => 302 [header_size] => 236 [request_size] => 188 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0 [namelookup_time] => 0 [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 37 [size_download] => 0 [speed_download] => 0 [speed_upload] => 37 [download_content_length] => 0 [upload_content_length] => 37 [starttransfer_time] => 0 [redirect_time] => 0 [certinfo] => Array ( ) [primary_ip] => 127.0.0.1 [primary_port] => 80 [local_ip] => 127.0.0.1 [local_port] => 1408 [redirect_url] => http://localhost/geoserver/web ) Array ( [0] => HTTP/1.1 302 Found [1] => Date: Tue, 18 Jun 2013 07:47:53 GMT [2] => Server: Jetty(6.1.8) [3] => Expires: Thu, 01 Jan 1970 00:00:00 GMT [4] => Location: http://localhost/geoserver/web/;jsessionid=1npqa4o5dsm7u?wicket:bookmarkablePage=:org.geoserver.web.GeoServerLoginPage&error=true [5] => Content-Length: [6] => Set-Cookie: SPRING_SECURITY_REMEMBER_ME_COOKIE=;Path=/geoserver;Expires=Thu, 01 Jan 1970 00:00:00 GMT [7] => Set-Cookie: JSESSIONID=1npqa4o5dsm7u;Path=/geoserver [8] => Connection: close [9] => HTTP/1.1 200 OK [10] => Date: Tue, 18 Jun 2013 07:47:53 GMT [11] => Server: Jetty(6.1.8) [12] => Content-Type: text/html; charset=utf-8 [13] => Content-Language: es-ES [14] => Pragma: no-cache [15] => Cache-Control: no-cache, max-age=0, must-revalidate, no-store [16] => Content-Length: 5246 [17] => Connection: close ) 1 //-------------------------------------------------------------------------------- help me please [email protected] escribió: > > > Wow, uffff, so, what gonna happen now, i need a way to log in the > users, and i need this version cause in this version the Direct > integration with GeoServer WMS of GWC is working fine, and i need it, > please is there another way to grant access or creation of session > from php, i need that cause in a few days i have to discuss my project > and i need the fast solution that comes with the use of GWC, please help > this is my php function: > //--------------------------------- > public static function loginGeoserver($username, $password) > { > $post_data['username'] = $username; > $post_data['password'] = $password; > foreach ($post_data as $key => $value) { > $post_items[] = $key . '=' . $value; > } > $post_string = implode('&', $post_items); > $curl_connection = curl_init('http://' . master::$host . > '/geoserver/j_spring_security_check'); > curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); > curl_setopt($curl_connection, CURLOPT_USERAGENT, > "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); > > > curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); > curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); > curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); > > //curl_setopt($curl_connection, > CURLOPT_HTTPHEADER,array("HTTPHeader: ".$username)); > > curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); > $result = curl_exec($curl_connection); > $arrInfo = curl_getinfo($curl_connection); > > die(print_r($arrInfo)); > > > $url = $arrInfo['url']; > parse_str($url, $output); > $trans = array("." => "_"); > $base = strtr(master::$host, $trans); > > > if (master::getLoggedUser() != null) { > if (master::getLoggedUser()->tieneRol("Operador")) > $str = "http://" . $base . "/geoserver/web/;jsessionid"; > $str = "http://" . $base . "/geoserver/;jsessionid"; > > curl_close($curl_connection); > if (!empty($output[$str])) { > } else { > //header('Location: > /geoportal/index.php?page=home.home&Error=GeoserverDown'); > header('Location: > /personal/index.php?page=inicio&Error=GeoserverDown'); > } > setcookie('JSESSIONID', $output[$str], 0, '/geoserver'); > setcookie('JSESSIONID', $output[$str], 0, '/'); > } else { > return null; > } > > } > //--------------------------------- > , and i put a break to see what the transaction return and i get : > //------------------------------------------- > > Array ( [url] => http://localhost/geoserver/web/ [content_type] => > text/html; charset=utf-8 [http_code] => 200 [header_size] => 718 > [request_size] => 503 [filetime] => -1 [ssl_verify_result] => 0 > [redirect_count] => 2 [total_time] => 0.016 [namelookup_time] => 0 > [connect_time] => 0 [pretransfer_time] => 0 [size_upload] => 0 > [size_download] => 7991 [speed_download] => 499437 [speed_upload] => 0 > [download_content_length] => 7991 [upload_content_length] => 0 > [starttransfer_time] => 0.016 [redirect_time] => 0 [certinfo] => Array > ( ) [primary_ip] => 127.0.0.1 [primary_port] => 80 [local_ip] => > 127.0.0.1 [local_port] => 1176 [redirect_url] => ) 1 > > > > please i need help, thanks to all > >> "Christian Mueller" <[email protected]> escribió: >> >>> Hi Thomas >>> >>> Long story for short, you detected a bug. Can you open a JIRA issue and >>> copy/paste your description (step 1 - 4). >>> >>> There should be an HTTP session but there is none. I looked a the code and >>> can confirm your observations. >>> >>> I will fix this ASAP. >>> >>> >>> 2013/6/17 Thomas Colley <[email protected]> >>> >>>> Thanks for your reply Christian.**** >>>> >>>> ** ** >>>> >>>> **1) **The pink tiles are due to Geoserver returning a "could not >>>> find layer" message as Catalog Mode under Data Security was set >>>> to HIDE. If >>>> I change Catalog Mode to CHALLENGE instead of pink tiles I get the 401 >>>> challenge prompt. **** >>>> >>>> ** ** >>>> >>>> **2) **That makes sense, I was on completely the wrong track with >>>> Remember Me, it was just a guess.**** >>>> >>>> ** ** >>>> >>>> **3) **Removing the anonymous filter would not be ideal as the way >>>> I was hoping it would work is users with access to restricted layers would >>>> authenticate via proxy and everyone else would fallback to >>>> anonymous access >>>> (anonymous has always been below proxy in the chain). However I have tried >>>> removing anonymous from the filter chain and it doesn't fix the problem.** >>>> ** >>>> >>>> ** ** >>>> >>>> The problem seems to be that although I have HTTP session creation allowed >>>> on the default chain the getcapabilities request containing the header is >>>> not creating a session. I can see this by monitoring the Tomcat >>>> manager. If >>>> I log in to the Geoserver admin interface a session is created and while >>>> still logged in the mapping application works fine. As soon as I >>>> log out of >>>> admin page the restricted map layers break.**** >>>> >>>> ** ** >>>> >>>> Here is the exact process:**** >>>> >>>> ** ** >>>> >>>> **1) **Openlayers page loads and submits a getcapabilities request >>>> with HTTP header added.**** >>>> >>>> **2) **WMS layer tree is displayed showing the correct restricted >>>> layers (data is restricted at a workspace level in Geoserver) so >>>> authentication has definitely been successful at this point.**** >>>> >>>> **3) **Checking Tomcat manager no session has been created**** >>>> >>>> **4) **Trying to load a restricted layer from this list results in >>>> either "can't find layer" error (pink tiles) or 401 prompt depending on >>>> Geoserver setting.**** >>>> >>>> ** ** >>>> >>>> So it appears that for some reason even though I am sending a request with >>>> header that is getting successfully authenticated (step 2) a >>>> session is not >>>> being created.**** >>>> >>>> ** ** >>>> >>>> Thanks again for your help**** >>>> >>>> ** ** >>>> >>>> Tom**** >>>> >>>> ** ** >>>> >>>> **** >>>> >>>> *From:* Christian Mueller [mailto:[email protected]] >>>> *Sent:* 15 June 2013 15:38 >>>> *To:* Thomas Colley >>>> *Cc:* [email protected] >>>> >>>> *Subject:* Re: [Geoserver-users] Geoserver Header Auth**** >>>> >>>> ** ** >>>> >>>> Hi Thomas**** >>>> >>>> ** ** >>>> >>>> About your questions**** >>>> >>>> ** ** >>>> >>>> 1) Adding a layer and getting pink tiles**** >>>> >>>> No idea here, adding a layer has nothing to do with authentication, could >>>> you reproduce this problem using the default security configuration ?**** >>>> >>>> ** ** >>>> >>>> 2) The remember me service works only with http basic auth and form based >>>> login. Why ?. The remeber me services uses a cookie and stores a digested >>>> representation of the password as cookie value (along with the user id) . >>>> Header authentication uses no password --> no remember me service.**** >>>> >>>> ** ** >>>> >>>> 3) Your filter chain**** >>>> >>>> You have a proxy and the anonymous filter. The last filter in the chain >>>> determines the authentication entry point (e.g. redirecting the browser to >>>> a login form). The anonymous filter has no authentication entry point >>>> because it always logs you in as "anonymous" successfully. If you use an >>>> anonymous filter, the filter has to be the last filter in the chain. A >>>> filter behind the anonymous filter will never be used.**** >>>> >>>> ** ** >>>> >>>> You have HTTP session creation enabled. I assume you send the http header >>>> once and use the session cookie for subsequent requests. This may be >>>> problematic in case of a session time out because you are logged in again >>>> as anonymous "automatically". Remove the anonymous filter if this is >>>> possible in your scenario. Upon session time out, you must log in again.** >>>> ** >>>> >>>> ** ** >>>> >>>> If you cannot remove the anonymous filter, you have to send the http >>>> header attribute in each request which requires authentication, >>>> there is no >>>> other solution. In this scenario, you can disable session creation.**** >>>> >>>> ** ** >>>> >>>> Hope this helps**** >>>> >>>> Christian**** >>>> >>> >>> >>> >>> -- >>> DI Christian Mueller MSc (GIS), MSc (IT-Security) >>> OSS Open Source Solutions GmbH >>> >> >> >> >> ---------------------------------------------------------------- >> This message was sent using IMP, the Internet Messaging Program. >> >> >> -- >> >> Este mensaje le ha llegado mediante el servicio de correo >> electronico que ofrece Infomed para respaldar el cumplimiento de las >> misiones del Sistema Nacional de Salud. La persona que envia este >> correo asume el compromiso de usar el servicio a tales fines y >> cumplir con las regulaciones establecidas >> >> Infomed: http://www.sld.cu/ >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by Windows: >> >> Build for Windows Store. >> >> http://p.sf.net/sfu/windows-dev2dev >> _______________________________________________ >> Geoserver-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/geoserver-users >> > > > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > > > -- > > Este mensaje le ha llegado mediante el servicio de correo > electronico que ofrece Infomed para respaldar el cumplimiento de las > misiones del Sistema Nacional de Salud. La persona que envia este > correo asume el compromiso de usar el servicio a tales fines y > cumplir con las regulaciones establecidas > > Infomed: http://www.sld.cu/ > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Windows: > > Build for Windows Store. > > http://p.sf.net/sfu/windows-dev2dev > _______________________________________________ > Geoserver-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geoserver-users > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. -- Este mensaje le ha llegado mediante el servicio de correo electronico que ofrece Infomed para respaldar el cumplimiento de las misiones del Sistema Nacional de Salud. La persona que envia este correo asume el compromiso de usar el servicio a tales fines y cumplir con las regulaciones establecidas Infomed: http://www.sld.cu/ ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Geoserver-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geoserver-users
