Skip to content

Commit

Permalink
Merge pull request #14 from goblindegook/fix/13-rewrite-rule
Browse files Browse the repository at this point in the history
Fix/13 rewrite rule
  • Loading branch information
goblindegook committed Jul 26, 2015
2 parents 898f12c + 6c50512 commit d742339
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 491 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Temporary Items
# Composer

composer.phar
composer.lock
vendor/

# PHPdocumentor

Expand Down
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ php:
env:
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=1
- WP_VERSION=4.2 WP_MULTISITE=0
- WP_VERSION=4.2 WP_MULTISITE=1
- WP_VERSION=4.1 WP_MULTISITE=0
- WP_VERSION=4.1 WP_MULTISITE=1
- WP_VERSION=4.0 WP_MULTISITE=0
- WP_VERSION=4.0 WP_MULTISITE=1

before_script:
- composer install
- bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION

script: phpunit

sudo: false
10 changes: 9 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributors: goblindegook
Tags: authentication, cas, central authentication service, single sign-on, jasig cas, sso
Requires at least: 3.9
Tested up to: 4.1.1
Tested up to: 4.3
Stable tag: 1.2.1
License: GPLv2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -36,6 +36,10 @@ Please follow and contribute to Cassava's development on [Github](https://github

== Installation ==

= Using [Composer](https://getcomposer.org) =

1. Install the plugin package using `composer require goblindegook/wp-cas-server`.

= Using the WordPress Dashboard =

1. Navigate to the 'Add New' in the plugins dashboard
Expand Down Expand Up @@ -241,6 +245,10 @@ Parameters:

== Changelog ==

= 1.2.2 =

* Fixed endpoint registration in mixed HTTP/HTTPS installs. The server will now respond to requests over unencrypted HTTP, but will throw an error and tell the user to switch to HTTPS.

= 1.2.1 =

* Fixed missing autoloader in the SVN repository.
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"Cassava\\": "lib/"
}
},
"require": {},
"require": {
},
"require-dev": {
"phpunit/phpunit": "~4.7"
}
}
18 changes: 13 additions & 5 deletions lib/CAS/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function routes() {
* If the 'allowed_services' contains at least one host, it will always perform a safe
* redirect.
*
* Calling Server::redirect() will _always_ terminate the request.
* Calling Server::redirect() will _always_ end the request.
*
* @param string $location URI to redirect to.
* @param integer $status HTTP status code (default 302).
Expand Down Expand Up @@ -123,7 +123,7 @@ public function handleRequest( $path ) {
$this->setResponseHeader( 'Expires' , gmdate( static::RFC1123_DATE_FORMAT ) );

/**
* Fires before the CAS request is processed.
* Fires before processing the CAS request.
*
* @param string $path Requested URI path.
* @return string Filtered requested URI path.
Expand Down Expand Up @@ -175,19 +175,26 @@ public function handleRequest( $path ) {
* @global $_GET
*
* @uses \apply_filters()
* @uses \is_ssl()
* @uses \is_wp_error()
*/
protected function dispatch( $path ) {

if ( ! \is_ssl() ) {
throw new GeneralException(
__( 'The CAS server requires SSL.', 'wp-cas-server' ) );
}

/**
* Allows developers to disable CAS.
*
* @param boolean $cas_enabled Whether the server should respond to single sign-on requests.
*/
$enabled = apply_filters( 'cas_enabled', true );

if (!$enabled) {
throw new GeneralException( __('The CAS server is disabled.', 'wp-cas-server') );
if ( ! $enabled ) {
throw new GeneralException(
__( 'The CAS server is disabled.', 'wp-cas-server' ) );
}

$routes = $this->routes();
Expand All @@ -201,7 +208,8 @@ protected function dispatch( $path ) {
}

if ( ! class_exists( $controller ) ) {
throw new GeneralException( __('The controller for the route is invalid.', 'wp-cas-server') );
throw new GeneralException(
__( 'The controller for the route is invalid.', 'wp-cas-server' ) );
}

$args = $_GET;
Expand Down
10 changes: 1 addition & 9 deletions lib/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Plugin {
/**
* Plugin version.
*/
const VERSION = '1.2.1';
const VERSION = '1.2.2';

/**
* Plugin slug.
Expand Down Expand Up @@ -226,19 +226,11 @@ public function allowed_redirect_hosts( $allowed = array() ) {
* Register new rewrite rules for the CAS server URIs.
*
* @uses \add_rewrite_endpoint()
* @uses \is_ssl()
*
* @SuppressWarnings(CamelCaseMethodName)
*/
private function addRewriteRules() {

/**
* Enforce SSL
*/
if ( ! \is_ssl() ) {
return;
}

$path = Options::get( 'endpoint_slug' );

if ( empty( $path ) ) {
Expand Down
2 changes: 2 additions & 0 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ function _manually_load_plugin() {

$GLOBALS['wp_tests_options']['active_plugins'][] = 'wp-cas-server/wp-cas-server.php';

$_SERVER['HTTPS'] = 'on';

require $_tests_dir . '/includes/bootstrap.php';
require_once 'WPCAS_UnitTestCase.php';
7 changes: 0 additions & 7 deletions vendor/autoload.php

This file was deleted.

0 comments on commit d742339

Please sign in to comment.