├── .env.example ├── .gitattributes ├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── app ├── Console │ ├── Commands │ │ └── Inspire.php │ └── Kernel.php ├── Events │ ├── CasUserLoginEvent.php │ └── Event.php ├── Exceptions │ ├── CAS │ │ └── CasException.php │ ├── Handler.php │ └── UserException.php ├── Http │ ├── Controllers │ │ ├── Admin │ │ │ ├── HomeController.php │ │ │ ├── ServiceController.php │ │ │ └── UserController.php │ │ ├── Cas │ │ │ ├── SecurityController.php │ │ │ └── ValidateController.php │ │ ├── Controller.php │ │ ├── HomeController.php │ │ └── PasswordController.php │ ├── Kernel.php │ ├── Middleware │ │ ├── Admin.php │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── RedirectIfAuthenticated.php │ │ └── VerifyCsrfToken.php │ └── routes.php ├── Jobs │ └── Job.php ├── Listeners │ ├── .gitkeep │ └── CasUserLoginEventListener.php ├── Models │ ├── Service.php │ ├── ServiceHost.php │ └── Ticket.php ├── Policies │ └── .gitkeep ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── Response │ └── JsonResponse.php ├── Services │ ├── Service.php │ ├── Ticket.php │ └── User.php ├── User.php ├── UserProvider │ └── CasUserProvider.php └── Utils │ └── SimpleValidator.php ├── artisan ├── bootstrap ├── app.php ├── autoload.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── cas.php ├── compile.php ├── database.php ├── filesystems.php ├── mail.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── ModelFactory.php ├── migrations │ ├── .gitkeep │ ├── 2014_10_12_000000_create_users_table.php │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2016_08_01_061914_create_services_table.php │ ├── 2016_08_01_061918_create_tickets_table.php │ └── 2016_08_01_061923_create_service_hosts_table.php └── seeds │ ├── .gitkeep │ └── DatabaseSeeder.php ├── gulpfile.js ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── css │ ├── bootstrap.min.css │ ├── font-awesome.min.css │ ├── metisMenu.min.css │ └── sb-admin-2.css ├── favicon.ico ├── fonts │ ├── FontAwesome.otf │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.svg │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ ├── fontawesome-webfont.woff2 │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 ├── index.php ├── js │ ├── bootbox.js │ ├── bootstrap.min.js │ ├── jquery.min.js │ ├── metisMenu.min.js │ └── vue.min.js ├── robots.txt └── web.config ├── readme.md ├── resources ├── lang │ ├── cn │ │ ├── admin.php │ │ ├── auth.php │ │ ├── common.php │ │ ├── message.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php │ └── en │ │ ├── admin.php │ │ ├── auth.php │ │ ├── common.php │ │ ├── message.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php └── views │ ├── admin │ ├── dashboard.blade.php │ ├── service.blade.php │ └── user.blade.php │ ├── auth │ ├── emails │ │ └── password.blade.php │ ├── login.blade.php │ ├── login_warn.blade.php │ └── passwords │ │ ├── email.blade.php │ │ └── reset.blade.php │ ├── errors │ └── 503.blade.php │ ├── home.blade.php │ ├── layouts │ ├── admin.blade.php │ └── app.blade.php │ └── vendor │ ├── .gitkeep │ └── bootbox.blade.php ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore └── tests ├── Http └── Controllers │ ├── Cas │ ├── SecurityControllerTest.php │ └── ValidateControllerTest.php │ └── HomeControllerTest.php ├── Services ├── ServiceTest.php ├── TicketTest.php └── UserTest.php └── TestCase.php /.env.example: -------------------------------------------------------------------------------- 1 | APP_ENV=local 2 | APP_KEY=SomeRandomString 3 | APP_DEBUG=true 4 | APP_LOG_LEVEL=debug 5 | APP_URL=http://localhost 6 | APP_LOCATE=en 7 | 8 | DB_CONNECTION=mysql 9 | DB_HOST=127.0.0.1 10 | DB_PORT=3306 11 | DB_DATABASE=homestead 12 | DB_USERNAME=homestead 13 | DB_PASSWORD=secret 14 | 15 | CACHE_DRIVER=file 16 | SESSION_DRIVER=file 17 | QUEUE_DRIVER=sync 18 | 19 | REDIS_HOST=127.0.0.1 20 | REDIS_PASSWORD=null 21 | REDIS_PORT=6379 22 | 23 | MAIL_DRIVER=smtp 24 | MAIL_HOST=mailtrap.io 25 | MAIL_PORT=2525 26 | MAIL_USERNAME=null 27 | MAIL_PASSWORD=null 28 | MAIL_ENCRYPTION=null 29 | 30 | CAS_LOCK_TIMEOUT=5000 31 | CAS_TICKET_EXPIRE=300 32 | CAS_TICKET_LEN=32 33 | CAS_ALLOW_RESET_PWD=true 34 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /node_modules 3 | /public/storage 4 | Homestead.yaml 5 | Homestead.json 6 | .env 7 | /public/build 8 | 9 | .idea 10 | .phpstorm.meta.php 11 | _ide_helper.php 12 | _ide_helper_models.php 13 | coverage -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.6 5 | 6 | cache: 7 | directories: 8 | - node_modules 9 | timeout: 3600 10 | 11 | services: 12 | - mysql 13 | 14 | before_install: 15 | - sudo apt-get -qq update 16 | 17 | install: 18 | - sudo apt-get install -y npm 19 | - npm install -g nvm && export NVM_DIR=~/.nvm && . "$NVM_DIR/nvm.sh" 20 | - nvm install 0.12.14 && nvm use 0.12.14 21 | 22 | before_script: 23 | - mysql -e 'create database cas;' 24 | - composer install 25 | - npm install 26 | - gulp 27 | 28 | script: phpunit -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/Console/Commands/Inspire.php: -------------------------------------------------------------------------------- 1 | comment(PHP_EOL.Inspiring::quote().PHP_EOL); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Events/CasUserLoginEvent.php: -------------------------------------------------------------------------------- 1 | request = $request; 19 | $this->user = $user; 20 | } 21 | 22 | /** 23 | * Get the channels the event should be broadcast on. 24 | * 25 | * @return array 26 | */ 27 | public function broadcastOn() { 28 | return []; 29 | } 30 | 31 | /** 32 | * @return Request 33 | */ 34 | public function getRequest() { 35 | return $this->request; 36 | } 37 | 38 | /** 39 | * @return User 40 | */ 41 | public function getUser() { 42 | return $this->user; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/Events/Event.php: -------------------------------------------------------------------------------- 1 | casErrorCode = $casErrorCode; 28 | $this->message = $msg; 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getCasErrorCode() 35 | { 36 | return $this->casErrorCode; 37 | } 38 | 39 | public function getCasMsg() 40 | { 41 | //todo translate error msg 42 | return $this->casErrorCode; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | ajax() && !$request->pjax()) || $request->wantsJson()) { 54 | if ($e instanceof ValidationException) { 55 | return AppJsonResponse::error(join("\n", $e->validator->errors()->all()), -1); 56 | } 57 | 58 | return AppJsonResponse::error($e->getMessage(), $e->getCode()); 59 | } 60 | 61 | return parent::render($request, $e); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/Exceptions/UserException.php: -------------------------------------------------------------------------------- 1 | User::dashboard(), 23 | 'service' => Service::dashboard(), 24 | ] 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/ServiceController.php: -------------------------------------------------------------------------------- 1 | get('page', 1); 22 | $limit = 20; 23 | $search = $request->get('search', ''); 24 | $services = Service::getList($search, $page, $limit); 25 | 26 | return view( 27 | 'admin.service', 28 | [ 29 | 'services' => $services, 30 | 'query' => [ 31 | 'search' => $search, 32 | ], 33 | ] 34 | ); 35 | } 36 | 37 | public function saveAction(Request $request) 38 | { 39 | $id = $request->get('id', 0); 40 | $name = $request->get('name', ''); 41 | $enabled = $request->get('enabled', false); 42 | $hosts = array_filter(explode("\n", $request->get('hosts', ''))); 43 | $service = Service::createOrUpdate($name, $hosts, $enabled, $id); 44 | $service->load('hosts'); 45 | 46 | return JsonResponse::success($service, trans($id > 0 ? 'admin.service.edit_ok' : 'admin.service.add_ok')); 47 | } 48 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Admin/UserController.php: -------------------------------------------------------------------------------- 1 | get('page', 1); 22 | $limit = 20; 23 | $search = $request->get('search', ''); 24 | $enabled = $request->get('enabled', null); 25 | if ($enabled === '') { 26 | $enabled = null; 27 | } 28 | $users = User::getList($search, $enabled, null, $page, $limit); 29 | 30 | return view( 31 | 'admin.user', 32 | [ 33 | 'users' => $users, 34 | 'query' => [ 35 | 'search' => $search, 36 | 'enabled' => is_null($enabled) ? '' : $enabled, 37 | ], 38 | ] 39 | ); 40 | } 41 | 42 | public function saveAction(Request $request) 43 | { 44 | $id = $request->get('id', 0); 45 | $name = $request->get('name', ''); 46 | $realName = $request->get('real_name', ''); 47 | $password = $request->get('password', ''); 48 | $email = $request->get('email', ''); 49 | $enabled = $request->get('enabled', false); 50 | $admin = $request->get('admin', false); 51 | $user = User::createOrUpdate($name, $realName, $password, $email, $admin, $enabled, $id); 52 | 53 | return JsonResponse::success($user, trans($id > 0 ? 'admin.user.edit_ok' : 'admin.user.add_ok')); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Http/Controllers/Cas/SecurityController.php: -------------------------------------------------------------------------------- 1 | get('service', ''); 31 | $errors = []; 32 | if (!empty($service)) { 33 | //service not found in white list 34 | if (!Service::isUrlValid($service)) { 35 | $errors[] = (new CasException(CasException::INVALID_SERVICE))->getCasMsg(); 36 | } 37 | } 38 | 39 | $user = \Auth::user(); 40 | //user already has sso session 41 | if ($user) { 42 | //must not be transparent 43 | if ($request->get('warn') === 'true' && !empty($service)) { 44 | $query = $request->query->all(); 45 | unset($query['warn']); 46 | $url = route('cas_login_action', $query); 47 | 48 | return view('auth.login_warn', ['url' => $url, 'service' => $service]); 49 | } 50 | 51 | return $this->authenticated($request, $user); 52 | } 53 | 54 | $view = view('auth.login', ['origin_req' => $request->query->all()]); 55 | if (!empty($errors)) { 56 | $view->withErrors(['global' => $errors]); 57 | } 58 | 59 | return $view; 60 | } 61 | 62 | protected function authenticated(Request $request, User $user) 63 | { 64 | return event(new CasUserLoginEvent($request, $user), [], true); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/Http/Controllers/Cas/ValidateController.php: -------------------------------------------------------------------------------- 1 | '; 22 | 23 | public function v1ValidateAction(Request $request) 24 | { 25 | $service = $request->get('service', ''); 26 | $ticket = $request->get('ticket', ''); 27 | if (empty($service) || empty($ticket)) { 28 | return new Response('no'); 29 | } 30 | 31 | if (!$this->lockTicket($ticket)) { 32 | return new Response('no'); 33 | } 34 | $record = Ticket::getByTicket($ticket); 35 | if (!$record || $record->service_url != $service) { 36 | $this->unlockTicket($ticket); 37 | 38 | return new Response('no'); 39 | } 40 | Ticket::invalidTicket($record); 41 | 42 | $this->unlockTicket($ticket); 43 | 44 | return new Response('yes'); 45 | } 46 | 47 | public function v2ValidateAction(Request $request) 48 | { 49 | return $this->casValidate($request, false); 50 | } 51 | 52 | public function v3ValidateAction(Request $request) 53 | { 54 | return $this->casValidate($request, true); 55 | } 56 | 57 | /** 58 | * @param Request $request 59 | * @param bool $returnAttr 60 | * @return Response 61 | */ 62 | protected function casValidate(Request $request, $returnAttr) 63 | { 64 | $service = $request->get('service', ''); 65 | $ticket = $request->get('ticket', ''); 66 | $format = strtoupper($request->get('format', 'XML')); 67 | if (empty($service) || empty($ticket)) { 68 | return $this->failureResponse( 69 | CasException::INVALID_REQUEST, 70 | 'param service and ticket can not be empty', 71 | $format 72 | ); 73 | } 74 | 75 | if (!$this->lockTicket($ticket)) { 76 | return $this->failureResponse(CasException::INTERNAL_ERROR, 'try to lock ticket failed', $format); 77 | } 78 | 79 | $record = Ticket::getByTicket($ticket); 80 | try { 81 | if (!$record) { 82 | throw new CasException(CasException::INVALID_TICKET, 'ticket is not valid'); 83 | } 84 | 85 | if ($record->service_url != $service) { 86 | throw new CasException(CasException::INVALID_SERVICE, 'service is not valid'); 87 | } 88 | } catch (CasException $e) { 89 | //invalid ticket if error occur 90 | $record instanceof TicketModel && Ticket::invalidTicket($record); 91 | $this->unlockTicket($ticket); 92 | 93 | return $this->failureResponse($e->getCasErrorCode(), $e->getMessage(), $format); 94 | } 95 | Ticket::invalidTicket($record); 96 | $this->unlockTicket($ticket); 97 | 98 | $attr = $returnAttr ? [ 99 | 'email' => $record->user->email, 100 | 'realName' => $record->user->real_name, 101 | ] : []; 102 | 103 | return $this->successResponse($record->user->name, $attr, $format); 104 | } 105 | 106 | /** 107 | * @param $username 108 | * @param $attrs 109 | * @param $format 110 | * @return Response 111 | */ 112 | protected function successResponse($username, $attrs, $format) 113 | { 114 | if (strtoupper($format) === 'JSON') { 115 | $data = [ 116 | 'serviceResponse' => [ 117 | 'authenticationSuccess' => [ 118 | 'user' => $username, 119 | ], 120 | ], 121 | ]; 122 | 123 | if (!empty($attrs)) { 124 | $data['serviceResponse']['authenticationSuccess']['attributes'] = $attrs; 125 | } 126 | 127 | return new Response($data); 128 | } else { 129 | $xml = simplexml_load_string(self::BASE_XML); 130 | $childSuccess = $xml->addChild('cas:authenticationSuccess'); 131 | $childSuccess->addChild('cas:user', $username); 132 | 133 | if (!empty($attrs)) { 134 | $childAttrs = $childSuccess->addChild('cas:attributes'); 135 | foreach ($attrs as $key => $value) { 136 | $childAttrs->addChild('cas:'.$key, $value); 137 | } 138 | } 139 | 140 | return $this->returnXML($xml); 141 | } 142 | } 143 | 144 | /** 145 | * @param $code 146 | * @param $desc 147 | * @param $format 148 | * @return Response 149 | */ 150 | protected function failureResponse($code, $desc, $format) 151 | { 152 | if (strtoupper($format) === 'JSON') { 153 | return new Response( 154 | [ 155 | 'serviceResponse' => [ 156 | 'authenticationFailure' => [ 157 | 'code' => $code, 158 | 'description' => $desc, 159 | ], 160 | ], 161 | ] 162 | ); 163 | } else { 164 | $xml = simplexml_load_string(self::BASE_XML); 165 | $childFailure = $xml->addChild('cas:authenticationFailure', $desc); 166 | $childFailure->addAttribute('code', $code); 167 | 168 | return $this->returnXML($xml); 169 | } 170 | } 171 | 172 | /** 173 | * @param string $ticket 174 | * @return bool 175 | */ 176 | protected function lockTicket($ticket) 177 | { 178 | return \App::make('locker')->acquireLock($ticket, config('cas.lock_timeout')); 179 | } 180 | 181 | /** 182 | * @param string $ticket 183 | * @return bool 184 | */ 185 | protected function unlockTicket($ticket) 186 | { 187 | return \App::make('locker')->releaseLock($ticket); 188 | } 189 | 190 | /** 191 | * remove the first line of xml string 192 | * @param string $str 193 | * @return string 194 | */ 195 | protected function removeXmlFirstLine($str) 196 | { 197 | $first = ''; 198 | if (stripos($str, $first) === 0) { 199 | return trim(substr($str, strlen($first))); 200 | } 201 | 202 | return $str; 203 | } 204 | 205 | /** 206 | * @param \SimpleXMLElement $xml 207 | * @return Response 208 | */ 209 | protected function returnXML(\SimpleXMLElement $xml) 210 | { 211 | return new Response($this->removeXmlFirstLine($xml->asXML()), 200, array('Content-Type' => 'application/xml')); 212 | } 213 | } -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | validate($request, ['new' => $rule], [], ['new' => trans('auth.new_pwd')]); 25 | 26 | $old = $request->get('old'); 27 | $new = $request->get('new'); 28 | $user = \Auth::user(); 29 | if (!\Hash::check($old, $user->password)) { 30 | return JsonResponse::error(trans('message.invalid_old_pwd')); 31 | } 32 | 33 | User::resetPassword($user->id, $new); 34 | 35 | return JsonResponse::success([], trans('message.change_pwd_ok')); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/Http/Controllers/PasswordController.php: -------------------------------------------------------------------------------- 1 | subject = trans('passwords.email_subject'); 24 | $this->redirectPath = route('home'); 25 | } 26 | 27 | protected function getResetValidationRules() 28 | { 29 | $rule = $this->originGetResetValidationRules(); 30 | $pwdRule = User::getPasswordRule(false); 31 | $pwdRule[] = 'confirmed'; 32 | $rule['password'] = join('|', array_unique($pwdRule)); 33 | 34 | return $rule; 35 | } 36 | 37 | protected function getResetValidationCustomAttributes() 38 | { 39 | return [ 40 | 'password' => trans('auth.new_pwd'), 41 | 'email' => trans('passwords.email'), 42 | ]; 43 | } 44 | 45 | use ResetsPasswords { 46 | getResetValidationRules as originGetResetValidationRules; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | [ 27 | \App\Http\Middleware\EncryptCookies::class, 28 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 29 | \Illuminate\Session\Middleware\StartSession::class, 30 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 31 | \App\Http\Middleware\VerifyCsrfToken::class, 32 | ], 33 | 34 | 'api' => [ 35 | 'throttle:60,1', 36 | ], 37 | ]; 38 | 39 | /** 40 | * The application's route middleware. 41 | * 42 | * These middleware may be assigned to groups or used individually. 43 | * 44 | * @var array 45 | */ 46 | protected $routeMiddleware = [ 47 | 'auth' => \App\Http\Middleware\Authenticate::class, 48 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 49 | 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class, 50 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 51 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 52 | 'admin' => \App\Http\Middleware\Admin::class 53 | ]; 54 | } 55 | -------------------------------------------------------------------------------- /app/Http/Middleware/Admin.php: -------------------------------------------------------------------------------- 1 | admin) { 20 | return $next($request); 21 | } 22 | 23 | if ($request->ajax() || $request->wantsJson()) { 24 | return JsonResponse::error(trans('auth.need_login')); 25 | } 26 | 27 | return redirect()->route('cas_login_page'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | guest()) { 24 | return $this->error($request); 25 | } 26 | 27 | if (isset($guardIns->user()->enabled) && !$guardIns->user()->enabled) { 28 | if ($guardIns instanceof StatefulGuard) { 29 | $guardIns->logout(); 30 | } 31 | 32 | return $this->error($request); 33 | } 34 | 35 | return $next($request); 36 | } 37 | 38 | /** 39 | * @param \Illuminate\Http\Request $request 40 | * @return mixed 41 | */ 42 | private function error($request) 43 | { 44 | if ($request->ajax() || $request->wantsJson()) { 45 | return JsonResponse::error(trans('auth.need_login')); 46 | } 47 | 48 | return redirect()->route('cas_login_page'); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 'auth', 17 | ], 18 | function () { 19 | Route::get('/', ['as' => 'home', 'uses' => 'HomeController@indexAction']); 20 | Route::post('changePwd', ['as' => 'change_pwd', 'uses' => 'HomeController@changePwdAction']); 21 | } 22 | ); 23 | 24 | if (config('cas.allow_reset_pwd')) { 25 | Route::group( 26 | [ 27 | 'middleware' => 'guest', 28 | ], 29 | function () { 30 | Route::get( 31 | 'password/email', 32 | ['as' => 'request_pwd_reset_email_page', 'uses' => 'PasswordController@getEmail'] 33 | ); 34 | Route::post( 35 | 'password/email', 36 | ['as' => 'send_pwd_reset_email', 'uses' => 'PasswordController@sendResetLinkEmail'] 37 | ); 38 | Route::get( 39 | 'password/reset/{token?}', 40 | ['as' => 'reset_pwd_page', 'uses' => 'PasswordController@showResetForm'] 41 | ); 42 | Route::post('password/reset', ['as' => 'do_reset_pwd', 'uses' => 'PasswordController@reset']); 43 | } 44 | ); 45 | } 46 | 47 | Route::group( 48 | [ 49 | 'prefix' => 'cas', 50 | 'namespace' => 'Cas', 51 | ], 52 | function () { 53 | Route::get('login', ['as' => 'cas_login_page', 'uses' => 'SecurityController@loginPageAction']); 54 | Route::post('login', ['as' => 'cas_login_action', 'uses' => 'SecurityController@login']); 55 | Route::get('logout', ['as' => 'cas_logout', 'uses' => 'SecurityController@logout'])->middleware('auth'); 56 | Route::any('validate', ['as' => 'cas_v1validate', 'uses' => 'ValidateController@v1ValidateAction']); 57 | Route::any('serviceValidate', ['as' => 'cas_v2validate', 'uses' => 'ValidateController@v2ValidateAction']); 58 | Route::any('p3/serviceValidate', ['as' => 'cas_v3validate', 'uses' => 'ValidateController@v3ValidateAction']); 59 | } 60 | ); 61 | 62 | Route::group( 63 | [ 64 | 'namespace' => 'Admin', 65 | 'middleware' => 'admin', 66 | 'prefix' => 'admin', 67 | ], 68 | function () { 69 | Route::get('home', ['as' => 'admin_home', 'uses' => 'HomeController@indexAction']); 70 | Route::get('users', ['as' => 'admin_user_list', 'uses' => 'UserController@listAction']); 71 | Route::post('user', ['as' => 'admin_save_user', 'uses' => 'UserController@saveAction']); 72 | Route::get('services', ['as' => 'admin_service_list', 'uses' => 'ServiceController@listAction']); 73 | Route::post('service', ['as' => 'admin_save_service', 'uses' => 'ServiceController@saveAction']); 74 | } 75 | ); -------------------------------------------------------------------------------- /app/Jobs/Job.php: -------------------------------------------------------------------------------- 1 | getRequest()->get('service', ''); 21 | if (!empty($serviceUrl)) { 22 | $query = parse_url($serviceUrl, PHP_URL_QUERY); 23 | try { 24 | $ticket = Ticket::applyTicket($event->getUser(), $serviceUrl); 25 | } catch (CasException $e) { 26 | return redirect()->route('home')->withErrors(['global' => $e->getCasMsg()]); 27 | } 28 | $finalUrl = $serviceUrl.($query ? '&' : '?').'ticket='.$ticket->ticket; 29 | 30 | return redirect($finalUrl); 31 | } 32 | 33 | return redirect()->route('home'); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Models/Service.php: -------------------------------------------------------------------------------- 1 | 'boolean', 20 | ]; 21 | 22 | public function hosts() 23 | { 24 | return $this->hasMany('App\Models\ServiceHost'); 25 | } 26 | } -------------------------------------------------------------------------------- /app/Models/ServiceHost.php: -------------------------------------------------------------------------------- 1 | belongsTo('App\Models\Service'); 22 | } 23 | } -------------------------------------------------------------------------------- /app/Models/Ticket.php: -------------------------------------------------------------------------------- 1 | expire_at))->getTimestamp() < time(); 22 | } 23 | 24 | public function service() 25 | { 26 | return $this->belongsTo('App\Models\Service'); 27 | } 28 | 29 | public function user() 30 | { 31 | return $this->belongsTo('App\User'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Policies/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | sql); 19 | }); 20 | } 21 | 22 | /** 23 | * Register any application services. 24 | * 25 | * @return void 26 | */ 27 | public function register() 28 | { 29 | $this->app->singleton( 30 | 'locker', 31 | function () { 32 | $conf = config('database.connections.mysql'); 33 | 34 | return new MySqlLock($conf['username'], $conf['password'], $conf['host']); 35 | } 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 18 | ]; 19 | 20 | /** 21 | * Register any application authentication / authorization services. 22 | * 23 | * @param \Illuminate\Contracts\Auth\Access\Gate $gate 24 | * @return void 25 | */ 26 | public function boot(GateContract $gate) 27 | { 28 | $this->registerPolicies($gate); 29 | 30 | \Auth::provider('cas', function ($app, array $config){ 31 | return new CasUserProvider($app['hash'], $config['model']); 32 | }); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\CasUserLoginEventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any other events for your application. 23 | * 24 | * @param \Illuminate\Contracts\Events\Dispatcher $events 25 | * @return void 26 | */ 27 | public function boot(DispatcherContract $events) 28 | { 29 | parent::boot($events); 30 | 31 | // 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapWebRoutes($router); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @param \Illuminate\Routing\Router $router 51 | * @return void 52 | */ 53 | protected function mapWebRoutes(Router $router) 54 | { 55 | $router->group([ 56 | 'namespace' => $this->namespace, 'middleware' => 'web', 57 | ], function ($router) { 58 | require app_path('Http/routes.php'); 59 | }); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/Response/JsonResponse.php: -------------------------------------------------------------------------------- 1 | $code, 'msg' => $msg, 'data' => $data]); 18 | } 19 | 20 | public static function success($data = [], $msg = '') 21 | { 22 | return new Response(['code' => 0, 'msg' => $msg, 'data' => $data]); 23 | } 24 | } -------------------------------------------------------------------------------- /app/Services/Service.php: -------------------------------------------------------------------------------- 1 | first(); 27 | if (!$record) { 28 | return null; 29 | } 30 | 31 | return $record->service; 32 | } 33 | 34 | /** 35 | * @param $url 36 | * @return bool 37 | */ 38 | public static function isUrlValid($url) 39 | { 40 | $service = self::getServiceByUrl($url); 41 | 42 | return $service !== null && $service->enabled; 43 | } 44 | 45 | /** 46 | * @param $name 47 | * @param $hostArr 48 | * @param $enabled 49 | * @param $id 50 | * @return \App\Models\Service 51 | */ 52 | public static function createOrUpdate($name, $hostArr, $enabled = true, $id = 0) 53 | { 54 | \DB::beginTransaction(); 55 | if ($id == 0) { 56 | if (Model::where('name', $name)->count() > 0) { 57 | throw new UserException(trans('message.service.name_duplicated')); 58 | } 59 | 60 | $service = Model::create( 61 | [ 62 | 'name' => $name, 63 | 'enabled' => boolval($enabled), 64 | 'created_at' => (new Carbon())->toDateTimeString(), 65 | ] 66 | ); 67 | } else { 68 | $service = Model::find($id); 69 | $service->enabled = boolval($enabled); 70 | $service->save(); 71 | ServiceHostModel::where('service_id', $id)->delete(); 72 | } 73 | 74 | foreach ($hostArr as $host) { 75 | $host = trim($host); 76 | if (ServiceHostModel::where('host', $host)->count() > 0) { 77 | throw new UserException(trans('message.service.host_occupied', ['host' => $host])); 78 | } 79 | ServiceHostModel::create(['host' => $host, 'service_id' => $service->id]); 80 | } 81 | \DB::commit(); 82 | 83 | return $service; 84 | } 85 | 86 | public static function getList($search, $page, $limit) 87 | { 88 | /* @var \Illuminate\Database\Query\Builder $query */ 89 | $like = '%'.$search.'%'; 90 | if (!empty($search)) { 91 | $query = Model::whereHas( 92 | 'hosts', 93 | function ($query) use ($like) { 94 | $query->where('host', 'like', $like); 95 | } 96 | )->orWhere('name', 'like', $like)->with('hosts'); 97 | } else { 98 | $query = Model::with('hosts'); 99 | } 100 | 101 | return $query->orderBy('id', 'desc')->paginate($limit, ['*'], 'page', $page); 102 | } 103 | 104 | public static function dashboard() 105 | { 106 | return [ 107 | 'total' => Model::count(), 108 | 'enabled' => Model::where('enabled', true)->count(), 109 | ]; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /app/Services/Ticket.php: -------------------------------------------------------------------------------- 1 | $ticket, 37 | 'expire_at' => new Carbon(sprintf('+%dsec', config('cas.ticket_expire', 300))), 38 | 'created_at' => new Carbon(), 39 | 'service_url' => $serviceUrl, 40 | 'user_id' => $user->id, 41 | 'service_id' => $service->id, 42 | ] 43 | ); 44 | 45 | return $record; 46 | } 47 | 48 | /** 49 | * @param $ticket 50 | * @param bool $checkExpired 51 | * @return bool|\App\Models\Ticket 52 | */ 53 | public static function getByTicket($ticket, $checkExpired = true) 54 | { 55 | $record = Model::where('ticket', $ticket)->first(); 56 | if (!$record) { 57 | return false; 58 | } 59 | 60 | return ($checkExpired && $record->isExpired()) ? false : $record; 61 | } 62 | 63 | /** 64 | * @param Model $ticket 65 | * @return bool|null 66 | */ 67 | public static function invalidTicket(Model $ticket) 68 | { 69 | return $ticket->delete(); 70 | } 71 | 72 | /** 73 | * @param $totalLength 74 | * @return bool|string 75 | */ 76 | protected static function getAvailableTicket($totalLength) 77 | { 78 | $prefix = 'ST-'; 79 | $ticket = false; 80 | $flag = false; 81 | for ($i = 0; $i < 10; $i++) { 82 | $str = bin2hex(random_bytes($totalLength)); 83 | $ticket = $prefix.substr($str, 0, $totalLength - strlen($prefix)); 84 | if (!self::getByTicket($ticket, false)) { 85 | $flag = true; 86 | break; 87 | } 88 | } 89 | 90 | if (!$flag) { 91 | return false; 92 | } 93 | 94 | return $ticket; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /app/Services/User.php: -------------------------------------------------------------------------------- 1 | first(); 34 | } 35 | 36 | /** 37 | * @param $email 38 | * @return \App\User|null 39 | */ 40 | public static function getUserByEmail($email) 41 | { 42 | return Model::where('email', $email)->first(); 43 | } 44 | 45 | /** 46 | * @param string $name 47 | * @param string $realName 48 | * @param string $password 49 | * @param string $email 50 | * @param bool $isAdmin 51 | * @param bool $enabled 52 | * @param int $id 53 | * @return \App\User 54 | */ 55 | public static function createOrUpdate( 56 | $name, 57 | $realName, 58 | $password, 59 | $email, 60 | $isAdmin = false, 61 | $enabled = true, 62 | $id = 0 63 | ) { 64 | $data = [ 65 | 'real_name' => $realName, 66 | 'email' => $email, 67 | 'enabled' => boolval($enabled), 68 | 'admin' => boolval($isAdmin), 69 | ]; 70 | 71 | SimpleValidator::validate( 72 | $data, 73 | [ 74 | 'real_name' => 'required', 75 | 'email' => 'required|email', 76 | ], 77 | [ 78 | 'real_name' => trans('admin.user.real_name'), 79 | 'email' => trans('admin.user.email'), 80 | ] 81 | ); 82 | 83 | if ($id <= 0) { 84 | if (static::getUserByName($name)) { 85 | throw new UserException(trans('message.user.name_duplicated')); 86 | } 87 | 88 | if (static::getUserByEmail($email)) { 89 | throw new UserException(trans('message.user.email_duplicated')); 90 | } 91 | 92 | $data['name'] = $name; 93 | $data['password'] = $password; 94 | 95 | SimpleValidator::validate( 96 | $data, 97 | [ 98 | 'name' => 'required', 99 | 'password' => self::getPasswordRule(true), 100 | ], 101 | [ 102 | 'name' => trans('admin.user.username'), 103 | 'password' => trans('admin.user.password'), 104 | ] 105 | ); 106 | $data['password'] = bcrypt($password); 107 | 108 | return Model::create($data); 109 | } 110 | 111 | if (!empty($password)) { 112 | $data['password'] = $password; 113 | SimpleValidator::validate( 114 | $data, 115 | [ 116 | 'password' => self::getPasswordRule(true), 117 | ], 118 | [ 119 | 'password' => trans('admin.user.password'), 120 | ] 121 | ); 122 | $data['password'] = bcrypt($password); 123 | } 124 | 125 | Model::find($id)->update($data); 126 | 127 | return Model::find($id); 128 | } 129 | 130 | /** 131 | * @param int $id 132 | * @param string $pwd 133 | * @return \App\User 134 | */ 135 | public static function resetPassword($id, $pwd) 136 | { 137 | $user = Model::find($id); 138 | if (!$user) { 139 | throw new UserException(trans('messages.user.not_exists')); 140 | } 141 | $user->password = bcrypt($pwd); 142 | $user->remember_token = Str::random(60); 143 | $user->save(); 144 | 145 | return $user; 146 | } 147 | 148 | /** 149 | * @param $search 150 | * @param $enabled 151 | * @param $admin 152 | * @param $page 153 | * @param $limit 154 | * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator 155 | */ 156 | public static function getList($search, $enabled, $admin, $page, $limit) 157 | { 158 | /* @var \Illuminate\Database\Query\Builder $query */ 159 | $query = Model::getQuery(); 160 | if ($search) { 161 | $like = '%'.$search.'%'; 162 | $query->where( 163 | function ($query) use ($like) { 164 | /* @var \Illuminate\Database\Query\Builder $query */ 165 | $query->where('name', 'like', $like) 166 | ->orWhere('real_name', 'like', $like) 167 | ->orWhere('email', 'like', $like); 168 | } 169 | ); 170 | } 171 | 172 | if (!is_null($enabled)) { 173 | $query->where('enabled', boolval($enabled)); 174 | } 175 | 176 | if (!is_null($admin)) { 177 | $query->where('admin', boolval($admin)); 178 | } 179 | 180 | return $query->orderBy('id', 'desc')->paginate($limit, ['*'], 'page', $page); 181 | } 182 | 183 | public static function dashboard() 184 | { 185 | return [ 186 | 'total' => Model::count(), 187 | 'active' => Model::where('enabled', true)->count(), 188 | 'admin' => Model::where('admin', true)->count(), 189 | ]; 190 | } 191 | 192 | public static function getPasswordRule($returnStr = true) 193 | { 194 | $rule = [ 195 | 'required', 196 | 'min:6', 197 | ]; 198 | if ($returnStr) { 199 | return join('|', $rule); 200 | } 201 | 202 | return $rule; 203 | } 204 | } 205 | -------------------------------------------------------------------------------- /app/User.php: -------------------------------------------------------------------------------- 1 | 'boolean', 25 | 'admin' => 'boolean', 26 | ]; 27 | 28 | /** 29 | * The attributes that should be hidden for arrays. 30 | * 31 | * @var array 32 | */ 33 | protected $hidden = [ 34 | 'password', 35 | 'remember_token', 36 | ]; 37 | } 38 | -------------------------------------------------------------------------------- /app/UserProvider/CasUserProvider.php: -------------------------------------------------------------------------------- 1 | enabled) && !$user->enabled) { 20 | return false; 21 | } 22 | 23 | return parent::validateCredentials($user, $credentials); 24 | } 25 | 26 | public function retrieveById($identifier) 27 | { 28 | $user = parent::retrieveById($identifier); 29 | if (isset($user->enabled) && !$user->enabled) { 30 | return null; 31 | } 32 | 33 | return $user; 34 | } 35 | 36 | public function retrieveByToken($identifier, $token) 37 | { 38 | $user = parent::retrieveByToken($identifier, $token); 39 | if (isset($user->enabled) && !$user->enabled) { 40 | return null; 41 | } 42 | 43 | return $user; 44 | } 45 | 46 | public function retrieveByCredentials(array $credentials) 47 | { 48 | $user = parent::retrieveByCredentials($credentials); 49 | if (isset($user->enabled) && !$user->enabled) { 50 | return null; 51 | } 52 | 53 | return $user; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/Utils/SimpleValidator.php: -------------------------------------------------------------------------------- 1 | fails()) { 20 | return []; 21 | } 22 | 23 | if ($throws) { 24 | throw new ValidationException($validator); 25 | } 26 | 27 | return $validator->errors(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 32 | 33 | $status = $kernel->handle( 34 | $input = new Symfony\Component\Console\Input\ArgvInput, 35 | new Symfony\Component\Console\Output\ConsoleOutput 36 | ); 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Shutdown The Application 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Once Artisan has finished running. We will fire off the shutdown events 44 | | so that any final work may be done by the application before we shut 45 | | down the process. This is the last thing to happen to the request. 46 | | 47 | */ 48 | 49 | $kernel->terminate($input, $status); 50 | 51 | exit($status); 52 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | =5.5.9", 9 | "laravel/framework": "5.2.*", 10 | "barryvdh/laravel-ide-helper": "^2.2", 11 | "doctrine/dbal": "^2.5", 12 | "arvenil/ninja-mutex": "^0.5.1" 13 | }, 14 | "require-dev": { 15 | "fzaninotto/faker": "~1.4", 16 | "mockery/mockery": "0.9.*", 17 | "phpunit/phpunit": "~4.0", 18 | "symfony/css-selector": "2.8.*|3.0.*", 19 | "symfony/dom-crawler": "2.8.*|3.0.*" 20 | }, 21 | "autoload": { 22 | "classmap": [ 23 | "database" 24 | ], 25 | "psr-4": { 26 | "App\\": "app/" 27 | } 28 | }, 29 | "autoload-dev": { 30 | "classmap": [ 31 | "tests/TestCase.php" 32 | ] 33 | }, 34 | "scripts": { 35 | "post-install-cmd": [ 36 | "php -r \"copy('.env.example', '.env');\"", 37 | "php artisan key:generate", 38 | "Illuminate\\Foundation\\ComposerScripts::postInstall", 39 | "php artisan optimize" 40 | ], 41 | "post-update-cmd": [ 42 | "Illuminate\\Foundation\\ComposerScripts::postUpdate", 43 | "php artisan optimize" 44 | ] 45 | }, 46 | "config": { 47 | "preferred-install": "dist" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /config/app.php: -------------------------------------------------------------------------------- 1 | env('APP_ENV', 'production'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Application Debug Mode 21 | |-------------------------------------------------------------------------- 22 | | 23 | | When your application is in debug mode, detailed error messages with 24 | | stack traces will be shown on every error that occurs within your 25 | | application. If disabled, a simple generic error page is shown. 26 | | 27 | */ 28 | 29 | 'debug' => env('APP_DEBUG', false), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Application URL 34 | |-------------------------------------------------------------------------- 35 | | 36 | | This URL is used by the console to properly generate URLs when using 37 | | the Artisan command line tool. You should set this to the root of 38 | | your application so that it is used when running Artisan tasks. 39 | | 40 | */ 41 | 42 | 'url' => env('APP_URL', 'http://localhost'), 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Application Timezone 47 | |-------------------------------------------------------------------------- 48 | | 49 | | Here you may specify the default timezone for your application, which 50 | | will be used by the PHP date and date-time functions. We have gone 51 | | ahead and set this to a sensible default for you out of the box. 52 | | 53 | */ 54 | 55 | 'timezone' => 'UTC', 56 | 57 | /* 58 | |-------------------------------------------------------------------------- 59 | | Application Locale Configuration 60 | |-------------------------------------------------------------------------- 61 | | 62 | | The application locale determines the default locale that will be used 63 | | by the translation service provider. You are free to set this value 64 | | to any of the locales which will be supported by the application. 65 | | 66 | */ 67 | 68 | 'locale' => env('APP_LOCATE', 'en'), 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Application Fallback Locale 73 | |-------------------------------------------------------------------------- 74 | | 75 | | The fallback locale determines the locale to use when the current one 76 | | is not available. You may change the value to correspond to any of 77 | | the language folders that are provided through your application. 78 | | 79 | */ 80 | 81 | 'fallback_locale' => 'en', 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Encryption Key 86 | |-------------------------------------------------------------------------- 87 | | 88 | | This key is used by the Illuminate encrypter service and should be set 89 | | to a random, 32 character string, otherwise these encrypted strings 90 | | will not be safe. Please do this before deploying an application! 91 | | 92 | */ 93 | 94 | 'key' => env('APP_KEY'), 95 | 96 | 'cipher' => 'AES-256-CBC', 97 | 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Logging Configuration 101 | |-------------------------------------------------------------------------- 102 | | 103 | | Here you may configure the log settings for your application. Out of 104 | | the box, Laravel uses the Monolog PHP logging library. This gives 105 | | you a variety of powerful log handlers / formatters to utilize. 106 | | 107 | | Available Settings: "single", "daily", "syslog", "errorlog" 108 | | 109 | */ 110 | 111 | 'log' => env('APP_LOG', 'single'), 112 | 113 | 'log_level' => env('APP_LOG_LEVEL', 'debug'), 114 | 115 | /* 116 | |-------------------------------------------------------------------------- 117 | | Autoloaded Service Providers 118 | |-------------------------------------------------------------------------- 119 | | 120 | | The service providers listed here will be automatically loaded on the 121 | | request to your application. Feel free to add your own services to 122 | | this array to grant expanded functionality to your applications. 123 | | 124 | */ 125 | 126 | 'providers' => [ 127 | 128 | /* 129 | * Laravel Framework Service Providers... 130 | */ 131 | Illuminate\Auth\AuthServiceProvider::class, 132 | Illuminate\Broadcasting\BroadcastServiceProvider::class, 133 | Illuminate\Bus\BusServiceProvider::class, 134 | Illuminate\Cache\CacheServiceProvider::class, 135 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, 136 | Illuminate\Cookie\CookieServiceProvider::class, 137 | Illuminate\Database\DatabaseServiceProvider::class, 138 | Illuminate\Encryption\EncryptionServiceProvider::class, 139 | Illuminate\Filesystem\FilesystemServiceProvider::class, 140 | Illuminate\Foundation\Providers\FoundationServiceProvider::class, 141 | Illuminate\Hashing\HashServiceProvider::class, 142 | Illuminate\Mail\MailServiceProvider::class, 143 | Illuminate\Pagination\PaginationServiceProvider::class, 144 | Illuminate\Pipeline\PipelineServiceProvider::class, 145 | Illuminate\Queue\QueueServiceProvider::class, 146 | Illuminate\Redis\RedisServiceProvider::class, 147 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, 148 | Illuminate\Session\SessionServiceProvider::class, 149 | Illuminate\Translation\TranslationServiceProvider::class, 150 | Illuminate\Validation\ValidationServiceProvider::class, 151 | Illuminate\View\ViewServiceProvider::class, 152 | 153 | /* 154 | * Application Service Providers... 155 | */ 156 | App\Providers\AppServiceProvider::class, 157 | App\Providers\AuthServiceProvider::class, 158 | App\Providers\EventServiceProvider::class, 159 | App\Providers\RouteServiceProvider::class, 160 | 161 | Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class, 162 | ], 163 | 164 | /* 165 | |-------------------------------------------------------------------------- 166 | | Class Aliases 167 | |-------------------------------------------------------------------------- 168 | | 169 | | This array of class aliases will be registered when this application 170 | | is started. However, feel free to register as many as you wish as 171 | | the aliases are "lazy" loaded so they don't hinder performance. 172 | | 173 | */ 174 | 175 | 'aliases' => [ 176 | 177 | 'App' => Illuminate\Support\Facades\App::class, 178 | 'Artisan' => Illuminate\Support\Facades\Artisan::class, 179 | 'Auth' => Illuminate\Support\Facades\Auth::class, 180 | 'Blade' => Illuminate\Support\Facades\Blade::class, 181 | 'Cache' => Illuminate\Support\Facades\Cache::class, 182 | 'Config' => Illuminate\Support\Facades\Config::class, 183 | 'Cookie' => Illuminate\Support\Facades\Cookie::class, 184 | 'Crypt' => Illuminate\Support\Facades\Crypt::class, 185 | 'DB' => Illuminate\Support\Facades\DB::class, 186 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 187 | 'Event' => Illuminate\Support\Facades\Event::class, 188 | 'File' => Illuminate\Support\Facades\File::class, 189 | 'Gate' => Illuminate\Support\Facades\Gate::class, 190 | 'Hash' => Illuminate\Support\Facades\Hash::class, 191 | 'Lang' => Illuminate\Support\Facades\Lang::class, 192 | 'Log' => Illuminate\Support\Facades\Log::class, 193 | 'Mail' => Illuminate\Support\Facades\Mail::class, 194 | 'Password' => Illuminate\Support\Facades\Password::class, 195 | 'Queue' => Illuminate\Support\Facades\Queue::class, 196 | 'Redirect' => Illuminate\Support\Facades\Redirect::class, 197 | 'Redis' => Illuminate\Support\Facades\Redis::class, 198 | 'Request' => Illuminate\Support\Facades\Request::class, 199 | 'Response' => Illuminate\Support\Facades\Response::class, 200 | 'Route' => Illuminate\Support\Facades\Route::class, 201 | 'Schema' => Illuminate\Support\Facades\Schema::class, 202 | 'Session' => Illuminate\Support\Facades\Session::class, 203 | 'Storage' => Illuminate\Support\Facades\Storage::class, 204 | 'URL' => Illuminate\Support\Facades\URL::class, 205 | 'Validator' => Illuminate\Support\Facades\Validator::class, 206 | 'View' => Illuminate\Support\Facades\View::class, 207 | 208 | ], 209 | 210 | ]; 211 | -------------------------------------------------------------------------------- /config/auth.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'guard' => 'web', 18 | 'passwords' => 'users', 19 | ], 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Authentication Guards 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Next, you may define every authentication guard for your application. 27 | | Of course, a great default configuration has been defined for you 28 | | here which uses session storage and the Eloquent user provider. 29 | | 30 | | All authentication drivers have a user provider. This defines how the 31 | | users are actually retrieved out of your database or other storage 32 | | mechanisms used by this application to persist your user's data. 33 | | 34 | | Supported: "session", "token" 35 | | 36 | */ 37 | 38 | 'guards' => [ 39 | 'web' => [ 40 | 'driver' => 'session', 41 | 'provider' => 'users', 42 | ], 43 | 44 | 'api' => [ 45 | 'driver' => 'token', 46 | 'provider' => 'users', 47 | ], 48 | ], 49 | 50 | /* 51 | |-------------------------------------------------------------------------- 52 | | User Providers 53 | |-------------------------------------------------------------------------- 54 | | 55 | | All authentication drivers have a user provider. This defines how the 56 | | users are actually retrieved out of your database or other storage 57 | | mechanisms used by this application to persist your user's data. 58 | | 59 | | If you have multiple user tables or models you may configure multiple 60 | | sources which represent each model / table. These sources may then 61 | | be assigned to any extra authentication guards you have defined. 62 | | 63 | | Supported: "database", "eloquent" 64 | | 65 | */ 66 | 67 | 'providers' => [ 68 | 'users' => [ 69 | 'driver' => 'cas', 70 | 'model' => App\User::class, 71 | ], 72 | 73 | // 'users' => [ 74 | // 'driver' => 'database', 75 | // 'table' => 'users', 76 | // ], 77 | ], 78 | 79 | /* 80 | |-------------------------------------------------------------------------- 81 | | Resetting Passwords 82 | |-------------------------------------------------------------------------- 83 | | 84 | | Here you may set the options for resetting passwords including the view 85 | | that is your password reset e-mail. You may also set the name of the 86 | | table that maintains all of the reset tokens for your application. 87 | | 88 | | You may specify multiple password reset configurations if you have more 89 | | than one user table or model in the application and you want to have 90 | | separate password reset settings based on the specific user types. 91 | | 92 | | The expire time is the number of minutes that the reset token should be 93 | | considered valid. This security feature keeps tokens short-lived so 94 | | they have less time to be guessed. You may change this as needed. 95 | | 96 | */ 97 | 98 | 'passwords' => [ 99 | 'users' => [ 100 | 'provider' => 'users', 101 | 'email' => 'auth.emails.password', 102 | 'table' => 'password_resets', 103 | 'expire' => 60, 104 | ], 105 | ], 106 | 107 | ]; 108 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'pusher'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_KEY'), 36 | 'secret' => env('PUSHER_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | // 40 | ], 41 | ], 42 | 43 | 'redis' => [ 44 | 'driver' => 'redis', 45 | 'connection' => 'default', 46 | ], 47 | 48 | 'log' => [ 49 | 'driver' => 'log', 50 | ], 51 | 52 | ], 53 | 54 | ]; 55 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Cache Stores 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the cache "stores" for your application as 26 | | well as their drivers. You may even define multiple stores for the 27 | | same cache driver to group types of items stored in your caches. 28 | | 29 | */ 30 | 31 | 'stores' => [ 32 | 33 | 'apc' => [ 34 | 'driver' => 'apc', 35 | ], 36 | 37 | 'array' => [ 38 | 'driver' => 'array', 39 | ], 40 | 41 | 'database' => [ 42 | 'driver' => 'database', 43 | 'table' => 'cache', 44 | 'connection' => null, 45 | ], 46 | 47 | 'file' => [ 48 | 'driver' => 'file', 49 | 'path' => storage_path('framework/cache'), 50 | ], 51 | 52 | 'memcached' => [ 53 | 'driver' => 'memcached', 54 | 'servers' => [ 55 | [ 56 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 57 | 'port' => env('MEMCACHED_PORT', 11211), 58 | 'weight' => 100, 59 | ], 60 | ], 61 | ], 62 | 63 | 'redis' => [ 64 | 'driver' => 'redis', 65 | 'connection' => 'default', 66 | ], 67 | 68 | ], 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Cache Key Prefix 73 | |-------------------------------------------------------------------------- 74 | | 75 | | When utilizing a RAM based store such as APC or Memcached, there might 76 | | be other applications utilizing the same cache. So, we'll specify a 77 | | value to get prefixed to all our keys so we can avoid collisions. 78 | | 79 | */ 80 | 81 | 'prefix' => 'laravel', 82 | 83 | ]; 84 | -------------------------------------------------------------------------------- /config/cas.php: -------------------------------------------------------------------------------- 1 | env('CAS_LOCK_TIMEOUT', 5000), 4 | 'ticket_expire' => env('CAS_TICKET_EXPIRE', 300), 5 | 'ticket_len' => env('CAS_TICKET_LEN', 32), 6 | 'allow_reset_pwd' => env('CAS_ALLOW_RESET_PWD', true), 7 | ]; -------------------------------------------------------------------------------- /config/compile.php: -------------------------------------------------------------------------------- 1 | [ 17 | // 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled File Providers 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may list service providers which define a "compiles" function 26 | | that returns additional files that should be compiled, providing an 27 | | easy way to get common files from any packages you are utilizing. 28 | | 29 | */ 30 | 31 | 'providers' => [ 32 | // 33 | ], 34 | 35 | ]; 36 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | PDO::FETCH_CLASS, 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Default Database Connection Name 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may specify which of the database connections below you wish 24 | | to use as your default connection for all database work. Of course 25 | | you may use many connections at once using the Database library. 26 | | 27 | */ 28 | 29 | 'default' => env('DB_CONNECTION', 'mysql'), 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Database Connections 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Here are each of the database connections setup for your application. 37 | | Of course, examples of configuring each database platform that is 38 | | supported by Laravel is shown below to make development simple. 39 | | 40 | | 41 | | All database work in Laravel is done through the PHP PDO facilities 42 | | so make sure you have the driver for your particular database of 43 | | choice installed on your machine before you begin development. 44 | | 45 | */ 46 | 47 | 'connections' => [ 48 | 49 | 'sqlite' => [ 50 | 'driver' => 'sqlite', 51 | 'database' => env('DB_DATABASE', database_path('database.sqlite')), 52 | 'prefix' => '', 53 | ], 54 | 55 | 'mysql' => [ 56 | 'driver' => 'mysql', 57 | 'host' => env('DB_HOST', 'localhost'), 58 | 'port' => env('DB_PORT', '3306'), 59 | 'database' => env('DB_DATABASE', 'forge'), 60 | 'username' => env('DB_USERNAME', 'forge'), 61 | 'password' => env('DB_PASSWORD', ''), 62 | 'charset' => 'utf8', 63 | 'collation' => 'utf8_unicode_ci', 64 | 'prefix' => '', 65 | 'strict' => false, 66 | 'engine' => null, 67 | ], 68 | 69 | 'pgsql' => [ 70 | 'driver' => 'pgsql', 71 | 'host' => env('DB_HOST', 'localhost'), 72 | 'port' => env('DB_PORT', '5432'), 73 | 'database' => env('DB_DATABASE', 'forge'), 74 | 'username' => env('DB_USERNAME', 'forge'), 75 | 'password' => env('DB_PASSWORD', ''), 76 | 'charset' => 'utf8', 77 | 'prefix' => '', 78 | 'schema' => 'public', 79 | ], 80 | 81 | ], 82 | 83 | /* 84 | |-------------------------------------------------------------------------- 85 | | Migration Repository Table 86 | |-------------------------------------------------------------------------- 87 | | 88 | | This table keeps track of all the migrations that have already run for 89 | | your application. Using this information, we can determine which of 90 | | the migrations on disk haven't actually been run in the database. 91 | | 92 | */ 93 | 94 | 'migrations' => 'migrations', 95 | 96 | /* 97 | |-------------------------------------------------------------------------- 98 | | Redis Databases 99 | |-------------------------------------------------------------------------- 100 | | 101 | | Redis is an open source, fast, and advanced key-value store that also 102 | | provides a richer set of commands than a typical key-value systems 103 | | such as APC or Memcached. Laravel makes it easy to dig right in. 104 | | 105 | */ 106 | 107 | 'redis' => [ 108 | 109 | 'cluster' => false, 110 | 111 | 'default' => [ 112 | 'host' => env('REDIS_HOST', 'localhost'), 113 | 'password' => env('REDIS_PASSWORD', null), 114 | 'port' => env('REDIS_PORT', 6379), 115 | 'database' => 0, 116 | ], 117 | 118 | ], 119 | 120 | ]; 121 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | 'local', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Default Cloud Filesystem Disk 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Many applications store files both locally and in the cloud. For this 26 | | reason, you may specify a default "cloud" driver here. This driver 27 | | will be bound as the Cloud disk implementation in the container. 28 | | 29 | */ 30 | 31 | 'cloud' => 's3', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Filesystem Disks 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Here you may configure as many filesystem "disks" as you wish, and you 39 | | may even configure multiple disks of the same driver. Defaults have 40 | | been setup for each driver as an example of the required options. 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'visibility' => 'public', 55 | ], 56 | 57 | 's3' => [ 58 | 'driver' => 's3', 59 | 'key' => 'your-key', 60 | 'secret' => 'your-secret', 61 | 'region' => 'your-region', 62 | 'bucket' => 'your-bucket', 63 | ], 64 | 65 | ], 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /config/mail.php: -------------------------------------------------------------------------------- 1 | env('MAIL_DRIVER', 'smtp'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | SMTP Host Address 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may provide the host address of the SMTP server used by your 27 | | applications. A default option is provided that is compatible with 28 | | the Mailgun mail service which will provide reliable deliveries. 29 | | 30 | */ 31 | 32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | SMTP Host Port 37 | |-------------------------------------------------------------------------- 38 | | 39 | | This is the SMTP port used by your application to deliver e-mails to 40 | | users of the application. Like the host we have set this value to 41 | | stay compatible with the Mailgun e-mail application by default. 42 | | 43 | */ 44 | 45 | 'port' => env('MAIL_PORT', 587), 46 | 47 | /* 48 | |-------------------------------------------------------------------------- 49 | | Global "From" Address 50 | |-------------------------------------------------------------------------- 51 | | 52 | | You may wish for all e-mails sent by your application to be sent from 53 | | the same address. Here, you may specify a name and address that is 54 | | used globally for all e-mails that are sent by your application. 55 | | 56 | */ 57 | 58 | 'from' => ['address' => null, 'name' => null], 59 | 60 | /* 61 | |-------------------------------------------------------------------------- 62 | | E-Mail Encryption Protocol 63 | |-------------------------------------------------------------------------- 64 | | 65 | | Here you may specify the encryption protocol that should be used when 66 | | the application send e-mail messages. A sensible default using the 67 | | transport layer security protocol should provide great security. 68 | | 69 | */ 70 | 71 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 72 | 73 | /* 74 | |-------------------------------------------------------------------------- 75 | | SMTP Server Username 76 | |-------------------------------------------------------------------------- 77 | | 78 | | If your SMTP server requires a username for authentication, you should 79 | | set it here. This will get used to authenticate with your server on 80 | | connection. You may also set the "password" value below this one. 81 | | 82 | */ 83 | 84 | 'username' => env('MAIL_USERNAME'), 85 | 86 | /* 87 | |-------------------------------------------------------------------------- 88 | | SMTP Server Password 89 | |-------------------------------------------------------------------------- 90 | | 91 | | Here you may set the password required by your SMTP server to send out 92 | | messages from your application. This will be given to the server on 93 | | connection so that the application will be able to send messages. 94 | | 95 | */ 96 | 97 | 'password' => env('MAIL_PASSWORD'), 98 | 99 | /* 100 | |-------------------------------------------------------------------------- 101 | | Sendmail System Path 102 | |-------------------------------------------------------------------------- 103 | | 104 | | When using the "sendmail" driver to send e-mails, we will need to know 105 | | the path to where Sendmail lives on this server. A default path has 106 | | been provided here, which will work well on most of your systems. 107 | | 108 | */ 109 | 110 | 'sendmail' => '/usr/sbin/sendmail -bs', 111 | 112 | ]; 113 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'expire' => 90, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'ttr' => 90, 49 | ], 50 | 51 | 'sqs' => [ 52 | 'driver' => 'sqs', 53 | 'key' => 'your-public-key', 54 | 'secret' => 'your-secret-key', 55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', 56 | 'queue' => 'your-queue-name', 57 | 'region' => 'us-east-1', 58 | ], 59 | 60 | 'redis' => [ 61 | 'driver' => 'redis', 62 | 'connection' => 'default', 63 | 'queue' => 'default', 64 | 'expire' => 90, 65 | ], 66 | 67 | ], 68 | 69 | /* 70 | |-------------------------------------------------------------------------- 71 | | Failed Queue Jobs 72 | |-------------------------------------------------------------------------- 73 | | 74 | | These options configure the behavior of failed queue job logging so you 75 | | can control which database and table are used to store the jobs that 76 | | have failed. You may change them to any database / table you wish. 77 | | 78 | */ 79 | 80 | 'failed' => [ 81 | 'database' => env('DB_CONNECTION', 'mysql'), 82 | 'table' => 'failed_jobs', 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'mandrill' => [ 23 | 'secret' => env('MANDRILL_SECRET'), 24 | ], 25 | 26 | 'ses' => [ 27 | 'key' => env('SES_KEY'), 28 | 'secret' => env('SES_SECRET'), 29 | 'region' => 'us-east-1', 30 | ], 31 | 32 | 'sparkpost' => [ 33 | 'secret' => env('SPARKPOST_SECRET'), 34 | ], 35 | 36 | 'stripe' => [ 37 | 'model' => App\User::class, 38 | 'key' => env('STRIPE_KEY'), 39 | 'secret' => env('STRIPE_SECRET'), 40 | ], 41 | 42 | ]; 43 | -------------------------------------------------------------------------------- /config/session.php: -------------------------------------------------------------------------------- 1 | env('SESSION_DRIVER', 'file'), 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Session Lifetime 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify the number of minutes that you wish the session 27 | | to be allowed to remain idle before it expires. If you want them 28 | | to immediately expire on the browser closing, set that option. 29 | | 30 | */ 31 | 32 | 'lifetime' => 120, 33 | 34 | 'expire_on_close' => false, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Session Encryption 39 | |-------------------------------------------------------------------------- 40 | | 41 | | This option allows you to easily specify that all of your session data 42 | | should be encrypted before it is stored. All encryption will be run 43 | | automatically by Laravel and you can use the Session like normal. 44 | | 45 | */ 46 | 47 | 'encrypt' => false, 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Session File Location 52 | |-------------------------------------------------------------------------- 53 | | 54 | | When using the native session driver, we need a location where session 55 | | files may be stored. A default has been set for you but a different 56 | | location may be specified. This is only needed for file sessions. 57 | | 58 | */ 59 | 60 | 'files' => storage_path('framework/sessions'), 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Session Database Connection 65 | |-------------------------------------------------------------------------- 66 | | 67 | | When using the "database" or "redis" session drivers, you may specify a 68 | | connection that should be used to manage these sessions. This should 69 | | correspond to a connection in your database configuration options. 70 | | 71 | */ 72 | 73 | 'connection' => null, 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Session Database Table 78 | |-------------------------------------------------------------------------- 79 | | 80 | | When using the "database" session driver, you may specify the table we 81 | | should use to manage the sessions. Of course, a sensible default is 82 | | provided for you; however, you are free to change this as needed. 83 | | 84 | */ 85 | 86 | 'table' => 'sessions', 87 | 88 | /* 89 | |-------------------------------------------------------------------------- 90 | | Session Sweeping Lottery 91 | |-------------------------------------------------------------------------- 92 | | 93 | | Some session drivers must manually sweep their storage location to get 94 | | rid of old sessions from storage. Here are the chances that it will 95 | | happen on a given request. By default, the odds are 2 out of 100. 96 | | 97 | */ 98 | 99 | 'lottery' => [2, 100], 100 | 101 | /* 102 | |-------------------------------------------------------------------------- 103 | | Session Cookie Name 104 | |-------------------------------------------------------------------------- 105 | | 106 | | Here you may change the name of the cookie used to identify a session 107 | | instance by ID. The name specified here will get used every time a 108 | | new session cookie is created by the framework for every driver. 109 | | 110 | */ 111 | 112 | 'cookie' => 'laravel_session', 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | Session Cookie Path 117 | |-------------------------------------------------------------------------- 118 | | 119 | | The session cookie path determines the path for which the cookie will 120 | | be regarded as available. Typically, this will be the root path of 121 | | your application but you are free to change this when necessary. 122 | | 123 | */ 124 | 125 | 'path' => '/', 126 | 127 | /* 128 | |-------------------------------------------------------------------------- 129 | | Session Cookie Domain 130 | |-------------------------------------------------------------------------- 131 | | 132 | | Here you may change the domain of the cookie used to identify a session 133 | | in your application. This will determine which domains the cookie is 134 | | available to in your application. A sensible default has been set. 135 | | 136 | */ 137 | 138 | 'domain' => env('SESSION_DOMAIN', null), 139 | 140 | /* 141 | |-------------------------------------------------------------------------- 142 | | HTTPS Only Cookies 143 | |-------------------------------------------------------------------------- 144 | | 145 | | By setting this option to true, session cookies will only be sent back 146 | | to the server if the browser has a HTTPS connection. This will keep 147 | | the cookie from being sent to you if it can not be done securely. 148 | | 149 | */ 150 | 151 | 'secure' => false, 152 | 153 | /* 154 | |-------------------------------------------------------------------------- 155 | | HTTP Access Only 156 | |-------------------------------------------------------------------------- 157 | | 158 | | Setting this value to true will prevent JavaScript from accessing the 159 | | value of the cookie and the cookie will only be accessible through 160 | | the HTTP protocol. You are free to modify this option if needed. 161 | | 162 | */ 163 | 164 | 'http_only' => true, 165 | 166 | ]; 167 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | realpath(base_path('resources/views')), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/factories/ModelFactory.php: -------------------------------------------------------------------------------- 1 | define(App\User::class, function (Faker\Generator $faker) { 15 | return [ 16 | 'name' => $faker->name, 17 | 'email' => $faker->safeEmail, 18 | 'password' => bcrypt(str_random(10)), 19 | 'remember_token' => str_random(10), 20 | ]; 21 | }); 22 | -------------------------------------------------------------------------------- /database/migrations/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name')->unique(); 18 | $table->string('real_name'); 19 | $table->string('email')->unique(); 20 | $table->string('password'); 21 | $table->boolean('enabled')->default(true); 22 | $table->boolean('admin')->default(false); 23 | $table->rememberToken(); 24 | $table->timestamps(); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::drop('users'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 17 | $table->string('token')->index(); 18 | $table->timestamp('created_at')->nullable(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('password_resets'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_08_01_061914_create_services_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name')->unique(); 18 | $table->boolean('enabled')->default(true); 19 | $table->timestamp('created_at')->nullable(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::drop('services'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/migrations/2016_08_01_061918_create_tickets_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('ticket', 32)->unique(); 18 | $table->string('service_url', 1024); 19 | $table->integer('service_id')->unsigned(); 20 | $table->integer('user_id')->unsigned(); 21 | $table->timestamp('created_at')->nullable(); 22 | $table->timestamp('expire_at')->nullable(); 23 | $table->foreign('service_id')->references('id')->on('services'); 24 | $table->foreign('user_id')->references('id')->on('users'); 25 | }); 26 | } 27 | 28 | /** 29 | * Reverse the migrations. 30 | * 31 | * @return void 32 | */ 33 | public function down() 34 | { 35 | Schema::drop('tickets'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /database/migrations/2016_08_01_061923_create_service_hosts_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('host')->unique(); 18 | $table->integer('service_id')->unsigned(); 19 | $table->foreign('service_id')->references('id')->on('services'); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | * 26 | * @return void 27 | */ 28 | public function down() 29 | { 30 | Schema::drop('service_hosts'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /database/seeds/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | ./tests 14 | 15 | 16 | 17 | 18 | ./app 19 | 20 | ./app/Http/routes.php 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Redirect Trailing Slashes If Not A Folder... 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteRule ^(.*)/$ /$1 [L,R=301] 11 | 12 | # Handle Front Controller... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_FILENAME} !-f 15 | RewriteRule ^ index.php [L] 16 | 17 | # Handle Authorization Header 18 | RewriteCond %{HTTP:Authorization} . 19 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 20 | 21 | -------------------------------------------------------------------------------- /public/css/metisMenu.min.css: -------------------------------------------------------------------------------- 1 | /* 2 | * metismenu - v1.1.3 3 | * Easy menu jQuery plugin for Twitter Bootstrap 3 4 | * https://github.com/onokumus/metisMenu 5 | * 6 | * Made by Osman Nuri Okumus 7 | * Under MIT License 8 | */ 9 | 10 | .arrow{float:right;line-height:1.42857}.glyphicon.arrow:before{content:"\e079"}.active>a>.glyphicon.arrow:before{content:"\e114"}.fa.arrow:before{content:"\f104"}.active>a>.fa.arrow:before{content:"\f107"}.plus-times{float:right}.fa.plus-times:before{content:"\f067"}.active>a>.fa.plus-times{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}.plus-minus{float:right}.fa.plus-minus:before{content:"\f067"}.active>a>.fa.plus-minus:before{content:"\f068"} -------------------------------------------------------------------------------- /public/css/sb-admin-2.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Start Bootstrap - SB Admin 2 Bootstrap Admin Theme (http://startbootstrap.com) 3 | * Code licensed under the Apache License v2.0. 4 | * For details, see http://www.apache.org/licenses/LICENSE-2.0. 5 | */ 6 | 7 | body { 8 | background-color: #f8f8f8; 9 | } 10 | 11 | #wrapper { 12 | width: 100%; 13 | } 14 | 15 | #page-wrapper { 16 | padding: 0 15px; 17 | min-height: 568px; 18 | background-color: #fff; 19 | } 20 | 21 | @media(min-width:768px) { 22 | #page-wrapper { 23 | position: inherit; 24 | margin: 0 0 0 250px; 25 | padding: 0 30px; 26 | border-left: 1px solid #e7e7e7; 27 | } 28 | } 29 | 30 | .navbar-top-links { 31 | margin-right: 0; 32 | } 33 | 34 | .navbar-top-links li { 35 | display: inline-block; 36 | } 37 | 38 | .navbar-top-links li:last-child { 39 | margin-right: 15px; 40 | } 41 | 42 | .navbar-top-links li a { 43 | padding: 15px; 44 | min-height: 50px; 45 | } 46 | 47 | .navbar-top-links .dropdown-menu li { 48 | display: block; 49 | } 50 | 51 | .navbar-top-links .dropdown-menu li:last-child { 52 | margin-right: 0; 53 | } 54 | 55 | .navbar-top-links .dropdown-menu li a { 56 | padding: 3px 20px; 57 | min-height: 0; 58 | } 59 | 60 | .navbar-top-links .dropdown-menu li a div { 61 | white-space: normal; 62 | } 63 | 64 | .navbar-top-links .dropdown-messages, 65 | .navbar-top-links .dropdown-tasks, 66 | .navbar-top-links .dropdown-alerts { 67 | width: 310px; 68 | min-width: 0; 69 | } 70 | 71 | .navbar-top-links .dropdown-messages { 72 | margin-left: 5px; 73 | } 74 | 75 | .navbar-top-links .dropdown-tasks { 76 | margin-left: -59px; 77 | } 78 | 79 | .navbar-top-links .dropdown-alerts { 80 | margin-left: -123px; 81 | } 82 | 83 | .navbar-top-links .dropdown-user { 84 | right: 0; 85 | left: auto; 86 | } 87 | 88 | .sidebar .sidebar-nav.navbar-collapse { 89 | padding-right: 0; 90 | padding-left: 0; 91 | } 92 | 93 | .sidebar .sidebar-search { 94 | padding: 15px; 95 | } 96 | 97 | .sidebar ul li { 98 | border-bottom: 1px solid #e7e7e7; 99 | } 100 | 101 | .sidebar ul li a.active { 102 | background-color: #eee; 103 | } 104 | 105 | .sidebar .arrow { 106 | float: right; 107 | } 108 | 109 | .sidebar .fa.arrow:before { 110 | content: "\f104"; 111 | } 112 | 113 | .sidebar .active>a>.fa.arrow:before { 114 | content: "\f107"; 115 | } 116 | 117 | .sidebar .nav-second-level li, 118 | .sidebar .nav-third-level li { 119 | border-bottom: 0!important; 120 | } 121 | 122 | .sidebar .nav-second-level li a { 123 | padding-left: 37px; 124 | } 125 | 126 | .sidebar .nav-third-level li a { 127 | padding-left: 52px; 128 | } 129 | 130 | @media(min-width:768px) { 131 | .sidebar { 132 | z-index: 1; 133 | position: absolute; 134 | width: 250px; 135 | margin-top: 51px; 136 | } 137 | 138 | .navbar-top-links .dropdown-messages, 139 | .navbar-top-links .dropdown-tasks, 140 | .navbar-top-links .dropdown-alerts { 141 | margin-left: auto; 142 | } 143 | } 144 | 145 | .btn-outline { 146 | color: inherit; 147 | background-color: transparent; 148 | transition: all .5s; 149 | } 150 | 151 | .btn-primary.btn-outline { 152 | color: #428bca; 153 | } 154 | 155 | .btn-success.btn-outline { 156 | color: #5cb85c; 157 | } 158 | 159 | .btn-info.btn-outline { 160 | color: #5bc0de; 161 | } 162 | 163 | .btn-warning.btn-outline { 164 | color: #f0ad4e; 165 | } 166 | 167 | .btn-danger.btn-outline { 168 | color: #d9534f; 169 | } 170 | 171 | .btn-primary.btn-outline:hover, 172 | .btn-success.btn-outline:hover, 173 | .btn-info.btn-outline:hover, 174 | .btn-warning.btn-outline:hover, 175 | .btn-danger.btn-outline:hover { 176 | color: #fff; 177 | } 178 | 179 | .chat { 180 | margin: 0; 181 | padding: 0; 182 | list-style: none; 183 | } 184 | 185 | .chat li { 186 | margin-bottom: 10px; 187 | padding-bottom: 5px; 188 | border-bottom: 1px dotted #999; 189 | } 190 | 191 | .chat li.left .chat-body { 192 | margin-left: 60px; 193 | } 194 | 195 | .chat li.right .chat-body { 196 | margin-right: 60px; 197 | } 198 | 199 | .chat li .chat-body p { 200 | margin: 0; 201 | } 202 | 203 | .panel .slidedown .glyphicon, 204 | .chat .glyphicon { 205 | margin-right: 5px; 206 | } 207 | 208 | .chat-panel .panel-body { 209 | height: 350px; 210 | overflow-y: scroll; 211 | } 212 | 213 | .login-panel { 214 | margin-top: 25%; 215 | } 216 | 217 | .flot-chart { 218 | display: block; 219 | height: 400px; 220 | } 221 | 222 | .flot-chart-content { 223 | width: 100%; 224 | height: 100%; 225 | } 226 | 227 | .dataTables_wrapper { 228 | position: relative; 229 | clear: both; 230 | } 231 | 232 | table.dataTable thead .sorting, 233 | table.dataTable thead .sorting_asc, 234 | table.dataTable thead .sorting_desc, 235 | table.dataTable thead .sorting_asc_disabled, 236 | table.dataTable thead .sorting_desc_disabled { 237 | background: 0 0; 238 | } 239 | 240 | table.dataTable thead .sorting_asc:after { 241 | content: "\f0de"; 242 | float: right; 243 | font-family: fontawesome; 244 | } 245 | 246 | table.dataTable thead .sorting_desc:after { 247 | content: "\f0dd"; 248 | float: right; 249 | font-family: fontawesome; 250 | } 251 | 252 | table.dataTable thead .sorting:after { 253 | content: "\f0dc"; 254 | float: right; 255 | font-family: fontawesome; 256 | color: rgba(50,50,50,.5); 257 | } 258 | 259 | .btn-circle { 260 | width: 30px; 261 | height: 30px; 262 | padding: 6px 0; 263 | border-radius: 15px; 264 | text-align: center; 265 | font-size: 12px; 266 | line-height: 1.428571429; 267 | } 268 | 269 | .btn-circle.btn-lg { 270 | width: 50px; 271 | height: 50px; 272 | padding: 10px 16px; 273 | border-radius: 25px; 274 | font-size: 18px; 275 | line-height: 1.33; 276 | } 277 | 278 | .btn-circle.btn-xl { 279 | width: 70px; 280 | height: 70px; 281 | padding: 10px 16px; 282 | border-radius: 35px; 283 | font-size: 24px; 284 | line-height: 1.33; 285 | } 286 | 287 | .show-grid [class^=col-] { 288 | padding-top: 10px; 289 | padding-bottom: 10px; 290 | border: 1px solid #ddd; 291 | background-color: #eee!important; 292 | } 293 | 294 | .show-grid { 295 | margin: 15px 0; 296 | } 297 | 298 | .huge { 299 | font-size: 40px; 300 | } 301 | 302 | .panel-green { 303 | border-color: #5cb85c; 304 | } 305 | 306 | .panel-green .panel-heading { 307 | border-color: #5cb85c; 308 | color: #fff; 309 | background-color: #5cb85c; 310 | } 311 | 312 | .panel-green a { 313 | color: #5cb85c; 314 | } 315 | 316 | .panel-green a:hover { 317 | color: #3d8b3d; 318 | } 319 | 320 | .panel-red { 321 | border-color: #d9534f; 322 | } 323 | 324 | .panel-red .panel-heading { 325 | border-color: #d9534f; 326 | color: #fff; 327 | background-color: #d9534f; 328 | } 329 | 330 | .panel-red a { 331 | color: #d9534f; 332 | } 333 | 334 | .panel-red a:hover { 335 | color: #b52b27; 336 | } 337 | 338 | .panel-yellow { 339 | border-color: #f0ad4e; 340 | } 341 | 342 | .panel-yellow .panel-heading { 343 | border-color: #f0ad4e; 344 | color: #fff; 345 | background-color: #f0ad4e; 346 | } 347 | 348 | .panel-yellow a { 349 | color: #f0ad4e; 350 | } 351 | 352 | .panel-yellow a:hover { 353 | color: #df8a13; 354 | } -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/favicon.ico -------------------------------------------------------------------------------- /public/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /public/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /public/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /public/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /public/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/leo108/simple_cas_server/5e146657e702a8f05c1282aa33b51906c7357fdb/public/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | /* 11 | |-------------------------------------------------------------------------- 12 | | Register The Auto Loader 13 | |-------------------------------------------------------------------------- 14 | | 15 | | Composer provides a convenient, automatically generated class loader for 16 | | our application. We just need to utilize it! We'll simply require it 17 | | into the script here so that we don't have to worry about manual 18 | | loading any of our classes later on. It feels nice to relax. 19 | | 20 | */ 21 | 22 | require __DIR__.'/../bootstrap/autoload.php'; 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Turn On The Lights 27 | |-------------------------------------------------------------------------- 28 | | 29 | | We need to illuminate PHP development, so let us turn on the lights. 30 | | This bootstraps the framework and gets it ready for use, then it 31 | | will load up this application so that we can run it and send 32 | | the responses back to the browser and delight our users. 33 | | 34 | */ 35 | 36 | $app = require_once __DIR__.'/../bootstrap/app.php'; 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Run The Application 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Once we have the application, we can handle the incoming request 44 | | through the kernel, and send the associated response back to 45 | | the client's browser allowing them to enjoy the creative 46 | | and wonderful application we have prepared for them. 47 | | 48 | */ 49 | 50 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); 51 | 52 | $response = $kernel->handle( 53 | $request = Illuminate\Http\Request::capture() 54 | ); 55 | 56 | $response->send(); 57 | 58 | $kernel->terminate($request, $response); 59 | -------------------------------------------------------------------------------- /public/js/metisMenu.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * metismenu - v1.1.3 3 | * Easy menu jQuery plugin for Twitter Bootstrap 3 4 | * https://github.com/onokumus/metisMenu 5 | * 6 | * Made by Osman Nuri Okumus 7 | * Under MIT License 8 | */ 9 | !function(a,b,c){function d(b,c){this.element=a(b),this.settings=a.extend({},f,c),this._defaults=f,this._name=e,this.init()}var e="metisMenu",f={toggle:!0,doubleTapToGo:!1};d.prototype={init:function(){var b=this.element,d=this.settings.toggle,f=this;this.isIE()<=9?(b.find("li.active").has("ul").children("ul").collapse("show"),b.find("li").not(".active").has("ul").children("ul").collapse("hide")):(b.find("li.active").has("ul").children("ul").addClass("collapse in"),b.find("li").not(".active").has("ul").children("ul").addClass("collapse")),f.settings.doubleTapToGo&&b.find("li.active").has("ul").children("a").addClass("doubleTapToGo"),b.find("li").has("ul").children("a").on("click."+e,function(b){return b.preventDefault(),f.settings.doubleTapToGo&&f.doubleTapToGo(a(this))&&"#"!==a(this).attr("href")&&""!==a(this).attr("href")?(b.stopPropagation(),void(c.location=a(this).attr("href"))):(a(this).parent("li").toggleClass("active").children("ul").collapse("toggle"),void(d&&a(this).parent("li").siblings().removeClass("active").children("ul.in").collapse("hide")))})},isIE:function(){for(var a,b=3,d=c.createElement("div"),e=d.getElementsByTagName("i");d.innerHTML="",e[0];)return b>4?b:a},doubleTapToGo:function(a){var b=this.element;return a.hasClass("doubleTapToGo")?(a.removeClass("doubleTapToGo"),!0):a.parent().children("ul").length?(b.find(".doubleTapToGo").removeClass("doubleTapToGo"),a.addClass("doubleTapToGo"),!1):void 0},remove:function(){this.element.off("."+e),this.element.removeData(e)}},a.fn[e]=function(b){return this.each(function(){var c=a(this);c.data(e)&&c.data(e).remove(),c.data(e,new d(this,b))}),this}}(jQuery,window,document); -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /public/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Simple Cas Server 2 | 3 | [![Build Status](https://travis-ci.org/leo108/simple_cas_server.svg)](https://travis-ci.org/leo108/simple_cas_server) 4 | 5 | A simple PHP implement of CAS server 6 | 7 | This project is deprecated, please refer to [laravel_cas_server](https://github.com/leo108/laravel_cas_server) and [php_cas_server](https://github.com/leo108/php_cas_server) 8 | 9 | ## Features 10 | 11 | * [CAS protocol](https://apereo.github.io/cas/4.2.x/protocol/CAS-Protocol-Specification.html) v1/v2/v3 without proxy 12 | * Users/Services Management 13 | 14 | ## Requirements 15 | 16 | * PHP 5.5.9+ 17 | * [composer](https://getcomposer.org/) 18 | * npm 19 | * gulp 20 | 21 | ## Installation 22 | 23 | 1. git clone https://github.com/leo108/simple_cas_server 24 | 2. cd simple_cas_server 25 | 3. composer install 26 | 4. npm install 27 | 5. gulp 28 | 29 | ## Basic Usage 30 | 31 | 1. Edit `.env` file in the project's root directory, change the options's value that start with `DB_` 32 | 2. ./artisan migrate 33 | 3. ./artisan db:seed 34 | 4. ./artisan serve 35 | 5. visit [http://localhost:8000](http://localhost:8000), login with `admin`/`secret` 36 | 37 | ## Configuration 38 | 39 | All configurations are set in `.env` file 40 | 41 | ### Application Settings 42 | 43 | `APP_LOCATE`: application Language, `en` | `cn` 44 | 45 | ### CAS Settings 46 | 47 | `CAS_ALLOW_RESET_PWD`: allow user reset password by email, `true` | `false`. if set to `true`, you should configure mail sending options 48 | 49 | `CAS_TICKET_LEN`: ticket length 50 | 51 | `CAS_TICKET_EXPIRE`: ticket ttl, time in seconds 52 | 53 | `CAS_LOCK_TIMEOUT`: lock time while validating a ticket, time in microseconds 54 | 55 | ## Todo 56 | 57 | * reset password by email 58 | * log user login history 59 | * event hook 60 | * gui installation 61 | * tar ball release 62 | 63 | ## License 64 | 65 | [MIT](http://opensource.org/licenses/MIT) 66 | -------------------------------------------------------------------------------- /resources/lang/cn/admin.php: -------------------------------------------------------------------------------- 1 | '系统管理', 4 | 'back_to_front' => '返回前台', 5 | 'menu' => [ 6 | 'dashboard' => '仪表盘', 7 | 'users' => '用户', 8 | 'services' => '服务', 9 | ], 10 | 'dashboard' => [ 11 | 'view_details' => '查看详情', 12 | 'user_total' => '用户数', 13 | 'service_total' => '服务数', 14 | 'service_enabled' => '启用数', 15 | 'user_active' => '启用数', 16 | 'user_admin' => '管理员数', 17 | ], 18 | 'user' => [ 19 | 'username' => '用户名', 20 | 'password' => '密码', 21 | 'email' => '邮箱', 22 | 'real_name' => '真实姓名', 23 | 'enabled' => '是否启用', 24 | 'admin' => '是否管理员', 25 | 'created_at' => '创建时间', 26 | 'updated_at' => '更新时间', 27 | 'add' => '添加用户', 28 | 'add_or_edit' => '添加/编辑用户', 29 | 'add_ok' => '添加用户成功', 30 | 'edit_ok' => '编辑用户成功', 31 | 'enabled_all' => '全部', 32 | 'enabled_yes' => '启用', 33 | 'enabled_no' => '禁用', 34 | ], 35 | 'service' => [ 36 | 'add_or_edit' => '添加/编辑服务', 37 | 'name' => '服务名称', 38 | 'hosts' => '域名', 39 | 'enabled' => '是否启用', 40 | 'created_at' => '创建时间', 41 | 'add' => '添加服务', 42 | 'hosts_placeholder' => '一行一个', 43 | 'add_ok' => '添加服务成功', 44 | 'edit_ok' => '编辑服务成功', 45 | ], 46 | 'operation' => '操作', 47 | 'edit' => '编辑', 48 | 'search' => '搜索', 49 | 'total' => '总计: ', 50 | ]; 51 | -------------------------------------------------------------------------------- /resources/lang/cn/auth.php: -------------------------------------------------------------------------------- 1 | '账号密码不匹配', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 'username' => '用户名', 19 | 'password' => '密码', 20 | 'remember_me' => '保持登录', 21 | 'logout' => '注销', 22 | 'logged_in_as' => '你已登录为 :name', 23 | 'change_pwd' => '修改密码', 24 | 'old_pwd' => '旧密码', 25 | 'new_pwd' => '新密码', 26 | 'new_pwd2' => '重复密码', 27 | 'need_login' => '请先登录', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/cn/common.php: -------------------------------------------------------------------------------- 1 | '提交', 4 | 'ok' => '确认', 5 | 'abort' => '放弃', 6 | 'cancel' => '取消', 7 | 'confirm' => '确认', 8 | 'close' => '关闭', 9 | 'yes' => '是', 10 | 'no' => '否', 11 | ]; -------------------------------------------------------------------------------- /resources/lang/cn/message.php: -------------------------------------------------------------------------------- 1 | '确认要注销登录?', 4 | 'cas_redirect_warn' => '即将跳转到 :url', 5 | 'invalid_old_pwd' => '旧密码不正确', 6 | 'change_pwd_ok' => '密码修改成功', 7 | 'user' => [ 8 | 'not_exists' => '该用户不存在', 9 | 'name_duplicated' => '该用户名已被占用', 10 | 'email_duplicated' => '该邮箱地址已被占用', 11 | ], 12 | 'service' => [ 13 | 'name_duplicated' => '该服务名已被占用', 14 | 'host_occupied' => '域名 :host 已被其他服务占用', 15 | ], 16 | ]; -------------------------------------------------------------------------------- /resources/lang/cn/pagination.php: -------------------------------------------------------------------------------- 1 | '« 上一页', 17 | 'next' => '下一页 »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/cn/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => '密码修改成功', 18 | 'sent' => '密码重置邮件已经发送到你的邮箱', 19 | 'token' => '重置链接无效', 20 | 'user' => "该邮箱尚未注册", 21 | 'forget_pwd' => '忘记密码', 22 | 'reset_pwd' => '重置密码', 23 | 'email' => '邮箱地址', 24 | 'email_subject' => '密码重置链接', 25 | 'email_content' => '点击链接重置密码', 26 | ]; 27 | -------------------------------------------------------------------------------- /resources/lang/cn/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => ':attribute 不是一个合法的网址', 18 | 'after' => ':attribute 必须晚于 :date.', 19 | 'alpha' => ':attribute 只允许包含字母', 20 | 'alpha_dash' => ':attribute 只允许包含字母、数字、-和_', 21 | 'alpha_num' => ':attribute 只允许包含字母和数字', 22 | 'array' => ':attribute 必须是一个数组', 23 | 'before' => ':attribute 必须早于 :date.', 24 | 'between' => [ 25 | 'numeric' => 'The :attribute must be between :min and :max.', 26 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 27 | 'string' => 'The :attribute must be between :min and :max characters.', 28 | 'array' => 'The :attribute must have between :min and :max items.', 29 | ], 30 | 'boolean' => ':attribute 必须是 true 或 false.', 31 | 'confirmed' => '新旧 :attribute 不匹配', 32 | 'date' => ':attribute 不是一个合法的日期', 33 | 'date_format' => ':attribute 不符合日期格式 :format.', 34 | 'different' => ':attribute 和 :other 不能一致', 35 | 'digits' => ':attribute 的位数必须是 :digits 位', 36 | 'digits_between' => ':attribute 的位数必须在 :min 和 :max 之间', 37 | 'dimensions' => 'The :attribute has invalid image dimensions.', 38 | 'distinct' => 'The :attribute field has a duplicate value.', 39 | 'email' => ':attribute 必须是一个合法的邮箱地址.', 40 | 'exists' => 'The selected :attribute is invalid.', 41 | 'file' => 'The :attribute must be a file.', 42 | 'filled' => 'The :attribute field is required.', 43 | 'image' => 'The :attribute must be an image.', 44 | 'in' => 'The selected :attribute is invalid.', 45 | 'in_array' => 'The :attribute field does not exist in :other.', 46 | 'integer' => 'The :attribute must be an integer.', 47 | 'ip' => 'The :attribute must be a valid IP address.', 48 | 'json' => 'The :attribute must be a valid JSON string.', 49 | 'max' => [ 50 | 'numeric' => 'The :attribute may not be greater than :max.', 51 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 52 | 'string' => 'The :attribute may not be greater than :max characters.', 53 | 'array' => 'The :attribute may not have more than :max items.', 54 | ], 55 | 'mimes' => 'The :attribute must be a file of type: :values.', 56 | 'min' => [ 57 | 'numeric' => ':attribute 必须大于 :min.', 58 | 'file' => 'The :attribute must be at least :min kilobytes.', 59 | 'string' => ':attribute 至少需要 :min 个字符', 60 | 'array' => 'The :attribute must have at least :min items.', 61 | ], 62 | 'not_in' => 'The selected :attribute is invalid.', 63 | 'numeric' => 'The :attribute must be a number.', 64 | 'present' => 'The :attribute field must be present.', 65 | 'regex' => 'The :attribute format is invalid.', 66 | 'required' => '请填写 :attribute', 67 | 'required_if' => 'The :attribute field is required when :other is :value.', 68 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 69 | 'required_with' => 'The :attribute field is required when :values is present.', 70 | 'required_with_all' => 'The :attribute field is required when :values is present.', 71 | 'required_without' => 'The :attribute field is required when :values is not present.', 72 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 73 | 'same' => 'The :attribute and :other must match.', 74 | 'size' => [ 75 | 'numeric' => 'The :attribute must be :size.', 76 | 'file' => 'The :attribute must be :size kilobytes.', 77 | 'string' => 'The :attribute must be :size characters.', 78 | 'array' => 'The :attribute must contain :size items.', 79 | ], 80 | 'string' => 'The :attribute must be a string.', 81 | 'timezone' => 'The :attribute must be a valid zone.', 82 | 'unique' => 'The :attribute has already been taken.', 83 | 'url' => 'The :attribute format is invalid.', 84 | 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | Custom Validation Language Lines 88 | |-------------------------------------------------------------------------- 89 | | 90 | | Here you may specify custom validation messages for attributes using the 91 | | convention "attribute.rule" to name the lines. This makes it quick to 92 | | specify a specific custom language line for a given attribute rule. 93 | | 94 | */ 95 | 96 | 'custom' => [ 97 | 'attribute-name' => [ 98 | 'rule-name' => 'custom-message', 99 | ], 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Custom Validation Attributes 105 | |-------------------------------------------------------------------------- 106 | | 107 | | The following language lines are used to swap attribute place-holders 108 | | with something more reader friendly such as E-Mail Address instead 109 | | of "email". This simply helps us make messages a little cleaner. 110 | | 111 | */ 112 | 113 | 'attributes' => [], 114 | 115 | ]; 116 | -------------------------------------------------------------------------------- /resources/lang/en/admin.php: -------------------------------------------------------------------------------- 1 | 'System Manage', 4 | 'back_to_front' => 'Back To Front End', 5 | 'menu' => [ 6 | 'dashboard' => 'Dashboard', 7 | 'users' => 'Users', 8 | 'services' => 'Services', 9 | ], 10 | 'dashboard' => [ 11 | 'view_details' => 'View Details', 12 | 'user_total' => 'Users', 13 | 'service_total' => 'Service', 14 | 'service_enabled' => 'Enabled', 15 | 'user_active' => 'Active', 16 | 'user_admin' => 'Admin', 17 | ], 18 | 'user' => [ 19 | 'username' => 'User Name', 20 | 'password' => 'Password', 21 | 'email' => 'Email', 22 | 'real_name' => 'Real Name', 23 | 'enabled' => 'Enabled', 24 | 'admin' => 'Admin', 25 | 'created_at' => 'Created Time', 26 | 'updated_at' => 'Updated Time', 27 | 'add' => 'Add User', 28 | 'add_or_edit' => 'Add/Edit User', 29 | 'add_ok' => 'Add user successful', 30 | 'edit_ok' => 'Edit user successful', 31 | 'enabled_all' => 'All', 32 | 'enabled_yes' => 'Enabled', 33 | 'enabled_no' => 'Disabled', 34 | ], 35 | 'service' => [ 36 | 'add_or_edit' => 'Add/Edit Service', 37 | 'name' => 'Service Name', 38 | 'hosts' => 'Service Domain', 39 | 'enabled' => 'Enabled', 40 | 'created_at' => 'Created Time', 41 | 'add' => 'Add Service', 42 | 'hosts_placeholder' => 'One url per line', 43 | 'add_ok' => 'Add service successful', 44 | 'edit_ok' => 'Edit service successful', 45 | ], 46 | 'operation' => 'Operation', 47 | 'edit' => 'Edit', 48 | 'search' => 'Search', 49 | 'total' => 'Total: ', 50 | ]; 51 | -------------------------------------------------------------------------------- /resources/lang/en/auth.php: -------------------------------------------------------------------------------- 1 | 'These credentials do not match our records.', 17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', 18 | 'username' => 'User Name', 19 | 'password' => 'Password', 20 | 'remember_me' => 'Remember Me', 21 | 'logout' => 'Logout', 22 | 'logged_in_as' => 'You are logged in as :name', 23 | 'change_pwd' => 'Change Password', 24 | 'old_pwd' => 'Old Password', 25 | 'new_pwd' => 'New Password', 26 | 'new_pwd2' => 'Confirm New Password', 27 | 'need_login' => 'You need to login first', 28 | ]; 29 | -------------------------------------------------------------------------------- /resources/lang/en/common.php: -------------------------------------------------------------------------------- 1 | 'Submit', 4 | 'ok' => 'OK', 5 | 'abort' => 'Abort', 6 | 'cancel' => 'Cancel', 7 | 'confirm' => 'Confirm', 8 | 'close' => 'Close', 9 | 'yes' => 'Yes', 10 | 'no' => 'No', 11 | ]; -------------------------------------------------------------------------------- /resources/lang/en/message.php: -------------------------------------------------------------------------------- 1 | 'Confirm to logout ?', 4 | 'cas_redirect_warn' => 'Redirect to :url', 5 | 'invalid_old_pwd' => 'Your old password is invalid', 6 | 'change_pwd_ok' => 'Your password has been changed', 7 | 'user' => [ 8 | 'not_exists' => 'User not exists', 9 | 'name_duplicated' => 'Username duplicated', 10 | 'email_duplicated' => 'Email duplicated', 11 | ], 12 | 'service' => [ 13 | 'name_duplicated' => 'Service name duplicated', 14 | 'host_occupied' => 'Service host :host is occupied', 15 | ], 16 | ]; 17 | -------------------------------------------------------------------------------- /resources/lang/en/pagination.php: -------------------------------------------------------------------------------- 1 | '« Previous', 17 | 'next' => 'Next »', 18 | 19 | ]; 20 | -------------------------------------------------------------------------------- /resources/lang/en/passwords.php: -------------------------------------------------------------------------------- 1 | 'Passwords must be at least six characters and match the confirmation.', 17 | 'reset' => 'Your password has been reset!', 18 | 'sent' => 'We have e-mailed your password reset link!', 19 | 'token' => 'This password reset token is invalid.', 20 | 'user' => "We can't find a user with that e-mail address.", 21 | 'forget_pwd' => 'Forget Password', 22 | 'reset_pwd' => 'Reset Password', 23 | 'email' => 'Email', 24 | 'email_subject' => 'Your Password Reset Link', 25 | 'email_content' => 'Click here to reset your password:', 26 | ]; 27 | -------------------------------------------------------------------------------- /resources/lang/en/validation.php: -------------------------------------------------------------------------------- 1 | 'The :attribute must be accepted.', 17 | 'active_url' => 'The :attribute is not a valid URL.', 18 | 'after' => 'The :attribute must be a date after :date.', 19 | 'alpha' => 'The :attribute may only contain letters.', 20 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.', 21 | 'alpha_num' => 'The :attribute may only contain letters and numbers.', 22 | 'array' => 'The :attribute must be an array.', 23 | 'before' => 'The :attribute must be a date before :date.', 24 | 'between' => [ 25 | 'numeric' => 'The :attribute must be between :min and :max.', 26 | 'file' => 'The :attribute must be between :min and :max kilobytes.', 27 | 'string' => 'The :attribute must be between :min and :max characters.', 28 | 'array' => 'The :attribute must have between :min and :max items.', 29 | ], 30 | 'boolean' => 'The :attribute field must be true or false.', 31 | 'confirmed' => 'The :attribute confirmation does not match.', 32 | 'date' => 'The :attribute is not a valid date.', 33 | 'date_format' => 'The :attribute does not match the format :format.', 34 | 'different' => 'The :attribute and :other must be different.', 35 | 'digits' => 'The :attribute must be :digits digits.', 36 | 'digits_between' => 'The :attribute must be between :min and :max digits.', 37 | 'dimensions' => 'The :attribute has invalid image dimensions.', 38 | 'distinct' => 'The :attribute field has a duplicate value.', 39 | 'email' => 'The :attribute must be a valid email address.', 40 | 'exists' => 'The selected :attribute is invalid.', 41 | 'file' => 'The :attribute must be a file.', 42 | 'filled' => 'The :attribute field is required.', 43 | 'image' => 'The :attribute must be an image.', 44 | 'in' => 'The selected :attribute is invalid.', 45 | 'in_array' => 'The :attribute field does not exist in :other.', 46 | 'integer' => 'The :attribute must be an integer.', 47 | 'ip' => 'The :attribute must be a valid IP address.', 48 | 'json' => 'The :attribute must be a valid JSON string.', 49 | 'max' => [ 50 | 'numeric' => 'The :attribute may not be greater than :max.', 51 | 'file' => 'The :attribute may not be greater than :max kilobytes.', 52 | 'string' => 'The :attribute may not be greater than :max characters.', 53 | 'array' => 'The :attribute may not have more than :max items.', 54 | ], 55 | 'mimes' => 'The :attribute must be a file of type: :values.', 56 | 'min' => [ 57 | 'numeric' => 'The :attribute must be at least :min.', 58 | 'file' => 'The :attribute must be at least :min kilobytes.', 59 | 'string' => 'The :attribute must be at least :min characters.', 60 | 'array' => 'The :attribute must have at least :min items.', 61 | ], 62 | 'not_in' => 'The selected :attribute is invalid.', 63 | 'numeric' => 'The :attribute must be a number.', 64 | 'present' => 'The :attribute field must be present.', 65 | 'regex' => 'The :attribute format is invalid.', 66 | 'required' => 'The :attribute field is required.', 67 | 'required_if' => 'The :attribute field is required when :other is :value.', 68 | 'required_unless' => 'The :attribute field is required unless :other is in :values.', 69 | 'required_with' => 'The :attribute field is required when :values is present.', 70 | 'required_with_all' => 'The :attribute field is required when :values is present.', 71 | 'required_without' => 'The :attribute field is required when :values is not present.', 72 | 'required_without_all' => 'The :attribute field is required when none of :values are present.', 73 | 'same' => 'The :attribute and :other must match.', 74 | 'size' => [ 75 | 'numeric' => 'The :attribute must be :size.', 76 | 'file' => 'The :attribute must be :size kilobytes.', 77 | 'string' => 'The :attribute must be :size characters.', 78 | 'array' => 'The :attribute must contain :size items.', 79 | ], 80 | 'string' => 'The :attribute must be a string.', 81 | 'timezone' => 'The :attribute must be a valid zone.', 82 | 'unique' => 'The :attribute has already been taken.', 83 | 'url' => 'The :attribute format is invalid.', 84 | 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | Custom Validation Language Lines 88 | |-------------------------------------------------------------------------- 89 | | 90 | | Here you may specify custom validation messages for attributes using the 91 | | convention "attribute.rule" to name the lines. This makes it quick to 92 | | specify a specific custom language line for a given attribute rule. 93 | | 94 | */ 95 | 96 | 'custom' => [ 97 | 'attribute-name' => [ 98 | 'rule-name' => 'custom-message', 99 | ], 100 | ], 101 | 102 | /* 103 | |-------------------------------------------------------------------------- 104 | | Custom Validation Attributes 105 | |-------------------------------------------------------------------------- 106 | | 107 | | The following language lines are used to swap attribute place-holders 108 | | with something more reader friendly such as E-Mail Address instead 109 | | of "email". This simply helps us make messages a little cleaner. 110 | | 111 | */ 112 | 113 | 'attributes' => [], 114 | 115 | ]; 116 | -------------------------------------------------------------------------------- /resources/views/admin/dashboard.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.admin') 2 | 3 | @section('content') 4 |
5 |
6 |
7 |

@lang('admin.menu.dashboard')

8 |
9 | 10 |
11 | 12 |
13 |
14 |
15 |
16 |
17 |
18 | 19 |
20 |
21 |
{{ $user['total'] }}
22 |
@lang('admin.dashboard.user_total')
23 |
24 |
25 |
26 |
27 | {{ $user['active'] }} @lang('admin.dashboard.user_active') 28 |
29 |
30 | {{ $user['admin'] }} @lang('admin.dashboard.user_admin') 31 |
32 |
33 |
34 | 35 | 40 | 41 |
42 |
43 | 44 |
45 |
46 |
47 |
48 |
49 | 50 |
51 |
52 |
{{ $service['total'] }}
53 |
@lang('admin.dashboard.service_total')
54 |
55 |
56 |
57 |
58 | {{ $service['enabled'] }} @lang('admin.dashboard.service_enabled') 59 |
60 |
61 |
62 | 63 | 68 | 69 |
70 |
71 | 72 |
73 | 74 |
75 | 76 | @endsection 77 | -------------------------------------------------------------------------------- /resources/views/auth/emails/password.blade.php: -------------------------------------------------------------------------------- 1 | @lang('passwords.email_content') {{ $link }} 2 | -------------------------------------------------------------------------------- /resources/views/auth/login.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 | 50 |
51 |
52 |
53 | @endsection 54 | -------------------------------------------------------------------------------- /resources/views/auth/login_warn.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 | 21 |
22 |
23 |
24 | @endsection 25 | 26 | @section('javascript') 27 | 32 | @endsection -------------------------------------------------------------------------------- /resources/views/auth/passwords/email.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | 4 | @section('content') 5 |
6 |
7 |
8 | 33 |
34 |
35 |
36 | @endsection 37 | -------------------------------------------------------------------------------- /resources/views/auth/passwords/reset.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 | 65 |
66 |
67 |
68 | @endsection 69 | -------------------------------------------------------------------------------- /resources/views/errors/503.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Be right back. 5 | 6 | 7 | 8 | 39 | 40 | 41 |
42 |
43 |
Be right back.
44 |
45 |
46 | 47 | 48 | -------------------------------------------------------------------------------- /resources/views/home.blade.php: -------------------------------------------------------------------------------- 1 | @extends('layouts.app') 2 | 3 | @section('content') 4 |
5 |
6 |
7 | 27 |
28 |
29 |
30 | 71 | @endsection 72 | 73 | @section('javascript') 74 | @include('vendor.bootbox') 75 | 130 | @endsection 131 | 132 | -------------------------------------------------------------------------------- /resources/views/layouts/admin.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CAS Server 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | @yield('stylesheet') 17 | 18 | 19 | 61 | 62 | @yield('content') 63 | 64 | 65 | 66 | 67 | 96 | @yield('javascript') 97 | 98 | 99 | -------------------------------------------------------------------------------- /resources/views/layouts/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CAS Server 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | @yield('stylesheet') 16 | 17 | 18 | 19 | @yield('content') 20 | 21 | 22 | 23 | 24 | @yield('javascript') 25 | 26 | 27 | -------------------------------------------------------------------------------- /resources/views/vendor/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /resources/views/vendor/bootbox.blade.php: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /server.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $uri = urldecode( 11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) 12 | ); 13 | 14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the 15 | // built-in PHP web server. This provides a convenient way to test a Laravel 16 | // application without having installed a "real" web server software here. 17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) { 18 | return false; 19 | } 20 | 21 | require_once __DIR__.'/public/index.php'; 22 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | routes.php 3 | schedule-* 4 | compiled.php 5 | services.json 6 | events.scanned.php 7 | routes.scanned.php 8 | down 9 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/Http/Controllers/Cas/SecurityControllerTest.php: -------------------------------------------------------------------------------- 1 | _login('not_exists_user', 'random')->see(trans('auth.failed')); 21 | 22 | //login with invalid credential 23 | $user = $this->initDemoUser(); 24 | $this->_login($user->name, 'wrong_password')->see(trans('auth.failed')); 25 | } 26 | 27 | public function testBaseLoginLogout() 28 | { 29 | //normally login 30 | $user = $this->initDemoUser(); 31 | $this->_login($user->name, 'secret')->see($user->name); 32 | 33 | //test session cookie 34 | $cookies = $this->response->headers->getCookies(ResponseHeaderBag::COOKIES_ARRAY); 35 | $this->assertContains($user->name, $this->route('GET', 'home', [], [], $cookies)->getContent()); 36 | //logout 37 | $this->assertNotContains($user->name, $this->route('GET', 'cas_logout', [], [], $cookies)->getContent()); 38 | } 39 | 40 | public function testDisabledUser() 41 | { 42 | $user = $this->initDemoUser(); 43 | $user->enabled = false; 44 | $user->save(); 45 | $this->_login($user->name, 'secret')->see(trans('auth.failed')); 46 | } 47 | 48 | public function testLoginWithRemember() 49 | { 50 | $user = $this->initDemoUser(); 51 | $this->_login($user->name, 'secret', true)->see($user->name); 52 | 53 | $cookies = $this->response->headers->getCookies(ResponseHeaderBag::COOKIES_ARRAY); 54 | unset($cookies['laravel_session']); 55 | $this->assertContains($user->name, $this->route('GET', 'home', [], [], $cookies)->getContent()); 56 | } 57 | 58 | public function testLoginWithService() 59 | { 60 | $user = $this->initDemoUser(); 61 | $service = $this->initService(); 62 | $serviceUrl = 'http://'.$service->hosts()->first()->host; 63 | 64 | $url = $this->app['url']->route('cas_login_page', ['service' => $serviceUrl]); 65 | $this->visit($url)->dontSee((new CasException(CasException::INVALID_SERVICE))->getCasMsg()); 66 | 67 | $this->actingAs($user)->route('GET', 'cas_login_page', ['service' => $serviceUrl]); 68 | 69 | $location = $this->response->headers->get('location'); 70 | $this->assertContains($serviceUrl, $location); 71 | $this->assertContains('ticket=', $location); 72 | } 73 | 74 | public function testRequestLoginWithInvalidServiceUrl() 75 | { 76 | $url = $this->app['url']->route('cas_login_page', ['service' => 'http://none-exists.com']); 77 | $this->visit($url)->see((new CasException(CasException::INVALID_SERVICE))->getCasMsg()); 78 | 79 | $user = $this->initDemoUser(); 80 | $this->visit($url)->type($user->name, 'name')->type('secret', 'password')->press(trans('common.submit')) 81 | ->see((new CasException(CasException::INVALID_SERVICE))->getCasMsg()); 82 | } 83 | 84 | public function testLoginWithWarn() 85 | { 86 | $user = $this->initDemoUser(); 87 | $service = $this->initService(); 88 | $serviceUrl = 'http://'.$service->hosts()->first()->host; 89 | 90 | $url = $this->app['url']->route('cas_login_page', ['service' => $serviceUrl, 'warn' => 'true']); 91 | $this->actingAs($user)->visit($url)->see(trans('message.cas_redirect_warn', ['url' => $serviceUrl])); 92 | $jumpUrl = $this->filterByNameOrId('btn_ok', 'a')->link()->getUri(); 93 | $this->call('GET', $jumpUrl); 94 | $location = $this->response->headers->get('location'); 95 | $this->assertContains($serviceUrl, $location); 96 | $this->assertContains('ticket=', $location); 97 | } 98 | 99 | /** 100 | * @param string $name 101 | * @param string $password 102 | * @param bool $remember 103 | * @param array $params 104 | * @return static 105 | */ 106 | protected function _login($name, $password, $remember = false, $params = array()) 107 | { 108 | $url = $this->app['url']->route('cas_login_page', $params); 109 | $form = $this->visit($url)->type($name, 'name')->type($password, 'password'); 110 | if ($remember) { 111 | $form->check('remember'); 112 | } 113 | 114 | return $form->press(trans('common.submit')); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /tests/Http/Controllers/Cas/ValidateControllerTest.php: -------------------------------------------------------------------------------- 1 | user = $this->initDemoUser(); 25 | $this->service = $this->initService(); 26 | } 27 | 28 | protected function getServiceUrl() 29 | { 30 | return 'http://'.$this->service->hosts()->first()->host; 31 | } 32 | 33 | protected function _createTicket() 34 | { 35 | return Ticket::applyTicket( 36 | $this->user, 37 | $this->getServiceUrl() 38 | ); 39 | } 40 | 41 | public function testV1Validate() 42 | { 43 | //normal 44 | $ticket = $this->_createTicket(); 45 | $url = $this->app['url']->route( 46 | 'cas_v1validate', 47 | ['ticket' => $ticket->ticket, 'service' => $ticket->service_url] 48 | ); 49 | 50 | $this->visit($url)->see('yes'); 51 | 52 | //reuse a ticket 53 | $this->visit($url)->see('no'); 54 | 55 | 56 | //request with a none-exists ticket 57 | $url = $this->app['url']->route( 58 | 'cas_v1validate', 59 | ['ticket' => 'randomstring', 'service' => $ticket->service_url] 60 | ); 61 | $this->visit($url)->see('no'); 62 | 63 | 64 | //invalid service url 65 | $ticket = $this->_createTicket(); 66 | $url = $this->app['url']->route( 67 | 'cas_v1validate', 68 | ['ticket' => $ticket->ticket, 'service' => 'http://badserviceurl'] 69 | ); 70 | $this->visit($url)->see('no'); 71 | 72 | //empty ticket or service 73 | $url = $this->app['url']->route( 74 | 'cas_v1validate', 75 | ['service' => $ticket->service_url] 76 | ); 77 | $this->visit($url)->see('no'); 78 | 79 | $ticket = $this->_createTicket(); 80 | $url = $this->app['url']->route( 81 | 'cas_v1validate', 82 | ['ticket' => $ticket->ticket] 83 | ); 84 | $this->visit($url)->see('no'); 85 | } 86 | 87 | public function testV23Validate() 88 | { 89 | $format = ['JSON', 'XML']; 90 | $router = ['cas_v2validate', 'cas_v3validate']; 91 | 92 | foreach ($format as $f) { 93 | foreach ($router as $r) { 94 | //normal 95 | $expect = $this->genNormalResp($r); 96 | $ticket = $this->_createTicket(); 97 | $this->doTest( 98 | $expect, 99 | $r, 100 | 'http://'.$this->service->hosts()->first()->host, 101 | $ticket->ticket, 102 | $f 103 | ); 104 | 105 | //reuse ticket 106 | $expect = [ 107 | 'code' => CasException::INVALID_TICKET, 108 | ]; 109 | 110 | $this->doTest( 111 | $expect, 112 | $r, 113 | 'http://'.$this->service->hosts()->first()->host, 114 | $ticket->ticket, 115 | $f 116 | ); 117 | 118 | //empty ticket or service 119 | $expect = [ 120 | 'code' => CasException::INVALID_REQUEST, 121 | ]; 122 | 123 | $this->doTest( 124 | $expect, 125 | $r, 126 | '', 127 | 'justnotempty', 128 | $f 129 | ); 130 | 131 | $expect = [ 132 | 'code' => CasException::INVALID_REQUEST, 133 | ]; 134 | 135 | $this->doTest( 136 | $expect, 137 | $r, 138 | 'justnotempty', 139 | '', 140 | $f 141 | ); 142 | 143 | //invalid service url 144 | $expect = [ 145 | 'code' => CasException::INVALID_SERVICE, 146 | ]; 147 | $ticket = $this->_createTicket(); 148 | $this->doTest( 149 | $expect, 150 | $r, 151 | 'http://badserviceurl', 152 | $ticket->ticket, 153 | $f 154 | ); 155 | } 156 | } 157 | } 158 | 159 | public function doTest($expect, $router, $service, $ticket, $format) 160 | { 161 | $data = array_filter( 162 | compact('service', 'ticket', 'format'), 163 | function ($val) { 164 | return !is_null($val); 165 | } 166 | ); 167 | 168 | $response = $this->route('GET', $router, $data); 169 | if (isset($expect['code'])) { 170 | $this->assertEquals($expect['code'], $this->getErrorCode($response, $format)); 171 | } 172 | 173 | if (isset($expect['equals'])) { 174 | foreach ($expect['equals'] as $k => $v) { 175 | $this->assertEquals($v, $this->getResponseValue($response, $format, $k)); 176 | } 177 | } 178 | 179 | if (isset($expect['empty'])) { 180 | foreach ($expect['empty'] as $v) { 181 | $this->assertEmpty($this->getResponseValue($response, $format, $v)); 182 | } 183 | } 184 | 185 | if (isset($expect['notEmpty'])) { 186 | foreach ($expect['notEmpty'] as $v) { 187 | $this->assertNotEmpty($this->getResponseValue($response, $format, $v)); 188 | } 189 | } 190 | } 191 | 192 | protected function genNormalResp($router) 193 | { 194 | $expect = [ 195 | 'equals' => [ 196 | 'serviceResponse.authenticationSuccess.user' => $this->user->name, 197 | ], 198 | ]; 199 | if (preg_match('~v3~', $router)) { 200 | $expect['notEmpty'] = ['serviceResponse.authenticationSuccess.attributes']; 201 | $expect['equals']['serviceResponse.authenticationSuccess.attributes.email'] = $this->user->email; 202 | $expect['equals']['serviceResponse.authenticationSuccess.attributes.realName'] = $this->user->real_name; 203 | } 204 | 205 | return $expect; 206 | } 207 | 208 | protected function getErrorCode(Response $response, $format) 209 | { 210 | if (is_null($format)) { 211 | $format = 'XML'; 212 | } 213 | if (strtoupper($format) == 'XML') { 214 | $crawler = new \Symfony\Component\DomCrawler\Crawler(); 215 | $crawler->addXmlContent($response->getContent()); 216 | $final = $crawler->filterXPath('cas:serviceResponse/cas:authenticationFailure'); 217 | if (count($final) == 0) { 218 | return null; 219 | } 220 | 221 | return $final->attr('code'); 222 | } else { 223 | $decode = \json_decode($response->getContent(), true); 224 | 225 | return isset($decode['serviceResponse']['authenticationFailure']['code']) ? 226 | $decode['serviceResponse']['authenticationFailure']['code'] : null; 227 | } 228 | } 229 | 230 | protected function getResponseValue(Response $response, $format, $key) 231 | { 232 | if (is_null($format)) { 233 | $format = 'XML'; 234 | } 235 | $keyArr = explode('.', $key); 236 | if (strtoupper($format) == 'XML') { 237 | $content = ''.$response->getContent().''; 238 | $content = preg_replace('~getContent(), true); 243 | } 244 | $tmp = $decode; 245 | foreach ($keyArr as $k) { 246 | if (!isset($tmp[$k])) { 247 | return null; 248 | } 249 | $tmp = $tmp[$k]; 250 | } 251 | 252 | return $tmp; 253 | } 254 | } 255 | -------------------------------------------------------------------------------- /tests/Http/Controllers/HomeControllerTest.php: -------------------------------------------------------------------------------- 1 | initDemoUser(); 18 | $this->actingAs($user)->route('POST', 'change_pwd', [], ['old' => 'wrong pwd', 'new' => 'whatever']); 19 | $this->seeJson(['code' => -1]); 20 | $this->actingAs($user)->route('POST', 'change_pwd', [], ['old' => 'secret', 'new' => 'new pwd']); 21 | $this->seeJson(['code' => 0]); 22 | } 23 | 24 | public function testDisabledUser() 25 | { 26 | $user = $this->initDemoUser(); 27 | $user->enabled = false; 28 | $user->save(); 29 | $this->actingAs($user)->route('GET', 'home'); 30 | $this->assertRedirectedToRoute('cas_login_page'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/Services/ServiceTest.php: -------------------------------------------------------------------------------- 1 | assertEquals($service->name, 'test'); 28 | $this->assertCount(2, $service->hosts); 29 | $this->assertGreaterThan(0, $service->id); 30 | 31 | $this->assertEquals($service->id, Service::getServiceByUrl('http://test.com')->id); 32 | $this->assertEquals($service->id, Service::getServiceByUrl('http://demo.com')->id); 33 | $this->assertNull(Service::getServiceByUrl('http://none.com')); 34 | $this->assertFalse(Service::isUrlValid('http://none.com')); 35 | } 36 | 37 | public function testEnable() 38 | { 39 | $service = Service::createOrUpdate( 40 | 'test', 41 | [ 42 | 'test.com', 43 | 'demo.com', 44 | ] 45 | ); 46 | $this->assertTrue(Service::isUrlValid('http://test.com')); 47 | 48 | Service::createOrUpdate( 49 | 'test', 50 | [ 51 | 'test.com', 52 | 'demo.com', 53 | ], 54 | false, 55 | $service->id 56 | ); 57 | $this->assertFalse(Service::isUrlValid('http://test.com')); 58 | } 59 | 60 | public function testGetList() 61 | { 62 | Service::createOrUpdate( 63 | 'key1', 64 | [ 65 | 'key2.com', 66 | 'key3.com', 67 | ] 68 | ); 69 | Service::createOrUpdate( 70 | 'key2', 71 | [ 72 | 'key4.com', 73 | 'key5.net', 74 | ] 75 | ); 76 | $this->assertCount(2, Service::getList('', 1, 10)); 77 | $this->assertCount(2, Service::getList('key2', 1, 10)); 78 | //only match host 79 | $list = Service::getList('key3', 1, 10); 80 | $this->assertCount(1, $list); 81 | $this->assertEquals($list[0]['name'], 'key1'); 82 | 83 | //only match name 84 | $list = Service::getList('key1', 1, 10); 85 | $this->assertCount(1, $list); 86 | $this->assertEquals($list[0]['name'], 'key1'); 87 | } 88 | 89 | public function testException1() 90 | { 91 | Service::createOrUpdate( 92 | 'test', 93 | [ 94 | 'test.com', 95 | 'demo.com', 96 | ] 97 | ); 98 | try { 99 | Service::createOrUpdate('test', []); 100 | } catch (\RuntimeException $e) { 101 | return; 102 | } 103 | $this->fail('An expected exception has not been raised.'); 104 | } 105 | 106 | public function testException2() 107 | { 108 | Service::createOrUpdate( 109 | 'test', 110 | [ 111 | 'test.com', 112 | 'demo.com', 113 | ] 114 | ); 115 | try { 116 | Service::createOrUpdate('test2', ['test.com']); 117 | } catch (\RuntimeException $e) { 118 | return; 119 | } 120 | $this->fail('An expected exception has not been raised.'); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /tests/Services/TicketTest.php: -------------------------------------------------------------------------------- 1 | user = User::createOrUpdate('demo', 'Demo Name', 'secret', 'demo@demo.com'); 25 | $this->service = Service::createOrUpdate( 26 | 'test', 27 | [ 28 | 'test.com', 29 | 'demo.com', 30 | ] 31 | ); 32 | } 33 | 34 | public function testApply() 35 | { 36 | $ticket = Ticket::applyTicket($this->user, 'http://test.com'); 37 | $this->assertGreaterThan(0, $ticket->id); 38 | $this->assertEquals($ticket->user->id, $this->user->id); 39 | $this->assertEquals($ticket->service->id, $this->service->id); 40 | $this->assertEquals($ticket->service_url, 'http://test.com'); 41 | $this->assertStringStartsWith('ST-', $ticket->ticket); 42 | $this->assertEquals( 43 | strlen($ticket->ticket), 44 | config('cas.ticket_len') 45 | ); 46 | $this->assertFalse($ticket->isExpired()); 47 | $this->assertEquals($ticket->id, Ticket::getByTicket($ticket->ticket)->id); 48 | sleep(config('cas.ticket_expire') + 1); 49 | $this->assertTrue($ticket->isExpired()); 50 | $this->assertFalse(Ticket::getByTicket($ticket->ticket)); 51 | $this->assertEquals($ticket->id, Ticket::getByTicket($ticket->ticket, false)->id); 52 | 53 | $this->assertFalse(Ticket::getByTicket('none-exists')); 54 | 55 | $ticket = Ticket::applyTicket($this->user, 'http://test.com'); 56 | $ticketStr = $ticket->ticket; 57 | Ticket::invalidTicket($ticket); 58 | $this->assertFalse(Ticket::getByTicket($ticketStr)); 59 | } 60 | 61 | public function testException() 62 | { 63 | try { 64 | Ticket::applyTicket($this->user, 'http://none'); 65 | } catch (CasException $e) { 66 | $this->assertEquals($e->getCasErrorCode(), CasException::INVALID_SERVICE); 67 | 68 | return; 69 | } 70 | $this->fail('An expected exception has not been raised.'); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /tests/Services/UserTest.php: -------------------------------------------------------------------------------- 1 | assertGreaterThan(0, $user->id); 21 | $this->assertEquals('demo', $user->name); 22 | $this->assertEquals('Demo Name', $user->real_name); 23 | $this->assertEquals('demo@demo.com', $user->email); 24 | $this->assertTrue($user->enabled); 25 | $this->assertFalse($user->admin); 26 | $this->assertTrue(Hash::check('secret', $user->password)); 27 | $this->assertEquals($user->id, User::getUserById($user->id)->id); 28 | $this->assertEquals($user->id, User::getUserByName($user->name)->id); 29 | $this->assertEquals($user->id, User::getUserByEmail($user->email)->id); 30 | 31 | //test update 32 | $new = User::createOrUpdate('new name', 'New Real Name', 'new pwd', 'new@demo.com', true, false, $user->id); 33 | $this->assertEquals($user->id, $new->id); 34 | //will not change name 35 | $this->assertEquals('demo', $new->name); 36 | $this->assertEquals('New Real Name', $new->real_name); 37 | $this->assertEquals('new@demo.com', $new->email); 38 | $this->assertFalse($new->enabled); 39 | $this->assertTrue($new->admin); 40 | $this->assertTrue(Hash::check('new pwd', $new->password)); 41 | 42 | $admin = User::createOrUpdate('admin', 'Admin Name', 'secret', 'admin@demo.com', true); 43 | $this->assertTrue($admin->admin); 44 | 45 | try { 46 | User::createOrUpdate('demo', 'Demo Name', 'secret', 'demo@demo.com'); 47 | } catch (\RuntimeException $e) { 48 | return; 49 | } 50 | $this->fail('An expected exception has not been raised.'); 51 | } 52 | 53 | public function testResetPassword() 54 | { 55 | $user = User::createOrUpdate('demo', 'Demo Name', 'secret', 'demo@demo.com'); 56 | $this->assertTrue(Hash::check('secret', $user->password)); 57 | 58 | $new = User::resetPassword($user->id, 'new pwd'); 59 | $this->assertTrue(Hash::check('new pwd', $new->password)); 60 | } 61 | 62 | public function testGetList() 63 | { 64 | User::createOrUpdate('demo', 'Demo Name', 'secret', 'demo@demo.com', false, false); 65 | User::createOrUpdate('admin', 'Admin Name', 'secret', 'admin@demo.com', true); 66 | $this->assertCount(2, User::getList('', null, null, 1, 10)); 67 | $this->assertCount(2, User::getList('demo', null, null, 1, 10)); 68 | $this->assertCount(1, User::getList('', true, null, 1, 10)); 69 | $this->assertCount(1, User::getList('', null, true, 1, 10)); 70 | 71 | $list = User::getList('admin', null, null, 1, 10); 72 | $this->assertCount(1, $list); 73 | $this->assertEquals('admin', $list[0]->name); 74 | 75 | $list = User::getList('Demo Name', null, null, 1, 10); 76 | $this->assertCount(1, $list); 77 | $this->assertEquals('demo', $list[0]->name); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | make(Illuminate\Contracts\Console\Kernel::class)->bootstrap(); 25 | 26 | return $app; 27 | } 28 | 29 | protected function initDemoUser() 30 | { 31 | return User::createOrUpdate('demo', 'Demo Name', 'secret', 'demo@demo.com'); 32 | } 33 | 34 | protected function initService() 35 | { 36 | return Service::createOrUpdate( 37 | 'demo', 38 | [ 39 | 'demo.com', 40 | ] 41 | ); 42 | } 43 | } 44 | --------------------------------------------------------------------------------