dongmu9253 2013-05-21 17:28
浏览 86
已采纳

使用PHP处理CAS登录(从JSP迁移)

Background:

We currently have a fully functional CAS implementation using JSP, but want to migrate it to a PHP implementation.

Currently, we have a central CAS server that authenticates the user and redirects them to a landing page(in JSP), which then takes their authentication data and passes it onto a third-party-application.

In this JSP we use the following snippet to retrieve the user's data

String usr = request.getParameter("id");
String nid = session.getAttribute("netid");

Question

How do I retrieve this information using PHP?

I have tried doing:

  • $_GET
  • $_POST
  • $_REQUEST
  • $_SESSION

and more.

I have a feeling that I may need to install phpCAS in order to do this, but do not want to do so unless absolutely necessary.

Thank you for your time.

  • 写回答

1条回答 默认 最新

  • doufuhao0566 2013-05-22 02:35
    关注

    Every consumer of a CAS service ticket needs to be able to validate a token, parse the response, etc. It seems like you're currently using some JSP-based CAS client which is doing the work for you? (possibly Yale's, as the Jasig one does not deal with JSP). If you want to switch your client to a non-JSP/Java application, but to a PHP one, your best option is to protect that page/client application with phpCAS. phpCAS will intercept the ticket in the url, validate it against the CAS server and set the appropriate session variables.

    Here's a simple example of phpCAS in action: https://github.com/Jasig/phpCAS/blob/master/docs/examples/example_simple.php

    Alternatively, you can write your own interception/validation/parsing code, but since this is a security product, I recommend using one of the well-known/tested clients.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启