求高手,求给力,cas的问题。CAS Authentication failed!

zhang_jun_tao 2011-01-06 06:32:01
目前开发一个项目采用java+php的组合
使用cas作为单点登录的服务,服务端已经部署没问题
java客户端使用cas做单点登录没问题。
但是php客户端使用cas的时候,无论怎么调,总是报以下错误:
CAS Authentication failed!

You were not authenticated.

You may submit your request again by clicking here.

If the problem persists, you may contact the administrator of this site.

无解啊,求高手给力 帮忙解决。。。
...全文
2361 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
zkgale 2011-11-16
  • 打赏
  • 举报
回复
你们查看一下你的那台服务器是否具有访问外网的权限~~~刚刚我也遇到这个问题了.
eagle_speed 2011-09-30
  • 打赏
  • 举报
回复
[Quote=引用 12 楼 niatwangcong 的回复:]

我们公司今年也搭建了一套cas的系统,其中整合过php,java,。net不同的版本。

1.你的cas server搭建的端口是80吗?cas 的server默认走的是https的协议,默认tomcat是8443端口。
2.通过日志来看有这么一段:“could not open URL 'http://passport.autoedu.com.cn:80/proxyValidate”,……
[/Quote]
我有问题,java端登出后,php项目依然没有注销,忘告之
yogibeargao 2011-04-12
  • 打赏
  • 举报
回复
我也遇到了这个问题,不关php的事。
我的log:
could not open URL 'https://sso.xxx.net:8443/cas/proxyValidate?service=http%3A%2F%2F192.168.5.102%2Fwiki2%2Fexample_simple.php&ticket=ST-11-7i4D5T1Ur55MpuiYdNgq-cas' to validate (CURL error #35: error:140773F2:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert unexpected message)

环境是ubuntu9.x+apache2.2.x,挂在apache下的三个系统都通过不同的方式报这个一模一样的错。

通过 nslookup sso.xxx.net可以解析到正确的ip地址。

查了一周了没解决问题,望高手相助!!
niatwangcong 2011-01-15
  • 打赏
  • 举报
回复
我们公司今年也搭建了一套cas的系统,其中整合过php,java,。net不同的版本。

1.你的cas server搭建的端口是80吗?cas 的server默认走的是https的协议,默认tomcat是8443端口。
2.通过日志来看有这么一段:“could not open URL 'http://passport.autoedu.com.cn:80/proxyValidate”,多半是客户端机器在进行validate验证的时候无法通过域名访问到那台server机器。这种问题我们当时也碰到过。
yaoweijq 2011-01-10
  • 打赏
  • 举报
回复
could not open URL 'http://passport.autoedu.com.cn:80/proxyValidate?service=http%3A%2F%2Fbbs.autoedu.com.cn%2Fexample_simple.php&ticket=ST-2-lifxE4vULp6tjP39T2R2-cas' to validate (CURL error #6: Couldn't resolve host 'passport.autoedu.com.cn')
...
zhang_jun_tao 2011-01-07
  • 打赏
  • 举报
回复
求给力:
以下错误日志:

6C8A .START phpCAS-1.2.0RC2 ****************** [CAS.php:471]
6C8A .=> phpCAS::client('2.0', 'passport.autoedu.com.cn', 80, '') [example_simple.php:13]
6C8A .| => CASClient::CASClient('2.0', false, 'passport.autoedu.com.cn', 80, '', true) [CAS.php:374]
6C8A .| | Starting a new session [client.php:680]
6C8A .| <= ''
6C8A .<= ''
6C8A .=> phpCAS::setNoCasServerValidation() [example_simple.php:16]
6C8A .<= ''
6C8A .=> phpCAS::forceAuthentication() [example_simple.php:19]
6C8A .| => CASClient::forceAuthentication() [CAS.php:950]
6C8A .| | => CASClient::isAuthenticated() [client.php:952]
6C8A .| | | => CASClient::wasPreviouslyAuthenticated() [client.php:1047]
6C8A .| | | | no user found [client.php:1216]
6C8A .| | | <= false
6C8A .| | | no ticket found [client.php:1109]
6C8A .| | <= false
6C8A .| | => CASClient::redirectToCas(false) [client.php:961]
6C8A .| | | => CASClient::getServerLoginURL(false, false) [client.php:1232]
6C8A .| | | | => CASClient::getURL() [client.php:439]
6C8A .| | | | | Final URI: http://bbs.autoedu.com.cn/example_simple.php [client.php:2805]
6C8A .| | | | <= 'http://bbs.autoedu.com.cn/example_simple.php'
6C8A .| | | <= 'http://passport.autoedu.com.cn:80/login?service=http%3A%2F%2Fbbs.autoedu.com.cn%2Fexample_simple.php'
6C8A .| | | Redirect to : http://passport.autoedu.com.cn:80/login?service=http%3A%2F%2Fbbs.autoedu.com.cn%2Fexample_simple.php [client.php:1234]
6C8A .| | | exit()
6C8A .| | | -
6C8A .| | -
6C8A .| -
0EFB .START phpCAS-1.2.0RC2 ****************** [CAS.php:471]
0EFB .=> phpCAS::client('2.0', 'passport.autoedu.com.cn', 80, '') [example_simple.php:13]
0EFB .| => CASClient::CASClient('2.0', false, 'passport.autoedu.com.cn', 80, '', true) [CAS.php:374]
0EFB .| | Starting a new session [client.php:680]
0EFB .| | ST or PT 'ST-2-lifxE4vULp6tjP39T2R2-cas' found [client.php:766]
0EFB .| <= ''
0EFB .<= ''
0EFB .=> phpCAS::setNoCasServerValidation() [example_simple.php:16]
0EFB .<= ''
0EFB .=> phpCAS::forceAuthentication() [example_simple.php:19]
0EFB .| => CASClient::forceAuthentication() [CAS.php:950]
0EFB .| | => CASClient::isAuthenticated() [client.php:952]
0EFB .| | | => CASClient::wasPreviouslyAuthenticated() [client.php:1047]
0EFB .| | | | no user found [client.php:1216]
0EFB .| | | <= false
0EFB .| | | PT `ST-2-lifxE4vULp6tjP39T2R2-cas' is present [client.php:1082]
0EFB .| | | => CASClient::validatePT('', NULL, NULL) [client.php:1083]
0EFB .| | | | [client.php:2653]
0EFB .| | | | => CASClient::getURL() [client.php:550]
0EFB .| | | | | Final URI: http://bbs.autoedu.com.cn/example_simple.php [client.php:2805]
0EFB .| | | | <= 'http://bbs.autoedu.com.cn/example_simple.php'
0EFB .| | | | => CAS_CurlRequest::_sendRequest() [AbstractRequest.php:188]
0EFB .| | | | | curl_exec() failed [CurlRequest.php:124]
0EFB .| | | | <= false
0EFB .| | | | could not open URL 'http://passport.autoedu.com.cn:80/proxyValidate?service=http%3A%2F%2Fbbs.autoedu.com.cn%2Fexample_simple.php&ticket=ST-2-lifxE4vULp6tjP39T2R2-cas' to validate (CURL error #6: Couldn't resolve host 'passport.autoedu.com.cn') [client.php:2664]
0EFB .| | | | => CASClient::authError('PT not validated', 'http://passport.autoedu.com.cn:80/proxyValidate?service=http%3A%2F%2Fbbs.autoedu.com.cn%2Fexample_simple.php&ticket=ST-2-lifxE4vULp6tjP39T2R2-cas', true) [client.php:2667]
0EFB .| | | | | => CASClient::getURL() [client.php:2888]
0EFB .| | | | | <= 'http://bbs.autoedu.com.cn/example_simple.php'
0EFB .| | | | | CAS URL: http://passport.autoedu.com.cn:80/proxyValidate?service=http%3A%2F%2Fbbs.autoedu.com.cn%2Fexample_simple.php&ticket=ST-2-lifxE4vULp6tjP39T2R2-cas [client.php:2889]
0EFB .| | | | | Authentication failure: PT not validated [client.php:2890]
0EFB .| | | | | Reason: no response from the CAS server [client.php:2892]
0EFB .| | | | | exit()
0EFB .| | | | | -
0EFB .| | | | -
0EFB .| | | -
0EFB .| | -
0EFB .| -


zhang_jun_tao 2011-01-07
  • 打赏
  • 举报
回复
目前是用以下代码测试的:
一个名叫:example_simple.php的文件
内容如下:

<?php

//
// phpCAS simple client
//

// import phpCAS lib
include_once('CAS.php');

phpCAS::setDebug();

// initialize phpCAS
phpCAS::client(CAS_VERSION_2_0,'passport.testtest.com.cn',80,'');

// no SSL validation for the CAS server
phpCAS::setNoCasServerValidation();

// force CAS authentication
phpCAS::forceAuthentication();

// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().

// logout if desired
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
}

// for this test, simply print that the authentication was successfull
?>
<html>
<head>
<title>phpCAS simple client</title>
</head>
<body>
<h1>Successfull Authentication!</h1>
<p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
<p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
<p><a href="?logout=">Logout</a></p>
</body>
</html>



cas服务器已经部署好 java程序使用没问题
但是上面这个php程序使用的时候 当访问上述这个文件的时候 提示登录 登录后 就报错:
CAS Authentication failed!

You were not authenticated.

You may submit your request again by clicking here.

If the problem persists, you may contact the administrator of this site.
yaoweijq 2011-01-07
  • 打赏
  • 举报
回复
求详细exception stacktrace
zhang_jun_tao 2011-01-07
  • 打赏
  • 举报
回复
网上能搜的我都搜遍了!!!
和你们贴出来的都是一样的!
千篇一律,都是一摸一样的配置,也不知道谁抄谁?
难道国内就没有人真正的遇到过这样的问题?
有没有谁真正的遇到过这样的错误?
CAS Authentication failed!
有没有?

再增加一点:
我已经却掉了8443端口的安全认证,使用的是80端口。


happyfmy 2011-01-06
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 dyllove98 的回复:]
我拷贝的

XML code
CAS单点登录测试环境搭建步骤

实验目的:
A. 验证cas 和 php应用客户端的连接性
B. 验证cas 和java应用客户端的连接性
C. 验证从java客户端连接到php客户端,session的连续性

1. 下载必要的软件:
Tomcat:apache-tomcat-5.5.27……
[/Quote]
真给力 大哥
Jlins 2011-01-06
  • 打赏
  • 举报
回复
我拷贝的
CAS单点登录测试环境搭建步骤

实验目的:
A. 验证cas 和 php应用客户端的连接性
B. 验证cas 和java应用客户端的连接性
C. 验证从java客户端连接到php客户端,session的连续性

1. 下载必要的软件:
Tomcat:apache-tomcat-5.5.27 windows安装包。Tomcat可以去apache 网站上去下载。
以下CAS有关软件可以去 http://www.ja-sig.org/products/cas/downloads/index.html 下载。
CAS server端: cas-server-3.3-release.zip
CAS php客户端:CAS-1.0.1.tgz
CAS java客户端:cas-client-2.0.11.zip

2. 搭建php和tomcat 运行环境。
我是使用AppServ V.2.5.10 来安装的PHP运行环境,这个集成环境包安装非常方便,很容易就上手。

Tomcat 的安装就更简单,使用直接解压版(不用安装成windows的服务), jdk的安装当然是必备的,这里就不累述了。
这里假定读者可以正常的安装好php 和 tomcat 的运行环境。

3. 配置CAS 服务器。
a. 为CAS服务器端生成HTTPS证书并注册
运行如下脚本:

keytool -delete -alias tomcatsso -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -storepass changeit

keytool -delete -alias tomcatsso -storepass changeit

rem keytool -list -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -storepass changeit

keytool -genkey -keyalg RSA -alias tomcatsso -dname "CN=localhost" -storepass changeit

keytool -export -alias tomcatsso -file "%JAVA_HOME%/jre/lib/security/tomcatsso.crt" -storepass changeit

keytool -import -alias tomcatsso -file "%JAVA_HOME%/jre/lib/security/tomcatsso.crt" -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -storepass changeit

说明:在生成key的过程," CN=localhost" 中的localhost为Server端的域名。当然你可以改成别的,取决于你的应用。

b. 配置Tomcat的HTTPS服务
拷贝C:\Documents and Settings\Administrator\.keystore到 tomcat的 conf 目录下。
修改server.xml,去掉ssl的注释,并更改为如下配置
<Connector port="8443" maxHttpHeaderSize="8192" keystorePass="changeit" keystoreFile="conf/.keystore"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />

注意:
请保持C:\Documents and Settings\Administrator\.keystore与%tomcat_home%\conf\.keystore一致

将cas.war 拷入 webapp 目录中,然后启动tomcat, 保证 http://localhost:8080/cas 可以访问。
用admin/admin 登录示例程序,显示登录成功则表明cas 服务器配置成功。

4. 配置PHP cas 客户端测试程序。
解压CAS-1.0.1.tgz,将CAS 目录和CAS.php 拷入 C:\AppServ\www (AppServ默认安装目录中的www目录)中。
这样, cas 的php 客户端就配置好了。
我们来测试一下这个php的cas 客户端是否起作用。

修改php客户端自带的一个示例:example_simple.php,并拷贝到www目录中。 
代码修改如下:
<?php

//
// phpCAS simple client
//

// import phpCAS lib
include_once('CAS.php');

phpCAS::setDebug();

// initialize phpCAS
phpCAS::client(CAS_VERSION_2_0,'localhost',8443,'cas');

// no SSL validation for the CAS server
phpCAS::setNoCasServerValidation();

// force CAS authentication
phpCAS::forceAuthentication();

// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().

// logout if desired
if (isset($_REQUEST['logout'])) {
phpCAS::logout();
}

// for this test, simply print that the authentication was successfull
?>
<html>
<head>
<title>phpCAS simple client</title>
</head>
<body>
<h1>Successfull Authentication!</h1>
<p>the user's login is <b><?php echo phpCAS::getUser(); ?></b>.</p>
<p>phpCAS version is <b><?php echo phpCAS::getVersion(); ?></b>.</p>
<p><a href="http://localhost:8080/ssodemo/ssojavaclient.jsp">去java客户端测试</a></p>
<p><a href="?logout=">Logout</a></p>
</body>
</html>
红色为修改添加部分。
测试:
1) 访问http://localhost/ example_simple.php
2) Cas检测到用户没有登录,转向:
  https://localhost:8443/cas/login?service=http%3A%2F%2Flocalhost%2Fexample_simple.php 登录界面。



3) 在登录界面输入admin/admin 用户名和密码。
4) 登录成功,转回http://localhost/ example_simple.php,并显示有关信息。

5. 配置cas 的 java 客户端
编写一个ssodemo的webapp 应用程序。
配置其web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<description>
JSP 2.0 Examples.
</description>
<display-name>JSP 2.0 Examples</display-name>


<filter> <filter-name>CAS Filter</filter-name>
<filter-class>edu.yale.its.tp.cas.client.filter.CASFilter</filter-class>
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.loginUrl</param-name>
<param-value>https://localhost:8443/cas/login</param-value>
</init-param>
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.validateUrl</param-name>
<param-value>https://localhost:8443/cas/serviceValidate</param-value>
</init-param>
<init-param>
<param-name>edu.yale.its.tp.cas.client.filter.serverName</param-name>
<param-value>localhost:8080</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CAS Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
红色为修改添加部分。

magong 2011-01-06
  • 打赏
  • 举报
回复
没做过。帮顶。
不过,网上搜了一下,文章很多啊。
zhang_jun_tao 2011-01-06
  • 打赏
  • 举报
回复
还有 哪位高手能把cas和discuz的结合讲解一下,不胜感激

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧