• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 479
  • Last Modified:

CAS-login in PHP?

Hello!

I want to implement CAS-login.
Here is some more information: Link

Some example code (see attached): Link (specific for the CAS-server at KTH which I will use).

Can some one give me more detailed information of how I will do it?

I uploaded the attached PHP-file to my server but it doesn't show anything when I run it.

Thanks!

Anders Branderud

//
// phpCAS simple client
//

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

// initialize phpCAS
phpCAS::client(CAS_VERSION_2_0,'login.kth.se',443,'');

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();
}

Open in new window

caskth.php
0
AndersBranderud
Asked:
AndersBranderud
  • 3
1 Solution
 
AndersBranderudAuthor Commented:
I added this to the php-file and it solve the problem.:

<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>
0
 
AndersBranderudAuthor Commented:
Some minutes after that I had posted my question I found the solution myself.
0
 
AndersBranderudAuthor Commented:
Addition: The above code in my latest comment was found in a guide.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now