]> BookStack Code Mirror - website/blob - content/docs/admin/third-party-auth.md
b5fdfe972e50ed238e1ad8fe84a0cd06442109fc
[website] / content / docs / admin / third-party-auth.md
1 +++
2 title = "Third Party Authentication"
3 description = "Enabling and configuring third-party authentication for easier logins"
4 date = "2017-01-01"
5 type = "admin-doc"
6 aliases = [
7     "/docs/admin/social-auth"
8 ]
9 +++
10
11 BookStack currently supports login via a range of third party and social applications. 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.
12
13 #### Available Services
14
15 * [Google](#google)
16 * [GitHub](#github)
17 * [Twitter](#twitter)
18 * [Facebook](#facebook)
19 * [Slack](#slack)
20 * [AzureAD (Microsoft)](#azuread-microsoft)
21 * [Okta](#okta)
22 * [GitLab](#gitlab)
23 * [Twitch](#twitch)
24
25 ---
26
27 ### Google
28
29 1. Open the [Google Developers Console](https://console.developers.google.com/).
30 2. Create a new project (May have to wait a short while for it to be created).
31 3. Select 'Enable and manage APIs'.
32 4. Enable the 'Google+ API'.
33 5. In 'Credentials' choose the 'OAuth consent screen' tab and enter a product name ('BookStack' or your custom set name).
34 6. Back in the 'Credentials' tab click 'New credentials' > 'OAuth client ID'.
35 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:
36     - `https://example.com/login/service/google/callback`
37     - `https://example.com/register/service/google/callback`
38 8. Add or set the following items in your `.env` file like so:
39         ```bash
40         # Replace the below (including '{}' braces) with your Google API_KEY and API_SECRET
41         GOOGLE_APP_ID={google_app_id}
42         GOOGLE_APP_SECRET={google_app_secret}
43
44         # APP_URL Needs to be set to your BookStack base url
45         APP_URL=http://mybookstackurl.com
46         ```
47 10. All done! Users should now be able to link their social accounts in their account profile pages and also register/login using their Google accounts.
48
49 ---
50
51 ### GitHub
52
53 1. While logged in, open up your [GitHub developer applications](https://github.com/settings/developers).
54 2. Click 'Register new application'.
55 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'.
56 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.
57 5. Set the 'APP_URL' environment variable to be the same domain as you entered in step 3.
58 6. All done! Users should now be able to link their social accounts in their account profile pages and also register/login using their Github account.
59
60 ---
61
62 ### Twitter
63
64 To create a Twitter application for signing in with you may require a phone number linked to your Twitter account.
65
66 1. Go to your [Twitter apps page](https://apps.twitter.com/) and click 'Create New App'.
67 2. Enter an application name and description. The website and callback URL can just be your BookStack homepage urls. Then submit the form.
68 3. Click into your new application and go the the settings tab and ensure 'Allow this application to be used to Sign in with Twitter' is checked.
69 4. If you'd like, set an icon and change any other details.
70 5. Click the 'Permissions' tab and in the 'Additional Permissions' section check the box 'Request email addresses from users' then save.
71 6. Go to the 'Keys and Access Tokens' tab to find your API key and secret. Add or set these to your `.env` file like so:
72         ```bash
73         # Replace the below (including '{}' braces) with your twitter API_KEY and API_SECRET
74         TWITTER_APP_ID={API_KEY}
75         TWITTER_APP_SECRET={API_SECRET}
76
77         # APP_URL Needs to be set to your BookStack base url
78         APP_URL=http://mybookstackurl.com
79         ```
80 7. All done! Users should now be able to link their Twitter account in their account profile pages and also register/login using their Twitter account.
81
82 ---
83
84 ### Facebook
85
86 1. Navigate to the [Facebook developers page](https://developers.facebook.com) then go 'My Apps' -> 'Add a New App'.
87 2. Enter an app name ('BookStack login' or something custom) and contact email then continue.
88 3. In your new app select 'Add Product' on the left sidebar then choose 'Facebook Login' by clicking the 'Get Started' button. Select the 'Web' option if asked to choose a platform.
89 4. Enter the your base BookStack url into the 'Site URL' box and save.
90 5. On the left sidebar again go to 'Facebook Login' -> 'Settings'.
91 6. Enter your base BookStack URL again into the 'Valid OAuth redirect URIs' input and save.
92 7. Navigate back to the app 'Dashboard' in the sidebar to find your app id and secret. Add or set these to your `.env` file like so:
93         ```bash
94         # Replace the below (including '{}' braces) with your facebook APP_KEY and APP_SECRET
95         FACEBOOK_APP_ID={APP_KEY}
96         FACEBOOK_APP_SECRET={APP_SECRET}
97
98         # APP_URL Needs to be set to your BookStack base url
99         APP_URL=http://mybookstackurl.com
100         ```
101 7. All done! Users should now be able to link their Facebook account in their account profile pages and also register/login using their Facebook account.
102
103 ---
104
105 ### Slack
106
107 1. Go to the [Slack apps page](https://api.slack.com/apps) and select 'Create New App'.
108 2. Enter an app name ('BookStack login' or something custom), select your team then continue.
109 3. You should see your client ID and secret. Copy these details and add them as new variables in your `.env` file like so:
110         ```bash
111         # Replace the below (including '{}' braces) with your slack CLIENT_ID and CLIENT_SECRET
112         SLACK_APP_ID={CLIENT_ID}
113         SLACK_APP_SECRET={CLIENT_SECRET}
114
115         # APP_URL Needs to be set to your BookStack base url
116         APP_URL=http://mybookstackurl.com
117         ```
118 4. In your slack app go to 'OAuth & Permissions' and enter your BookStack base URL into the 'Redirect URL(s)' input then save.
119 5. All done! Users should now be able to link their Slack account in their account profile pages and also register/login using their Slack account.
120
121 ---
122
123 ### AzureAD (Microsoft)
124
125 1. Login to your your azure portal and navigate to the 'Azure Activity Directory' area.
126 2. Under 'Manage > App registrations' select 'New application registration'.
127 3. Enter a name ('BookStack'). Keep the 'Application type' as 'Web app / API'. Set the 'Sign-on URL' to be the main URL to your BookStack instance.
128 4. Once created, Click on your new application and note the 'Application ID'. This is the APP_ID value for step 9.
129 5. Within your application in azure, Navigate to 'Keys' under 'API access'.
130 6. Enter any description you want and set a duration ('Never expires' is okay unless you specifically want it to expire). Then click 'Save'.
131 7. Copy the string of characters under 'Value'. This is the APP_SECRET value for step 9 and is only shown once.
132 8. Back under 'App registrations' click on 'Endpoints'. This will show a list of URL's that each contain a unique ID. For example, the OAuth2 token endpoint will look something like this: `https://login.microsoftonline.com/<UniqueID>/oauth2/token`. Copy out the unique ID. This is the TENANT value for step 9.
133 9. Copy these details and add them as new variables in your `.env` file like so:
134         ```bash
135         # Replace the below (including '{}' braces) with your azure APP_ID and APP_SECRET and TENANT
136         AZURE_APP_ID={APP_ID}
137         AZURE_APP_SECRET={APP_SECRET}
138         AZURE_TENANT={TENANT}
139
140         # APP_URL Needs to be set to your BookStack base url
141         APP_URL=http://mybookstackurl.com
142         ```
143 10. All done! Users should now be able to link their AzureAD account in their account profile pages and also register/login using their Slack account.
144
145 ---
146
147 ### Okta
148
149 1. Login to Okta and, once logged in, Note the current URL. This is used for the 'BASE_URL' in step 6.
150 2. Navigate to the Admin panel then 'Applications' then select 'Add Application'. Then select 'Create New App' on the left.
151 3. For the 'Platform' choose 'Web'. For the 'Sign on method' choose 'OpenID Connect' then click 'Create'.
152 4. Give the app a name such as 'BookStack' or 'Our documentation'. Under the 'Login redirect URIs' option add both of the below URLs, Changing `https://example.com` to the base URL of your BookStack instance:
153     - `https://example.com/login/service/okta/callback`
154     - `https://example.com/register/service/okta/callback`
155 5. Save and scroll down to the 'Client Credentials' area. Copy the 'Client ID' and 'Client secret' values. These are your 'APP_ID' and 'APP_SECRET' values for step 6.
156 6. Copy these details and add them as new variables in your `.env` file like so:
157         ```bash
158         # Replace the below (including '{}' braces) with your okta APP_ID and APP_SECRET and BASE_URL.
159         OKTA_APP_ID={APP_ID}
160         OKTA_APP_SECRET={APP_SECRET}
161         # The base URL is the URL from step 1 but with everything after the domain (okta.com) removed.
162         OKTA_BASE_URL={BASE_URL}
163
164         # APP_URL Needs to be set to your BookStack base url
165         APP_URL=http://mybookstackurl.com
166         ```
167 7. All set up! Remember to assign the new application you created in Okta to your Okta users otherwise they will not be able to register/login using the service.
168
169 ---
170
171 ### GitLab
172
173 GitLab authentication works for both [gitlab.com](https://gitlab.com) and self-hosted GitLab instances.
174
175 1. Login to GitLab and go to your user settings.
176 2. In the left sidebar select 'Applications'.
177 3. Set a name to identify the application, such as 'BookStack Authentication', and in the 'Redirect URI' input add both of the below URLs, Changing `https://example.com` to the base URL of your BookStack instance:
178     - `https://example.com/login/service/gitlab/callback`
179     - `https://example.com/register/service/gitlab/callback`
180 4. Do not select any of the 'Scopes' checkboxes.
181 5. Press 'Save application'. You will be shown the application ID and secret which you'll need for the next step.  
182 6. Copy the below details and add them as new variables in your `.env` file like so:
183     ```bash
184     # Replace the below (including '{}' braces) with your GitLab Application Id and Secret values.
185     GITLAB_APP_ID={APP_ID}
186     GITLAB_APP_SECRET={APP_SECRET}
187
188     # APP_URL Needs to be set to your BookStack base url
189     APP_URL=http://mybookstackurl.com
190
191
192     # ONLY REQURED FOR SELF-HOSTED GITLAB INSTANCES - REMOVE FOR GITLAB.COM
193     # Set the below URI to match the base URI of your GitLab install
194     GITLAB_BASE_URI=http://my-custom-gitlab.example.com
195     ```
196 7. All set up! Users will now be able to use GitLab to sign-in and register.
197
198 ---
199
200 ### Twitch
201
202 To allow twich sign-in you'll first need to create an application from the Twitch developer site. Here's the process:
203
204 1. Login into the [Twitch developer website](https://dev.twitch.tv/).
205 2. Navigate to your 'Dashboard' then ['Apps'](https://dev.twitch.tv/dashboard/apps) and select 'Register Your Application'.
206 3. Set a name to identify the application, such as 'BookStack Authentication', and in the 'OAuth Redirect URI' input add the below URL, Changing `https://example.com` to the base URL of your BookStack instance:
207     - `https://example.com/login/service/twitch/callback`
208 4. Under the 'Application Category' option select 'Website Integration' then hit 'Register'.
209 5. Click the 'New Secret' button and accept the prompt that appears. You should now see both a 'Client ID' and 'Client Secret' value which you'll use in the next step.
210 6. Copy the below details and add them as new variables in your `.env` file like so:
211     ```bash
212     # Replace the below (including '{}' braces) with your Twitch Application Id and Secret values.
213     TWITCH_APP_ID={APP_ID}
214     TWITCH_APP_SECRET={APP_SECRET}
215
216     # APP_URL Needs to be set to your BookStack base url
217     APP_URL=http://mybookstackurl.com
218     ```
219 7. All set up! Users will now be able to use Twitch to sign-in and register.