Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement namespacing #189

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ utils/dist/
utils/tmp/
utils/starting_HEAD
/.settings
.idea/
vendor/
.php_cs.cache
composer.lock
77 changes: 77 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

use Symfony\CS\Config\Config;
use Symfony\CS\FixerInterface;
use Symfony\CS\Finder\DefaultFinder;

$fixers = [
'blankline_after_open_tag',
'braces',
'concat_without_spaces',
'double_arrow_multiline_whitespaces',
'duplicate_semicolon',
'elseif',
'empty_return',
'encoding',
'eof_ending',
'extra_empty_lines',
'function_call_space',
'function_declaration',
'include',
'indentation',
'join_function',
'line_after_namespace',
'linefeed',
'list_commas',
'logical_not_operators_with_successor_space',
'lowercase_constants',
'lowercase_keywords',
'method_argument_space',
'multiline_array_trailing_comma',
'multiline_spaces_before_semicolon',
'multiple_use',
'namespace_no_leading_whitespace',
'no_blank_lines_after_class_opening',
'no_empty_lines_after_phpdocs',
'object_operator',
'operators_spaces',
'parenthesis',
'phpdoc_indent',
'phpdoc_inline_tag',
'phpdoc_no_access',
'phpdoc_no_package',
'phpdoc_scalar',
'phpdoc_short_description',
'phpdoc_to_comment',
'phpdoc_trim',
'phpdoc_type_to_var',
'phpdoc_var_without_name',
'remove_leading_slash_use',
'remove_lines_between_uses',
'return',
'self_accessor',
'short_array_syntax',
'short_echo_tag',
'short_tag',
'single_array_no_trailing_comma',
'single_blank_line_before_namespace',
'single_line_after_imports',
'single_quote',
'spaces_before_semicolon',
'spaces_cast',
'standardize_not_equal',
'ternary_spaces',
'trailing_spaces',
'trim_array_spaces',
'unalign_equals',
'unary_operators_spaces',
'unused_use',
'visibility',
'whitespacy_lines',
];

return Config::create()
->finder(DefaultFinder::create()->in(__DIR__))
->fixers($fixers)
->level(FixerInterface::NONE_LEVEL)
->setUsingCache(true);
2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>phpcas-devel</name>
<name>phpCAS-devel</name>
<comment></comment>
<projects>
</projects>
Expand Down
35 changes: 29 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
language: php

php:
- "5.4"
- "5.5"
- "5.6"
script:
- cd test
- phpunit TestSuite.php
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

env:
global:
- setup=basic

matrix:
include:
- php: 5.4
env: setup=lowest
- php: 5.4
env: setup=stable

sudo: false

before_install:
- travis_retry composer self-update

install:
- if [[ $setup = 'basic' ]]; then travis_retry composer install --no-interaction --prefer-dist; fi
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-stable; fi
- if [[ $setup = 'lowest' ]]; then travis_retry composer update --prefer-dist --no-interaction --prefer-lowest --prefer-stable; fi

script: vendor/bin/phpunit

30 changes: 0 additions & 30 deletions CAS.php

This file was deleted.

14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
"ext-curl": "*"
},
"require-dev": {
"phpunit/phpunit": "~3.7.10"
"fabpot/php-cs-fixer": "~1.11",
"phpunit/phpunit": "~3.7"
},
"autoload": {
"classmap": [
"source/"
]
"psr-4": {
"phpCAS\\": "source/"
}
},
"autoload-dev": {
"psr-4": {
"phpCAS\\": "test/"
}
},
"extra": {
"branch-alias": {
Expand Down
8 changes: 4 additions & 4 deletions docs/Upgrading
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

For security hardening purposes the verbose error messages to the web browsers
are now masked. If you want to have the verbose messages you need to use:
phpCAS::setVerbose(true);
CAS::setVerbose(true);
This will set the configuration to the old verbose mode that helps during
development and debugging.

Expand Down Expand Up @@ -55,11 +55,11 @@ when validating the proxy tickets. The strings are compared starting from
the beginning and must fully match with the proxies in the list.

Examples:
phpCAS::allowProxyChain(new CAS_ProxyChain(array(
CAS::allowProxyChain(new CAS_ProxyChain(array(
'https://app.example.com/'
)));
or
phpCAS::allowProxyChain(new CAS_ProxyChain(array(
CAS::allowProxyChain(new CAS_ProxyChain(array(
'/^https:\/\/app[0-9]\.example\.com\/rest\//',
'http://client.example.com/'
)));
Expand All @@ -68,7 +68,7 @@ For quick testing or in certain production screnarios you might want to
allow allow any other valid service to proxy your service. To do so, add
the "Any" chain:

phpcas::allowProxyChain(new CAS_ProxyChain_Any);
CAS::allowProxyChain(new CAS_ProxyChain_Any);

THIS SETTING IS HOWEVER NOT RECOMMENDED FOR PRODUCTION AND HAS SECURITY
IMPLICATIONS: YOU ARE ALLOWING ANY SERVICE TO ACT ON BEHALF OF A USER
Expand Down
33 changes: 15 additions & 18 deletions docs/examples/config.example.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
* The purpose of this central config file is configuring all examples
* in one place with minimal work for your working environment
* Just configure all the items in this config according to your environment
* and rename the file to config.php
* and rename the file to config.php.
*
* PHP Version 5
*
* @file config.php
* @category Authentication
* @package PhpCAS
* @author Joachim Fritschi <[email protected]>
* @author Adam Franco <[email protected]>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://wiki.jasig.org/display/CASC/phpCAS
*/

$phpcas_path = '../../source/';
$CAS_path = '../../source/';

///////////////////////////////////////
// Basic Config of the phpCAS client //
Expand All @@ -41,7 +39,7 @@

// The "real" hosts of clustered cas server that send SAML logout messages
// Assumes the cas server is load balanced across multiple hosts
$cas_real_hosts = array('cas-real-1.example.com', 'cas-real-2.example.com');
$cas_real_hosts = ['cas-real-1.example.com', 'cas-real-2.example.com'];

// Client config for cookie hardening
$client_domain = '127.0.0.1';
Expand All @@ -64,41 +62,40 @@

// Generating the URLS for the local cas example services for proxy testing
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
$curbase = 'https://' . $_SERVER['SERVER_NAME'];
$curbase = 'https://'.$_SERVER['SERVER_NAME'];
} else {
$curbase = 'http://' . $_SERVER['SERVER_NAME'];
$curbase = 'http://'.$_SERVER['SERVER_NAME'];
}
if ($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
$curbase .= ':' . $_SERVER['SERVER_PORT'];
$curbase .= ':'.$_SERVER['SERVER_PORT'];
}

$curdir = dirname($_SERVER['REQUEST_URI']) . "/";
$curdir = dirname($_SERVER['REQUEST_URI']).'/';

// CAS client nodes for rebroadcasting pgtIou/pgtId and logoutRequest
$rebroadcast_node_1 = 'http://cas-client-1.example.com';
$rebroadcast_node_2 = 'http://cas-client-2.example.com';

// access to a single service
$serviceUrl = $curbase . $curdir . 'example_service.php';
$serviceUrl = $curbase.$curdir.'example_service.php';
// access to a second service
$serviceUrl2 = $curbase . $curdir . 'example_service_that_proxies.php';
$serviceUrl2 = $curbase.$curdir.'example_service_that_proxies.php';

$pgtBase = preg_quote(preg_replace('/^http:/', 'https:', $curbase . $curdir), '/');
$pgtUrlRegexp = '/^' . $pgtBase . '.*$/';
$pgtBase = preg_quote(preg_replace('/^http:/', 'https:', $curbase.$curdir), '/');
$pgtUrlRegexp = '/^'.$pgtBase.'.*$/';

$cas_url = 'https://' . $cas_host;
$cas_url = 'https://'.$cas_host;
if ($cas_port != '443') {
$cas_url = $cas_url . ':' . $cas_port;
$cas_url = $cas_url.':'.$cas_port;
}
$cas_url = $cas_url . $cas_context;
$cas_url = $cas_url.$cas_context;

// Set the session-name to be unique to the current script so that the client script
// doesn't share its session with a proxied script.
// This is just useful when running the example code, but not normally.
session_name(
'session_for:'
. preg_replace('/[^a-z0-9-]/i', '_', basename($_SERVER['SCRIPT_NAME']))
.preg_replace('/[^a-z0-9-]/i', '_', basename($_SERVER['SCRIPT_NAME']))
);
// Set an UTF-8 encoding header for internation characters (User attributes)
header('Content-Type: text/html; charset=utf-8');
?>
21 changes: 12 additions & 9 deletions docs/examples/create_pgt_storage_db_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,34 @@
* CAS_PGTStorage_Db() options:
* $db, $db_user, $db_password, $db_table, $driver_options
* have to filled out directly. Option examples can be found in the
* config.example.php
* config.example.php.
*
* PHP Version 5
*
* @file create_pgt_storage_table.php
* @category Authentication
* @package PhpCAS
* @author Joachim Fritschi <[email protected]>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://wiki.jasig.org/display/CASC/phpCAS
*/

// Load the autoloader
require_once '../../vendor/autoload.php';

// Load the settings from the central config file
require_once 'config.php';
// Load the CAS lib
require_once $phpcas_path . '/CAS.php';

use phpCAS\CAS;
use phpCAS\CAS\Client;
use phpCAS\CAS\PGTStorage\Db;

// Dummy client because we need a 'client' object
$client = new CAS_Client(
CAS_VERSION_2_0, true, $cas_host, $cas_port, $cas_context, false
$client = new Client(
CAS::CAS_VERSION_2_0, true, $cas_host, $cas_port, $cas_context, false
);

// Set the torage object
$cas_obj = new CAS_PGTStorage_Db(
// Set the storage object
$cas_obj = new Db(
$client, $db, $db_user, $db_password, $db_table, $driver_options
);
$cas_obj->init();
Expand All @@ -46,7 +49,7 @@
<body>
<div class="success">
<?php
echo 'Table <b>' . $db_table . '</b> successfully created in database <b>' . $db . '</b>';
echo 'Table <b>'.$db_table.'</b> successfully created in database <b>'.$db.'</b>';
?>
</div>
</body>
Expand Down
Loading