Skip to content

Commit

Permalink
Merge pull request #1 from leo108/proxy
Browse files Browse the repository at this point in the history
Proxy
  • Loading branch information
leo108 authored Oct 29, 2016
2 parents c3f7bd9 + 813e51e commit b7d5f59
Show file tree
Hide file tree
Showing 52 changed files with 3,266 additions and 608 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/vendor/
composer.lock

.idea
.idea
.DS_Store
coverage
5 changes: 5 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ build:
coverage:
file: '.coverage.xml'
format: 'clover'
filter:
excluded_paths:
- "database/"
- "config/"
- "tests/"
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
],
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*|5.2.*|5.3.*"
"ext-dom": "*",
"laravel/framework": "5.1.*|5.2.*|5.3.*",
"guzzlehttp/guzzle": "^6.2"
},
"require-dev": {
"mockery/mockery": "0.9.*",
Expand Down
16 changes: 10 additions & 6 deletions config/cas.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<?php

return [
'lock_timeout' => env('CAS_LOCK_TIMEOUT', 5000),
'ticket_expire' => env('CAS_TICKET_EXPIRE', 300),
'ticket_len' => env('CAS_TICKET_LEN', 32),
'user_table' => [
'lock_timeout' => env('CAS_LOCK_TIMEOUT', 5000),
'ticket_expire' => env('CAS_TICKET_EXPIRE', 300),
'ticket_len' => env('CAS_TICKET_LEN', 32),
'pg_ticket_expire' => env('CAS_PROXY_GRANTING_TICKET_EXPIRE', 7200),
'pg_ticket_len' => env('CAS_PROXY_GRANTING_TICKET_LEN', 64),
'pg_ticket_iou_len' => env('CAS_PROXY_GRANTING_TICKET_IOU_LEN', 64),
'verify_ssl' => env('CAS_VERIFY_SSL', true),
'user_table' => [
'id' => 'id',
'name' => 'users',
'model' => \App\User::class, //change to your user model class
],
'router' => [
'router' => [
'prefix' => 'cas',
'name_prefix' => 'cas.',
],
'middleware' => [
'middleware' => [
'common' => 'web',
'auth' => 'auth',
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProxyGrantingTicketsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('cas_proxy_granting_tickets', function (Blueprint $table) {
$table->increments('id');
$table->string('ticket', 256)->unique();
$table->string('pgt_url', 1024);
$table->integer('service_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->text('proxies')->nullable();
$table->timestamp('created_at')->nullable();
$table->timestamp('expire_at')->nullable();
$table->foreign('service_id')->references('id')->on('cas_services');
$table->foreign('user_id')->references(config('cas.user_table.id'))->on(config('cas.user_table.name'));
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('cas_proxy_granting_tickets');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddProxiesToTicketsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cas_tickets', function (Blueprint $table) {
$table->text('proxies')->nullable()->after('user_id');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cas_tickets', function (Blueprint $table) {
$table->dropColumn('proxies');
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddAllowProxyToServicesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cas_services', function (Blueprint $table) {
$table->boolean('allow_proxy')->default(false)->after('name');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cas_services', function (Blueprint $table) {
$table->dropColumn('allow_proxy');
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ChangeTicketColumnLength extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('cas_tickets', function (Blueprint $table) {
$table->string('ticket', 256)->change();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('cas_tickets', function (Blueprint $table) {
$table->string('ticket', 32)->change();
});
}
}
24 changes: 17 additions & 7 deletions src/Contracts/Interactions/UserLogin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@
interface UserLogin
{
/**
* @param Request $request
* @param callable $authenticated
* @return Response
* @param Request $request
* @return UserModel
*/
public function login(Request $request, callable $authenticated);
public function login(Request $request);

/**
* @param Request $request
* @return UserModel|null
*/
public function getCurrentUser(Request $request);

/**
* @param Request $request
* @return Response
*/
public function showAuthenticateFailed(Request $request);

/**
* @param Request $request
* @param string $jumpUrl
Expand All @@ -49,9 +54,14 @@ public function showLoginPage(Request $request, array $errors = []);
public function redirectToHome(array $errors = []);

/**
* @param Request $request
* @param callable $beforeLogout
* @param Request $request
* @return void
*/
public function logout(Request $request);

/**
* @param Request $request
* @return Response
*/
public function logout(Request $request, callable $beforeLogout);
public function showLoggedOut(Request $request);
}
19 changes: 19 additions & 0 deletions src/Contracts/Responses/AuthenticationFailureResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Created by PhpStorm.
* User: leo108
* Date: 2016/10/23
* Time: 16:19
*/

namespace Leo108\CAS\Contracts\Responses;

interface AuthenticationFailureResponse extends BaseResponse
{
/**
* @param string $code
* @param string $description
* @return $this
*/
public function setFailure($code, $description);
}
36 changes: 36 additions & 0 deletions src/Contracts/Responses/AuthenticationSuccessResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Created by PhpStorm.
* User: leo108
* Date: 2016/10/23
* Time: 15:54
*/

namespace Leo108\CAS\Contracts\Responses;

interface AuthenticationSuccessResponse extends BaseResponse
{
/**
* @param string $user
* @return $this
*/
public function setUser($user);

/**
* @param array $proxies
* @return $this
*/
public function setProxies($proxies);

/**
* @param array $attributes
* @return $this
*/
public function setAttributes($attributes);

/**
* @param array $ticket
* @return $this
*/
public function setProxyGrantingTicket($ticket);
}
19 changes: 19 additions & 0 deletions src/Contracts/Responses/BaseResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* Created by PhpStorm.
* User: leo108
* Date: 2016/10/23
* Time: 16:20
*/

namespace Leo108\CAS\Contracts\Responses;

use Symfony\Component\HttpFoundation\Response;

interface BaseResponse
{
/**
* @return Response
*/
public function toResponse();
}
20 changes: 20 additions & 0 deletions src/Contracts/Responses/ProxyFailureResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Created by PhpStorm.
* User: leo108
* Date: 2016/10/25
* Time: 17:48
*/

namespace Leo108\CAS\Contracts\Responses;


interface ProxyFailureResponse extends BaseResponse
{
/**
* @param string $code
* @param string $description
* @return $this
*/
public function setFailure($code, $description);
}
18 changes: 18 additions & 0 deletions src/Contracts/Responses/ProxySuccessResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: leo108
* Date: 2016/10/25
* Time: 18:17
*/

namespace Leo108\CAS\Contracts\Responses;

interface ProxySuccessResponse extends BaseResponse
{
/**
* @param string $ticket
* @return $this
*/
public function setProxyTicket($ticket);
}
1 change: 1 addition & 0 deletions src/Exceptions/CAS/CasException.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CasException extends \Exception
const INVALID_TICKET = 'INVALID_TICKET';
const INVALID_SERVICE = 'INVALID_SERVICE';
const INTERNAL_ERROR = 'INTERNAL_ERROR';
const UNAUTHORIZED_SERVICE_PROXY = 'UNAUTHORIZED_SERVICE_PROXY';

protected $casErrorCode;

Expand Down
Loading

0 comments on commit b7d5f59

Please sign in to comment.