Showing
20 changed files
with
357 additions
and
53 deletions
| ... | @@ -3,8 +3,11 @@ | ... | @@ -3,8 +3,11 @@ |
| 3 | namespace BookStack\Exceptions; | 3 | namespace BookStack\Exceptions; |
| 4 | 4 | ||
| 5 | use Exception; | 5 | use Exception; |
| 6 | +use Illuminate\Contracts\Validation\ValidationException; | ||
| 7 | +use Illuminate\Database\Eloquent\ModelNotFoundException; | ||
| 6 | use Symfony\Component\HttpKernel\Exception\HttpException; | 8 | use Symfony\Component\HttpKernel\Exception\HttpException; |
| 7 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | 9 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
| 10 | +use Illuminate\Auth\Access\AuthorizationException; | ||
| 8 | 11 | ||
| 9 | class Handler extends ExceptionHandler | 12 | class Handler extends ExceptionHandler |
| 10 | { | 13 | { |
| ... | @@ -14,7 +17,10 @@ class Handler extends ExceptionHandler | ... | @@ -14,7 +17,10 @@ class Handler extends ExceptionHandler |
| 14 | * @var array | 17 | * @var array |
| 15 | */ | 18 | */ |
| 16 | protected $dontReport = [ | 19 | protected $dontReport = [ |
| 20 | + AuthorizationException::class, | ||
| 17 | HttpException::class, | 21 | HttpException::class, |
| 22 | + ModelNotFoundException::class, | ||
| 23 | + ValidationException::class, | ||
| 18 | ]; | 24 | ]; |
| 19 | 25 | ||
| 20 | /** | 26 | /** | ... | ... |
app/Exceptions/LdapException.php
0 → 100644
| ... | @@ -29,7 +29,6 @@ class AuthController extends Controller | ... | @@ -29,7 +29,6 @@ class AuthController extends Controller |
| 29 | 29 | ||
| 30 | use AuthenticatesAndRegistersUsers, ThrottlesLogins; | 30 | use AuthenticatesAndRegistersUsers, ThrottlesLogins; |
| 31 | 31 | ||
| 32 | - protected $loginPath = '/login'; | ||
| 33 | protected $redirectPath = '/'; | 32 | protected $redirectPath = '/'; |
| 34 | protected $redirectAfterLogout = '/login'; | 33 | protected $redirectAfterLogout = '/login'; |
| 35 | 34 | ||
| ... | @@ -232,13 +231,9 @@ class AuthController extends Controller | ... | @@ -232,13 +231,9 @@ class AuthController extends Controller |
| 232 | */ | 231 | */ |
| 233 | public function getLogin() | 232 | public function getLogin() |
| 234 | { | 233 | { |
| 235 | - | ||
| 236 | - if (view()->exists('auth.authenticate')) { | ||
| 237 | - return view('auth.authenticate'); | ||
| 238 | - } | ||
| 239 | - | ||
| 240 | $socialDrivers = $this->socialAuthService->getActiveDrivers(); | 234 | $socialDrivers = $this->socialAuthService->getActiveDrivers(); |
| 241 | - return view('auth.login', ['socialDrivers' => $socialDrivers]); | 235 | + $authMethod = 'standard'; // TODO - rewrite to use config. |
| 236 | + return view('auth/login', ['socialDrivers' => $socialDrivers, 'authMethod' => $authMethod]); | ||
| 242 | } | 237 | } |
| 243 | 238 | ||
| 244 | /** | 239 | /** |
| ... | @@ -253,7 +248,7 @@ class AuthController extends Controller | ... | @@ -253,7 +248,7 @@ class AuthController extends Controller |
| 253 | } | 248 | } |
| 254 | 249 | ||
| 255 | /** | 250 | /** |
| 256 | - * Redirect to the social site for authentication initended to register. | 251 | + * Redirect to the social site for authentication intended to register. |
| 257 | * @param $socialDriver | 252 | * @param $socialDriver |
| 258 | * @return mixed | 253 | * @return mixed |
| 259 | */ | 254 | */ | ... | ... |
| ... | @@ -48,7 +48,7 @@ abstract class Controller extends BaseController | ... | @@ -48,7 +48,7 @@ abstract class Controller extends BaseController |
| 48 | */ | 48 | */ |
| 49 | protected function preventAccessForDemoUsers() | 49 | protected function preventAccessForDemoUsers() |
| 50 | { | 50 | { |
| 51 | - if (env('APP_ENV', 'production') === 'demo') $this->showPermissionError(); | 51 | + if (config('app.env') === 'demo') $this->showPermissionError(); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | /** | 54 | /** | ... | ... |
| ... | @@ -72,7 +72,7 @@ class UserController extends Controller | ... | @@ -72,7 +72,7 @@ class UserController extends Controller |
| 72 | $user->attachRoleId($request->get('role')); | 72 | $user->attachRoleId($request->get('role')); |
| 73 | 73 | ||
| 74 | // Get avatar from gravatar and save | 74 | // Get avatar from gravatar and save |
| 75 | - if (!env('DISABLE_EXTERNAL_SERVICES', false)) { | 75 | + if (!config('services.disable_services')) { |
| 76 | $avatar = \Images::saveUserGravatar($user); | 76 | $avatar = \Images::saveUserGravatar($user); |
| 77 | $user->avatar()->associate($avatar); | 77 | $user->avatar()->associate($avatar); |
| 78 | $user->save(); | 78 | $user->save(); | ... | ... |
| 1 | <?php | 1 | <?php |
| 2 | 2 | ||
| 3 | +Route::get('/test', function() { | ||
| 4 | + // TODO - remove this | ||
| 5 | + $service = new \BookStack\Services\LdapService(); | ||
| 6 | + $service->getUserDetails('ssmith'); | ||
| 7 | +}); | ||
| 8 | + | ||
| 3 | // Authenticated routes... | 9 | // Authenticated routes... |
| 4 | Route::group(['middleware' => 'auth'], function () { | 10 | Route::group(['middleware' => 'auth'], function () { |
| 5 | 11 | ... | ... |
app/Providers/AuthServiceProvider.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace BookStack\Providers; | ||
| 4 | + | ||
| 5 | +use Auth; | ||
| 6 | +use Illuminate\Support\ServiceProvider; | ||
| 7 | + | ||
| 8 | +class AuthServiceProvider extends ServiceProvider | ||
| 9 | +{ | ||
| 10 | + /** | ||
| 11 | + * Bootstrap the application services. | ||
| 12 | + * | ||
| 13 | + * @return void | ||
| 14 | + */ | ||
| 15 | + public function boot() | ||
| 16 | + { | ||
| 17 | + // | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * Register the application services. | ||
| 22 | + * | ||
| 23 | + * @return void | ||
| 24 | + */ | ||
| 25 | + public function register() | ||
| 26 | + { | ||
| 27 | + Auth::provider('ldap', function($app, array $config) { | ||
| 28 | + return new LdapUserProvider($config['model']); | ||
| 29 | + }); | ||
| 30 | + } | ||
| 31 | +} |
app/Providers/LdapUserProvider.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace BookStack\Providers; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use BookStack\User; | ||
| 7 | +use Illuminate\Contracts\Auth\Authenticatable; | ||
| 8 | +use Illuminate\Contracts\Auth\UserProvider; | ||
| 9 | + | ||
| 10 | +class LdapUserProvider implements UserProvider | ||
| 11 | +{ | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * The user model. | ||
| 15 | + * | ||
| 16 | + * @var string | ||
| 17 | + */ | ||
| 18 | + protected $model; | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * LdapUserProvider constructor. | ||
| 23 | + * @param $model | ||
| 24 | + */ | ||
| 25 | + public function __construct($model) | ||
| 26 | + { | ||
| 27 | + $this->model = $model; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * Create a new instance of the model. | ||
| 32 | + * | ||
| 33 | + * @return \Illuminate\Database\Eloquent\Model | ||
| 34 | + */ | ||
| 35 | + public function createModel() | ||
| 36 | + { | ||
| 37 | + $class = '\\'.ltrim($this->model, '\\'); | ||
| 38 | + | ||
| 39 | + return new $class; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * Retrieve a user by their unique identifier. | ||
| 45 | + * | ||
| 46 | + * @param mixed $identifier | ||
| 47 | + * @return \Illuminate\Contracts\Auth\Authenticatable|null | ||
| 48 | + */ | ||
| 49 | + public function retrieveById($identifier) | ||
| 50 | + { | ||
| 51 | + return $this->createModel()->newQuery()->find($identifier); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Retrieve a user by their unique identifier and "remember me" token. | ||
| 56 | + * | ||
| 57 | + * @param mixed $identifier | ||
| 58 | + * @param string $token | ||
| 59 | + * @return \Illuminate\Contracts\Auth\Authenticatable|null | ||
| 60 | + */ | ||
| 61 | + public function retrieveByToken($identifier, $token) | ||
| 62 | + { | ||
| 63 | + $model = $this->createModel(); | ||
| 64 | + | ||
| 65 | + return $model->newQuery() | ||
| 66 | + ->where($model->getAuthIdentifierName(), $identifier) | ||
| 67 | + ->where($model->getRememberTokenName(), $token) | ||
| 68 | + ->first(); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + | ||
| 72 | + /** | ||
| 73 | + * Update the "remember me" token for the given user in storage. | ||
| 74 | + * | ||
| 75 | + * @param \Illuminate\Contracts\Auth\Authenticatable $user | ||
| 76 | + * @param string $token | ||
| 77 | + * @return void | ||
| 78 | + */ | ||
| 79 | + public function updateRememberToken(Authenticatable $user, $token) | ||
| 80 | + { | ||
| 81 | + $user->setRememberToken($token); | ||
| 82 | + | ||
| 83 | + $user->save(); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * Retrieve a user by the given credentials. | ||
| 88 | + * | ||
| 89 | + * @param array $credentials | ||
| 90 | + * @return \Illuminate\Contracts\Auth\Authenticatable|null | ||
| 91 | + */ | ||
| 92 | + public function retrieveByCredentials(array $credentials) | ||
| 93 | + { | ||
| 94 | + // TODO: Implement retrieveByCredentials() method. | ||
| 95 | + | ||
| 96 | + // Get user via LDAP | ||
| 97 | + | ||
| 98 | + // Search current user base by looking up a uid | ||
| 99 | + | ||
| 100 | + // If not exists create a new user instance with attached role | ||
| 101 | + // but do not store it in the database yet | ||
| 102 | + | ||
| 103 | + // | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + /** | ||
| 107 | + * Validate a user against the given credentials. | ||
| 108 | + * | ||
| 109 | + * @param \Illuminate\Contracts\Auth\Authenticatable $user | ||
| 110 | + * @param array $credentials | ||
| 111 | + * @return bool | ||
| 112 | + */ | ||
| 113 | + public function validateCredentials(Authenticatable $user, array $credentials) | ||
| 114 | + { | ||
| 115 | + // TODO: Implement validateCredentials() method. | ||
| 116 | + } | ||
| 117 | +} |
| ... | @@ -200,7 +200,7 @@ class ImageService | ... | @@ -200,7 +200,7 @@ class ImageService |
| 200 | { | 200 | { |
| 201 | if ($this->storageInstance !== null) return $this->storageInstance; | 201 | if ($this->storageInstance !== null) return $this->storageInstance; |
| 202 | 202 | ||
| 203 | - $storageType = env('STORAGE_TYPE'); | 203 | + $storageType = config('filesystems.default'); |
| 204 | $this->storageInstance = $this->fileSystem->disk($storageType); | 204 | $this->storageInstance = $this->fileSystem->disk($storageType); |
| 205 | 205 | ||
| 206 | return $this->storageInstance; | 206 | return $this->storageInstance; |
| ... | @@ -226,10 +226,10 @@ class ImageService | ... | @@ -226,10 +226,10 @@ class ImageService |
| 226 | private function getPublicUrl($filePath) | 226 | private function getPublicUrl($filePath) |
| 227 | { | 227 | { |
| 228 | if ($this->storageUrl === null) { | 228 | if ($this->storageUrl === null) { |
| 229 | - $storageUrl = env('STORAGE_URL'); | 229 | + $storageUrl = config('filesystems.url'); |
| 230 | 230 | ||
| 231 | // Get the standard public s3 url if s3 is set as storage type | 231 | // Get the standard public s3 url if s3 is set as storage type |
| 232 | - if ($storageUrl == false && env('STORAGE_TYPE') === 's3') { | 232 | + if ($storageUrl == false && config('filesystems.default') === 's3') { |
| 233 | $storageDetails = config('filesystems.disks.s3'); | 233 | $storageDetails = config('filesystems.disks.s3'); |
| 234 | $storageUrl = 'https://s3-' . $storageDetails['region'] . '.amazonaws.com/' . $storageDetails['bucket']; | 234 | $storageUrl = 'https://s3-' . $storageDetails['region'] . '.amazonaws.com/' . $storageDetails['bucket']; |
| 235 | } | 235 | } | ... | ... |
app/Services/LdapService.php
0 → 100644
| 1 | +<?php namespace BookStack\Services; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +use BookStack\Exceptions\LdapException; | ||
| 5 | + | ||
| 6 | +class LdapService | ||
| 7 | +{ | ||
| 8 | + | ||
| 9 | + public function getUserDetails($userName) | ||
| 10 | + { | ||
| 11 | + | ||
| 12 | + if(!function_exists('ldap_connect')) { | ||
| 13 | + throw new LdapException('LDAP PHP extension not installed'); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + $ldapServer = explode(':', config('services.ldap.server')); | ||
| 18 | + $ldapConnection = ldap_connect($ldapServer[0], count($ldapServer) > 1 ? $ldapServer[1] : 389); | ||
| 19 | + | ||
| 20 | + if ($ldapConnection === false) { | ||
| 21 | + throw new LdapException('Cannot connect to ldap server, Initial connection failed'); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + // Options | ||
| 25 | + | ||
| 26 | + ldap_set_option($ldapConnection, LDAP_OPT_PROTOCOL_VERSION, 3); // TODO - make configurable | ||
| 27 | + | ||
| 28 | + $ldapDn = config('services.ldap.dn'); | ||
| 29 | + $ldapPass = config('services.ldap.pass'); | ||
| 30 | + $isAnonymous = ($ldapDn === false || $ldapPass === false); | ||
| 31 | + if ($isAnonymous) { | ||
| 32 | + $ldapBind = ldap_bind($ldapConnection); | ||
| 33 | + } else { | ||
| 34 | + $ldapBind = ldap_bind($ldapConnection, $ldapDn, $ldapPass); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + if (!$ldapBind) throw new LdapException('LDAP access failed using ' . $isAnonymous ? ' anonymous bind.' : ' given dn & pass details'); | ||
| 38 | + | ||
| 39 | + // Find user | ||
| 40 | + $userFilter = $this->buildFilter(config('services.ldap.user_filter'), ['user' => $userName]); | ||
| 41 | + //dd($userFilter); | ||
| 42 | + $baseDn = config('services.ldap.base_dn'); | ||
| 43 | + $ldapSearch = ldap_search($ldapConnection, $baseDn, $userFilter); | ||
| 44 | + $users = ldap_get_entries($ldapConnection, $ldapSearch); | ||
| 45 | + | ||
| 46 | + dd($users); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + | ||
| 50 | + private function buildFilter($filterString, $attrs) | ||
| 51 | + { | ||
| 52 | + $newAttrs = []; | ||
| 53 | + foreach ($attrs as $key => $attrText) { | ||
| 54 | + $newKey = '${'.$key.'}'; | ||
| 55 | + $newAttrs[$newKey] = $attrText; | ||
| 56 | + } | ||
| 57 | + return strtr($filterString, $newAttrs); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -76,9 +76,9 @@ class SocialAuthService | ... | @@ -76,9 +76,9 @@ class SocialAuthService |
| 76 | throw new UserRegistrationException('This ' . $socialDriver . ' account is already in use, Try logging in via the ' . $socialDriver . ' option.', '/login'); | 76 | throw new UserRegistrationException('This ' . $socialDriver . ' account is already in use, Try logging in via the ' . $socialDriver . ' option.', '/login'); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | - if($this->userRepo->getByEmail($socialUser->getEmail())) { | 79 | + if ($this->userRepo->getByEmail($socialUser->getEmail())) { |
| 80 | $email = $socialUser->getEmail(); | 80 | $email = $socialUser->getEmail(); |
| 81 | - throw new UserRegistrationException('The email '. $email.' is already in use. If you already have an account you can connect your ' . $socialDriver .' account from your profile settings.', '/login'); | 81 | + throw new UserRegistrationException('The email ' . $email . ' is already in use. If you already have an account you can connect your ' . $socialDriver . ' account from your profile settings.', '/login'); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | return $socialUser; | 84 | return $socialUser; |
| ... | @@ -172,9 +172,10 @@ class SocialAuthService | ... | @@ -172,9 +172,10 @@ class SocialAuthService |
| 172 | */ | 172 | */ |
| 173 | private function checkDriverConfigured($driver) | 173 | private function checkDriverConfigured($driver) |
| 174 | { | 174 | { |
| 175 | - $upperName = strtoupper($driver); | 175 | + $lowerName = strtolower($driver); |
| 176 | - $config = [env($upperName . '_APP_ID', false), env($upperName . '_APP_SECRET', false), env('APP_URL', false)]; | 176 | + $configPrefix = 'services.' . $lowerName . '.'; |
| 177 | - return (!in_array(false, $config) && !in_array(null, $config)); | 177 | + $config = [config($configPrefix . 'client_id'), config($configPrefix . 'client_secret'), config('services.callback_url')]; |
| 178 | + return !in_array(false, $config) && !in_array(null, $config); | ||
| 178 | } | 179 | } |
| 179 | 180 | ||
| 180 | /** | 181 | /** | ... | ... |
| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | "type": "project", | 6 | "type": "project", |
| 7 | "require": { | 7 | "require": { |
| 8 | "php": ">=5.5.9", | 8 | "php": ">=5.5.9", |
| 9 | - "laravel/framework": "5.1.*", | 9 | + "laravel/framework": "5.2.*", |
| 10 | "intervention/image": "^2.3", | 10 | "intervention/image": "^2.3", |
| 11 | "laravel/socialite": "^2.0", | 11 | "laravel/socialite": "^2.0", |
| 12 | "barryvdh/laravel-ide-helper": "^2.1", | 12 | "barryvdh/laravel-ide-helper": "^2.1", |
| ... | @@ -17,7 +17,9 @@ | ... | @@ -17,7 +17,9 @@ |
| 17 | "fzaninotto/faker": "~1.4", | 17 | "fzaninotto/faker": "~1.4", |
| 18 | "mockery/mockery": "0.9.*", | 18 | "mockery/mockery": "0.9.*", |
| 19 | "phpunit/phpunit": "~4.0", | 19 | "phpunit/phpunit": "~4.0", |
| 20 | - "phpspec/phpspec": "~2.1" | 20 | + "phpspec/phpspec": "~2.1", |
| 21 | + "symfony/dom-crawler": "~3.0", | ||
| 22 | + "symfony/css-selector": "~3.0" | ||
| 21 | }, | 23 | }, |
| 22 | "autoload": { | 24 | "autoload": { |
| 23 | "classmap": [ | 25 | "classmap": [ | ... | ... |
This diff is collapsed.
Click to expand it.
| ... | @@ -2,6 +2,9 @@ | ... | @@ -2,6 +2,9 @@ |
| 2 | 2 | ||
| 3 | return [ | 3 | return [ |
| 4 | 4 | ||
| 5 | + | ||
| 6 | + 'env' => env('APP_ENV', 'production'), | ||
| 7 | + | ||
| 5 | /* | 8 | /* |
| 6 | |-------------------------------------------------------------------------- | 9 | |-------------------------------------------------------------------------- |
| 7 | | Application Debug Mode | 10 | | Application Debug Mode |
| ... | @@ -113,13 +116,11 @@ return [ | ... | @@ -113,13 +116,11 @@ return [ |
| 113 | /* | 116 | /* |
| 114 | * Laravel Framework Service Providers... | 117 | * Laravel Framework Service Providers... |
| 115 | */ | 118 | */ |
| 116 | - Illuminate\Foundation\Providers\ArtisanServiceProvider::class, | ||
| 117 | Illuminate\Auth\AuthServiceProvider::class, | 119 | Illuminate\Auth\AuthServiceProvider::class, |
| 118 | Illuminate\Broadcasting\BroadcastServiceProvider::class, | 120 | Illuminate\Broadcasting\BroadcastServiceProvider::class, |
| 119 | Illuminate\Bus\BusServiceProvider::class, | 121 | Illuminate\Bus\BusServiceProvider::class, |
| 120 | Illuminate\Cache\CacheServiceProvider::class, | 122 | Illuminate\Cache\CacheServiceProvider::class, |
| 121 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, | 123 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, |
| 122 | - Illuminate\Routing\ControllerServiceProvider::class, | ||
| 123 | Illuminate\Cookie\CookieServiceProvider::class, | 124 | Illuminate\Cookie\CookieServiceProvider::class, |
| 124 | Illuminate\Database\DatabaseServiceProvider::class, | 125 | Illuminate\Database\DatabaseServiceProvider::class, |
| 125 | Illuminate\Encryption\EncryptionServiceProvider::class, | 126 | Illuminate\Encryption\EncryptionServiceProvider::class, |
| ... | @@ -149,6 +150,7 @@ return [ | ... | @@ -149,6 +150,7 @@ return [ |
| 149 | /* | 150 | /* |
| 150 | * Application Service Providers... | 151 | * Application Service Providers... |
| 151 | */ | 152 | */ |
| 153 | + BookStack\Providers\AuthServiceProvider::class, | ||
| 152 | BookStack\Providers\AppServiceProvider::class, | 154 | BookStack\Providers\AppServiceProvider::class, |
| 153 | BookStack\Providers\EventServiceProvider::class, | 155 | BookStack\Providers\EventServiceProvider::class, |
| 154 | BookStack\Providers\RouteServiceProvider::class, | 156 | BookStack\Providers\RouteServiceProvider::class, | ... | ... |
| ... | @@ -2,66 +2,109 @@ | ... | @@ -2,66 +2,109 @@ |
| 2 | 2 | ||
| 3 | return [ | 3 | return [ |
| 4 | 4 | ||
| 5 | + | ||
| 6 | + 'method' => env('AUTH_METHOD', 'standard'), | ||
| 7 | + | ||
| 5 | /* | 8 | /* |
| 6 | |-------------------------------------------------------------------------- | 9 | |-------------------------------------------------------------------------- |
| 7 | - | Default Authentication Driver | 10 | + | Authentication Defaults |
| 8 | |-------------------------------------------------------------------------- | 11 | |-------------------------------------------------------------------------- |
| 9 | | | 12 | | |
| 10 | - | This option controls the authentication driver that will be utilized. | 13 | + | This option controls the default authentication "guard" and password |
| 11 | - | This driver manages the retrieval and authentication of the users | 14 | + | reset options for your application. You may change these defaults |
| 12 | - | attempting to get access to protected areas of your application. | 15 | + | as required, but they're a perfect start for most applications. |
| 13 | - | | ||
| 14 | - | Supported: "database", "eloquent" | ||
| 15 | | | 16 | | |
| 16 | */ | 17 | */ |
| 17 | 18 | ||
| 18 | - 'driver' => 'eloquent', | 19 | + 'defaults' => [ |
| 20 | + 'guard' => 'web', | ||
| 21 | + 'passwords' => 'users', | ||
| 22 | + ], | ||
| 19 | 23 | ||
| 20 | /* | 24 | /* |
| 21 | |-------------------------------------------------------------------------- | 25 | |-------------------------------------------------------------------------- |
| 22 | - | Authentication Model | 26 | + | Authentication Guards |
| 23 | |-------------------------------------------------------------------------- | 27 | |-------------------------------------------------------------------------- |
| 24 | | | 28 | | |
| 25 | - | When using the "Eloquent" authentication driver, we need to know which | 29 | + | Next, you may define every authentication guard for your application. |
| 26 | - | Eloquent model should be used to retrieve your users. Of course, it | 30 | + | Of course, a great default configuration has been defined for you |
| 27 | - | is often just the "User" model but you may use whatever you like. | 31 | + | here which uses session storage and the Eloquent user provider. |
| 32 | + | | ||
| 33 | + | All authentication drivers have a user provider. This defines how the | ||
| 34 | + | users are actually retrieved out of your database or other storage | ||
| 35 | + | mechanisms used by this application to persist your user's data. | ||
| 36 | + | | ||
| 37 | + | Supported: "session", "token" | ||
| 28 | | | 38 | | |
| 29 | */ | 39 | */ |
| 30 | 40 | ||
| 31 | - 'model' => BookStack\User::class, | 41 | + 'guards' => [ |
| 42 | + 'web' => [ | ||
| 43 | + 'driver' => 'session', | ||
| 44 | + 'provider' => 'users', | ||
| 45 | + ], | ||
| 46 | + | ||
| 47 | + 'api' => [ | ||
| 48 | + 'driver' => 'token', | ||
| 49 | + 'provider' => 'users', | ||
| 50 | + ], | ||
| 51 | + ], | ||
| 32 | 52 | ||
| 33 | /* | 53 | /* |
| 34 | |-------------------------------------------------------------------------- | 54 | |-------------------------------------------------------------------------- |
| 35 | - | Authentication Table | 55 | + | User Providers |
| 36 | |-------------------------------------------------------------------------- | 56 | |-------------------------------------------------------------------------- |
| 37 | | | 57 | | |
| 38 | - | When using the "Database" authentication driver, we need to know which | 58 | + | All authentication drivers have a user provider. This defines how the |
| 39 | - | table should be used to retrieve your users. We have chosen a basic | 59 | + | users are actually retrieved out of your database or other storage |
| 40 | - | default value but you may easily change it to any table you like. | 60 | + | mechanisms used by this application to persist your user's data. |
| 61 | + | | ||
| 62 | + | If you have multiple user tables or models you may configure multiple | ||
| 63 | + | sources which represent each model / table. These sources may then | ||
| 64 | + | be assigned to any extra authentication guards you have defined. | ||
| 65 | + | | ||
| 66 | + | Supported: "database", "eloquent" | ||
| 41 | | | 67 | | |
| 42 | */ | 68 | */ |
| 43 | 69 | ||
| 44 | - 'table' => 'users', | 70 | + 'providers' => [ |
| 71 | + 'users' => [ | ||
| 72 | + 'driver' => env('AUTH_METHOD', 'eloquent'), | ||
| 73 | + 'model' => Bookstack\User::class, | ||
| 74 | + ], | ||
| 75 | + | ||
| 76 | + // 'users' => [ | ||
| 77 | + // 'driver' => 'database', | ||
| 78 | + // 'table' => 'users', | ||
| 79 | + // ], | ||
| 80 | + ], | ||
| 45 | 81 | ||
| 46 | /* | 82 | /* |
| 47 | |-------------------------------------------------------------------------- | 83 | |-------------------------------------------------------------------------- |
| 48 | - | Password Reset Settings | 84 | + | Resetting Passwords |
| 49 | |-------------------------------------------------------------------------- | 85 | |-------------------------------------------------------------------------- |
| 50 | | | 86 | | |
| 51 | | Here you may set the options for resetting passwords including the view | 87 | | Here you may set the options for resetting passwords including the view |
| 52 | - | that is your password reset e-mail. You can also set the name of the | 88 | + | that is your password reset e-mail. You may also set the name of the |
| 53 | | table that maintains all of the reset tokens for your application. | 89 | | table that maintains all of the reset tokens for your application. |
| 54 | | | 90 | | |
| 91 | + | You may specify multiple password reset configurations if you have more | ||
| 92 | + | than one user table or model in the application and you want to have | ||
| 93 | + | separate password reset settings based on the specific user types. | ||
| 94 | + | | ||
| 55 | | The expire time is the number of minutes that the reset token should be | 95 | | The expire time is the number of minutes that the reset token should be |
| 56 | | considered valid. This security feature keeps tokens short-lived so | 96 | | considered valid. This security feature keeps tokens short-lived so |
| 57 | | they have less time to be guessed. You may change this as needed. | 97 | | they have less time to be guessed. You may change this as needed. |
| 58 | | | 98 | | |
| 59 | */ | 99 | */ |
| 60 | 100 | ||
| 61 | - 'password' => [ | 101 | + 'passwords' => [ |
| 102 | + 'users' => [ | ||
| 103 | + 'provider' => 'users', | ||
| 62 | 'email' => 'emails.password', | 104 | 'email' => 'emails.password', |
| 63 | 'table' => 'password_resets', | 105 | 'table' => 'password_resets', |
| 64 | 'expire' => 60, | 106 | 'expire' => 60, |
| 65 | ], | 107 | ], |
| 108 | + ], | ||
| 66 | 109 | ||
| 67 | ]; | 110 | ]; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -15,7 +15,18 @@ return [ | ... | @@ -15,7 +15,18 @@ return [ |
| 15 | | | 15 | | |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | - 'default' => 'local', | 18 | + 'default' => env('STORAGE_TYPE', 'local'), |
| 19 | + | ||
| 20 | + /* | ||
| 21 | + |-------------------------------------------------------------------------- | ||
| 22 | + | Storage URL | ||
| 23 | + |-------------------------------------------------------------------------- | ||
| 24 | + | | ||
| 25 | + | This is the url to where the storage is located for when using an external | ||
| 26 | + | file storage service, such as s3, to store publicly accessible assets. | ||
| 27 | + | | ||
| 28 | + */ | ||
| 29 | + 'url' => env('STORAGE_URL', false), | ||
| 19 | 30 | ||
| 20 | /* | 31 | /* |
| 21 | |-------------------------------------------------------------------------- | 32 | |-------------------------------------------------------------------------- | ... | ... |
| ... | @@ -13,6 +13,8 @@ return [ | ... | @@ -13,6 +13,8 @@ return [ |
| 13 | | to have a conventional place to find your various credentials. | 13 | | to have a conventional place to find your various credentials. |
| 14 | | | 14 | | |
| 15 | */ | 15 | */ |
| 16 | + 'disable_services' => env('DISABLE_EXTERNAL_SERVICES', false), | ||
| 17 | + 'callback_url' => env('APP_URL', false), | ||
| 16 | 18 | ||
| 17 | 'mailgun' => [ | 19 | 'mailgun' => [ |
| 18 | 'domain' => '', | 20 | 'domain' => '', |
| ... | @@ -47,4 +49,12 @@ return [ | ... | @@ -47,4 +49,12 @@ return [ |
| 47 | 'redirect' => env('APP_URL') . '/login/service/google/callback', | 49 | 'redirect' => env('APP_URL') . '/login/service/google/callback', |
| 48 | ], | 50 | ], |
| 49 | 51 | ||
| 52 | + 'ldap' => [ | ||
| 53 | + 'server' => env('LDAP_SERVER', false), | ||
| 54 | + 'dn' => env('LDAP_DN', false), | ||
| 55 | + 'pass' => env('LDAP_PASS', false), | ||
| 56 | + 'base_dn' => env('LDAP_BASE_DN', false), | ||
| 57 | + 'user_filter' => env('LDAP_USER_FILTER', '(&(uid=${user}))') | ||
| 58 | + ] | ||
| 59 | + | ||
| 50 | ]; | 60 | ]; | ... | ... |
| 1 | +<div class="form-group"> | ||
| 2 | + <label for="email">Username</label> | ||
| 3 | + @include('form/text', ['name' => 'email', 'tabindex' => 1]) | ||
| 4 | +</div> | ||
| 5 | + | ||
| 6 | +<div class="form-group"> | ||
| 7 | + <label for="password">Password</label> | ||
| 8 | + @include('form/password', ['name' => 'password', 'tabindex' => 2]) | ||
| 9 | +</div> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +<div class="form-group"> | ||
| 2 | + <label for="email">Email</label> | ||
| 3 | + @include('form/text', ['name' => 'email', 'tabindex' => 1]) | ||
| 4 | +</div> | ||
| 5 | + | ||
| 6 | +<div class="form-group"> | ||
| 7 | + <label for="password">Password</label> | ||
| 8 | + @include('form/password', ['name' => 'password', 'tabindex' => 2]) | ||
| 9 | + <span class="block small"><a href="/password/email">Forgot Password?</a></span> | ||
| 10 | +</div> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -15,16 +15,8 @@ | ... | @@ -15,16 +15,8 @@ |
| 15 | <form action="/login" method="POST" id="login-form"> | 15 | <form action="/login" method="POST" id="login-form"> |
| 16 | {!! csrf_field() !!} | 16 | {!! csrf_field() !!} |
| 17 | 17 | ||
| 18 | - <div class="form-group"> | ||
| 19 | - <label for="email">Email</label> | ||
| 20 | - @include('form/text', ['name' => 'email', 'tabindex' => 1]) | ||
| 21 | - </div> | ||
| 22 | 18 | ||
| 23 | - <div class="form-group"> | 19 | + @include('auth/forms/login/' . $authMethod) |
| 24 | - <label for="password">Password</label> | ||
| 25 | - @include('form/password', ['name' => 'password', 'tabindex' => 2]) | ||
| 26 | - <span class="block small"><a href="/password/email">Forgot Password?</a></span> | ||
| 27 | - </div> | ||
| 28 | 20 | ||
| 29 | <div class="form-group"> | 21 | <div class="form-group"> |
| 30 | <label for="remember" class="inline">Remember Me</label> | 22 | <label for="remember" class="inline">Remember Me</label> |
| ... | @@ -34,7 +26,7 @@ | ... | @@ -34,7 +26,7 @@ |
| 34 | 26 | ||
| 35 | 27 | ||
| 36 | <div class="from-group"> | 28 | <div class="from-group"> |
| 37 | - <button class="button block pos" tabindex="3">Sign In</button> | 29 | + <button class="button block pos" tabindex="3"><i class="zmdi zmdi-sign-in"></i> Sign In</button> |
| 38 | </div> | 30 | </div> |
| 39 | </form> | 31 | </form> |
| 40 | 32 | ... | ... |
-
Please register or sign in to post a comment