示例#1
0
文件: NXAuth.php 项目: nitroxy/nxauth
 /**
  * Get a model containing data for the current user
  *
  * This method is singletone'd so calling it multiple times is no performace hit
  *
  * @return NXUser instance or null if not authenticated
  */
 public static function user()
 {
     if (self::is_authenticated()) {
         if (self::$user == null) {
             self::$user = new NXUser();
         }
         return self::$user;
     } else {
         return null;
     }
 }
示例#2
0
文件: logout.php 项目: nitroxy/nxauth
<?php

include "nxauth.php";
NXAuth::logout($base_url);
示例#3
0
<?php

require_once "libs/nxauth/include.php";
/* Settings for CAS via NitroXy.com */
$dir = dirname(__FILE__);
/* path to cert must be absolute, so include this */
$cas_config = array('site' => "nitroxy.com", 'port' => 443, 'key_id' => "nxauth", 'private_key' => null, 'ca_cert' => "{$nxauth_root}/certs/GeoTrustGlobalCA.pem");
NXAuth::init($cas_config);
/* Include local user config */
if (file_exists("{$dir}/nxauth.local.php")) {
    require_once "{$dir}/nxauth.local.php";
}
示例#4
0
文件: login.php 项目: nitroxy/nxauth
<?php

include "nxauth.php";
if (NXAuth::user()) {
    header("Location: {$base_url}");
    exit;
}
NXAuth::login($base_url);
示例#5
0
文件: index.php 项目: nitroxy/nxauth
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title>NXAuth Test</title>
	</head>
	<body>
		<h1>NXAuth Test</h1>
		<?php 
    if ($user) {
        ?>
			<form action="logout.php" method="get">
				<button type="submit">Logout</button>
			</form>
			<h2>User</h2>
			<?php 
        dump(NXAuth::user());
        ?>
			<h2>Functions</h2>
			<?php 
        foreach ($functions as $f => $args) {
            ?>
				<?php 
            if ($args === null) {
                $args = array();
            }
            ?>
				<h3><?php 
            echo $f;
            ?>
</h3>
				<?php