Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddanbrown committed Jul 29, 2018
2 parents 30d4674 + c83a51f commit 6a7d7e7
Show file tree
Hide file tree
Showing 72 changed files with 4,158 additions and 3,323 deletions.
2 changes: 2 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>0.25%
not op_mini all
9 changes: 9 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ TWITCH_APP_SECRET=false
GITLAB_APP_ID=false
GITLAB_APP_SECRET=false
GITLAB_BASE_URI=false
DISCORD_APP_ID=false
DISCORD_APP_SECRET=false

# External services such as Gravatar and Draw.IO
DISABLE_EXTERNAL_SERVICES=false
Expand All @@ -67,6 +69,13 @@ LDAP_DN=false
LDAP_PASS=false
LDAP_USER_FILTER=false
LDAP_VERSION=false
# Do you want to sync LDAP groups to BookStack roles for a user
LDAP_USER_TO_GROUPS=false
# What is the LDAP attribute for group memberships
LDAP_GROUP_ATTRIBUTE="memberOf"
# Would you like to remove users from roles on BookStack if they do not match on LDAP
# If false, the ldap groups-roles sync will only add users to roles
LDAP_REMOVE_FROM_GROUPS=false

# Mail settings
MAIL_DRIVER=smtp
Expand Down
21 changes: 0 additions & 21 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

29 changes: 29 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**Steps To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Your Configuration (please complete the following information):**
- Exact BookStack Version (Found in settings):
- PHP Version:
- Using Docker or reverse proxy (Yes/No):

**Additional context**
Add any other context about the problem here.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Describe the feature you'd like**
A clear description of the feature you'd like implemented in BookStack.

**Describe the benefits this feature would bring to BookStack users**
Explain the measurable benefits this feature would achieve.

**Additional context**
Add any other context or screenshots about the feature request here.
12 changes: 11 additions & 1 deletion app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use BookStack\Exceptions\AuthException;
use BookStack\Http\Controllers\Controller;
use BookStack\Repos\UserRepo;
use BookStack\Services\LdapService;
use BookStack\Services\SocialAuthService;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
Expand Down Expand Up @@ -36,18 +37,21 @@ class LoginController extends Controller
protected $redirectAfterLogout = '/login';

protected $socialAuthService;
protected $ldapService;
protected $userRepo;

/**
* Create a new controller instance.
*
* @param SocialAuthService $socialAuthService
* @param LdapService $ldapService
* @param UserRepo $userRepo
*/
public function __construct(SocialAuthService $socialAuthService, UserRepo $userRepo)
public function __construct(SocialAuthService $socialAuthService, LdapService $ldapService, UserRepo $userRepo)
{
$this->middleware('guest', ['only' => ['getLogin', 'postLogin']]);
$this->socialAuthService = $socialAuthService;
$this->ldapService = $ldapService;
$this->userRepo = $userRepo;
$this->redirectPath = baseUrl('/');
$this->redirectAfterLogout = baseUrl('/login');
Expand Down Expand Up @@ -96,6 +100,11 @@ protected function authenticated(Request $request, Authenticatable $user)
auth()->login($user);
}

// Sync LDAP groups if required
if ($this->ldapService->shouldSyncGroups()) {
$this->ldapService->syncGroups($user);
}

$path = session()->pull('url.intended', '/');
$path = baseUrl($path, true);
return redirect($path);
Expand Down Expand Up @@ -125,6 +134,7 @@ public function getLogin(Request $request)
* Redirect to the relevant social site.
* @param $socialDriver
* @return \Symfony\Component\HttpFoundation\RedirectResponse
* @throws \BookStack\Exceptions\SocialDriverNotConfigured
*/
public function getSocialLogin($socialDriver)
{
Expand Down
32 changes: 21 additions & 11 deletions app/Http/Controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use BookStack\Repos\EntityRepo;
use BookStack\Repos\UserRepo;
use BookStack\Services\ExportService;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Views;
Expand Down Expand Up @@ -38,11 +37,18 @@ public function __construct(EntityRepo $entityRepo, ExportService $exportService
* @param string $chapterSlug
* @return Response
* @internal param bool $pageSlug
* @throws NotFoundException
*/
public function create($bookSlug, $chapterSlug = null)
{
$book = $this->entityRepo->getBySlug('book', $bookSlug);
$chapter = $chapterSlug ? $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug) : null;
if ($chapterSlug !== null) {
$chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
$book = $chapter->book;
} else {
$chapter = null;
$book = $this->entityRepo->getBySlug('book', $bookSlug);
}

$parent = $chapter ? $chapter : $book;
$this->checkOwnablePermission('page-create', $parent);

Expand All @@ -52,7 +58,7 @@ public function create($bookSlug, $chapterSlug = null)
return redirect($draft->getUrl());
}

// Otherwise show edit view
// Otherwise show the edit view if they're a guest
$this->setPageTitle(trans('entities.pages_new'));
return view('pages/guest-create', ['parent' => $parent]);
}
Expand All @@ -71,8 +77,14 @@ public function createAsGuest(Request $request, $bookSlug, $chapterSlug = null)
'name' => 'required|string|max:255'
]);

$book = $this->entityRepo->getBySlug('book', $bookSlug);
$chapter = $chapterSlug ? $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug) : null;
if ($chapterSlug !== null) {
$chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
$book = $chapter->book;
} else {
$chapter = null;
$book = $this->entityRepo->getBySlug('book', $bookSlug);
}

$parent = $chapter ? $chapter : $book;
$this->checkOwnablePermission('page-create', $parent);

Expand All @@ -93,7 +105,7 @@ public function createAsGuest(Request $request, $bookSlug, $chapterSlug = null)
public function editDraft($bookSlug, $pageId)
{
$draft = $this->entityRepo->getById('page', $pageId, true);
$this->checkOwnablePermission('page-create', $draft->book);
$this->checkOwnablePermission('page-create', $draft->parent);
$this->setPageTitle(trans('entities.pages_edit_draft'));

$draftsEnabled = $this->signedIn;
Expand All @@ -119,12 +131,10 @@ public function store(Request $request, $bookSlug, $pageId)
]);

$input = $request->all();
$book = $this->entityRepo->getBySlug('book', $bookSlug);

$draftPage = $this->entityRepo->getById('page', $pageId, true);
$book = $draftPage->book;

$chapterId = intval($draftPage->chapter_id);
$parent = $chapterId !== 0 ? $this->entityRepo->getById('chapter', $chapterId) : $book;
$parent = $draftPage->parent;
$this->checkOwnablePermission('page-create', $parent);

if ($parent->isA('chapter')) {
Expand Down
1 change: 1 addition & 0 deletions app/Http/Controllers/PermissionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function editRole($id)
* @param $id
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
* @throws PermissionsException
*/
public function updateRole($id, Request $request)
{
Expand Down
9 changes: 9 additions & 0 deletions app/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public function book()
return $this->belongsTo(Book::class);
}

/**
* Get the parent item
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function parent()
{
return $this->chapter_id ? $this->chapter() : $this->book();
}

/**
* Get the chapter that this page is in, If applicable.
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
Expand Down
1 change: 1 addition & 0 deletions app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class EventServiceProvider extends ServiceProvider
'SocialiteProviders\Okta\OktaExtendSocialite@handle',
'SocialiteProviders\GitLab\GitLabExtendSocialite@handle',
'SocialiteProviders\Twitch\TwitchExtendSocialite@handle',
'SocialiteProviders\Discord\DiscordExtendSocialite@handle',
],
];

Expand Down
2 changes: 1 addition & 1 deletion app/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Role extends Model
{

protected $fillable = ['display_name', 'description'];
protected $fillable = ['display_name', 'description', 'external_auth_id'];

/**
* The roles that belong to the role.
Expand Down
Loading

0 comments on commit 6a7d7e7

Please sign in to comment.