]> BookStack Code Mirror - bookstack/blob - readme.md
Increased LDAP testing and fixed any Auth-based bugs found
[bookstack] / readme.md
1 # BookStack
2
3 A platform to create documentation/wiki content. General information about BookStack can be found at https://www.bookstackapp.com/
4
5 1. [Requirements](#requirements)
6 2. [Installation](#installation)
7   - [Server Rewrite Rules](#url-rewrite-rules)
8 3. [Updating](#updating-bookstack)
9 4. [Social Authentication](#social-authentication)
10  - [Google](#google)
11  - [GitHub](#github)
12 5. [LDAP Authentication](#ldap-authentication)
13 6. [Testing](#testing)
14 7. [License](#license)
15 8. [Attribution](#attribution)
16
17
18 ## Requirements
19
20 BookStack has similar requirements to Laravel. On top of those are some front-end build tools which are only required when developing.
21
22 * PHP >= 5.5.9, Will need to be usable from the command line.
23 * OpenSSL PHP Extension
24 * PDO PHP Extension
25 * MBstring PHP Extension
26 * Tokenizer PHP Extension
27 * MySQL >= 5.6
28 * Git (Not strictly required but helps manage updates)
29 * [Composer](https://getcomposer.org/)
30 * [Node.js](https://nodejs.org/en/) **Development Only**
31 * [Gulp](http://gulpjs.com/) **Development Only**
32
33
34 ## Installation
35
36 Ensure the above requirements are met before installing. Currently BookStack requires its own domain/subdomain and will not work in a site subdirectory.
37
38 This project currently uses the `release` branch of this repository as a stable channel for providing updates.
39
40 The installation is currently somewhat complicated and will be made simpler in future releases. Some PHP/Laravel experience will currently benefit.
41
42 1. Clone the release branch of this repository into a folder.
43
44 ```
45 git clone https://github.com/ssddanbrown/BookStack.git --branch release --single-branch
46 ```
47
48 2. `cd` into the application folder and run `composer install`.
49 3. Copy the `.env.example` file to `.env` and fill with your own database and mail details.
50 4. Ensure the `storage` & `bootstrap/cache` folders are writable by the web server.
51 5. In the application root, Run `php artisan key:generate` to generate a unique application key.
52 6. If not using apache or if `.htaccess` files are disabled you will have to create some URL rewrite rules as shown below.
53 7. Run `php artisan migrate` to update the database.
54 8. Done! You can now login using the default admin details `[email protected]` with a password of `password`. It is recommended to change these details directly after first logging in.
55
56 #### URL Rewrite rules
57
58 **Apache**
59 ```
60 Options +FollowSymLinks
61 RewriteEngine On
62
63 RewriteCond %{REQUEST_FILENAME} !-d
64 RewriteCond %{REQUEST_FILENAME} !-f
65 RewriteRule ^ index.php [L]
66 ```
67
68 **Nginx**
69 ```
70 location / {
71     try_files $uri $uri/ /index.php?$query_string;
72 }
73 ```
74 ## Updating BookStack
75
76 To update BookStack you can run the following command in the root directory of the application:
77 ```
78 git pull origin release && composer install && php artisan migrate
79 ```
80 This command will update the repository that was created in the installation, install the PHP dependencies using `composer` then run the database migrations.
81
82 ## Social Authentication
83
84 BookStack currently supports login via both Google and GitHub. Once enabled options for these services will show up in the login, registration and user profile pages. By default these services are disabled. To enable them you will have to create an application on the external services to obtain the require application id's and secrets. Here are instructions to do this for the current supported services:
85
86 ### Google
87
88 1. Open the [Google Developers Console](https://console.developers.google.com/).
89 2. Create a new project (May have to wait a short while for it to be created).
90 3. Select 'Enable and manage APIs'.
91 4. Enable the 'Google+ API'.
92 5. In 'Credentials' choose the 'OAuth consent screen' tab and enter a product name ('BookStack' or your custom set name).
93 6. Back in the 'Credentials' tab click 'New credentials' > 'OAuth client ID'.
94 7. Choose an application type of 'Web application' and enter the following urls under 'Authorized redirect URIs', changing `https://example.com` to your own domain where BookStack is hosted:
95     - `https://example.com/login/service/google/callback`
96     - `https://example.com/register/service/google/callback`
97 8. Click 'Create' and your app_id and secret will be displayed. Replace the false value on both the `GOOGLE_APP_ID` & `GOOGLE_APP_SECRET` variables in the '.env' file in the BookStack root directory with your own app_id and secret.
98 9. Set the 'APP_URL' environment variable to be the same domain as you entered in step 7. So, in this example, it will be `https://example.com`.
99 10. All done! Users should now be able to link to their social accounts in their account profile pages and also register/login using their Google accounts.
100
101 ### Github
102
103 1. While logged in, open up your [GitHub developer applications](https://github.com/settings/developers).
104 2. Click 'Register new application'.
105 3. Enter an application name ('BookStack' or your custom set name), A link to your app instance under 'Homepage URL' and an 'Authorization callback URL' of the url that your BookStack instance is hosted on then click 'Register application'.
106 4. A 'Client ID' and a 'Client Secret' value will be shown. Add these two values to the to the `GITHUB_APP_ID` and `GITHUB_APP_SECRET` variables, replacing the default false value, in the '.env' file found in the BookStack root folder.
107 5. Set the 'APP_URL' environment variable to be the same domain as you entered in step 3.
108 6. All done! Users should now be able to link to their social accounts in their account profile pages and also register/login using their Github account.
109
110 ## LDAP Authentication
111
112 BookStack can be configured to allow LDAP based user login. While LDAP login is enabled you cannot log in with the standard user/password login and new user registration is disabled. BookStack will only use the LDAP server for getting user details and for authentication. Data on the LDAP server is not currently editable through BookStack.
113
114 When a LDAP user logs into BookStack for the first time their BookStack profile will be created and they will be given the default role set under the 'Default user role after registration' option in the application settings.    
115
116 To set up LDAP-based authentication add or modify the following variables in your `.env` file:
117
118 ```
119 # General auth
120 AUTH_METHOD=ldap
121
122 # The LDAP host, Adding a port is optional
123 LDAP_SERVER=ldap://example.com:389
124
125 # The base DN from where users will be searched within.
126 LDAP_BASE_DN=ou=People,dc=example,dc=com
127
128 # The full DN and password of the user used to search the server
129 # Can both be left as false to bind anonymously
130 LDAP_DN=false
131 LDAP_PASS=false
132
133 # A filter to use when searching for users
134 # The user-provided user-name used to replace any occurrences of '${user}'
135 LDAP_USER_FILTER=(&(uid=${user}))
136
137 # Set the LDAP version to use when connecting to the server.
138 LDAP_VERSION=false
139 ```
140
141 You will also need to have the php-ldap extension installed on your system. It's recommended to change your `APP_DEBUG` variable to `true` while setting up LDAP to make any errors visible. Remember to change this back after LDAP is functioning.
142
143 A user in BookStack will be linked to a LDAP user via a 'uid'. If a LDAP user uid changes it can be updated in BookStack by an admin by changing the 'External Authentication ID' field on the user's profile.
144
145 You may find that you cannot log in with your initial Admin account after changing the `AUTH_METHOD` to `ldap`. To get around this set the `AUTH_METHOD` to `standard`, login with your admin account then change it back to `ldap`. You get then edit your profile and add your LDAP uid under the 'External Authentication ID' field. You will then be able to login in with that ID.
146
147 ## Testing
148
149 BookStack has many integration tests that use Laravel's built-in testing capabilities which makes use of PHPUnit. To use you will need PHPUnit installed and accessible via command line. There is a `mysql_testing` database defined within the app config which is what is used by PHPUnit. This database is set with the following database name, user name and password defined as `bookstack-test`. You will have to create that database and credentials before testing.
150
151 The testing database will also need migrating and seeding beforehand. This can be done with the following commands:
152
153 ```
154 php artisan migrate --database=mysql_testing
155 php artisan db:seed --class=DummyContentSeeder --database=mysql_testing
156 ```
157
158 Once done you can run `phpunit` (or `./vendor/bin/phpunit` if `phpunit` is not found) in the application root directory to run all tests.
159
160 ## License
161
162 BookStack is provided under the MIT License.
163
164 ## Attribution
165
166 These are the great projects used to help build BookStack:
167
168 * [Laravel](http://laravel.com/)
169 * [AngularJS](https://angularjs.org/)
170 * [jQuery](https://jquery.com/)
171 * [TinyMCE](https://www.tinymce.com/)
172 * [highlight.js](https://highlightjs.org/)
173 * [jQuery Sortable](https://johnny.github.io/jquery-sortable/)
174 * [Material Design Iconic Font](http://zavoloklom.github.io/material-design-iconic-font/icons.html)
175 * [Dropzone.js](http://www.dropzonejs.com/)
176 * [ZeroClipboard](http://zeroclipboard.org/)