Skip to content

Commit 3f7a33d

Browse files
authored
Merge pull request #783 from SISheogorath/docs/splitAuth
Split authentication guides into multiple documents
2 parents 94e015d + 3251bcb commit 3f7a33d

6 files changed

Lines changed: 243 additions & 241 deletions

File tree

docs/guides/auth.md

Lines changed: 0 additions & 241 deletions
This file was deleted.

docs/guides/auth/github.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Authentication guide - GitHub
2+
===
3+
4+
1. Sign-in or sign-up for a GitHub account
5+
2. Navigate to developer settings in your GitHub account [here](https://github.com/settings/developers) and select the "OAuth Apps" tab
6+
3. Click on the **New OAuth App** button, to create a new OAuth App:
7+
8+
![create-oauth-app](../images/auth/create-oauth-app.png)
9+
10+
4. Fill out the new OAuth application registration form, and click **Register Application**
11+
12+
![register-oauth-application-form](../images/auth/register-oauth-application-form.png)
13+
14+
*Note: The callback URL is <your-hackmd-url>/auth/github/callback*
15+
16+
5. After successfully registering the application, you'll receive the Client ID and Client Secret for the application
17+
18+
![application-page](../images/auth/application-page.png)
19+
20+
6. Add the Client ID and Client Secret to your config.json file or pass them as environment variables
21+
* config.json:
22+
````javascript
23+
{
24+
"production": {
25+
"github": {
26+
"clientID": "3747d30eaccXXXXXXXXX",
27+
"clientSecret": "2a8e682948eee0c580XXXXXXXXXXXXXXXXXXXXXX"
28+
}
29+
}
30+
}
31+
````
32+
* environment variables:
33+
````
34+
HMD_GITHUB_CLIENTID=3747d30eaccXXXXXXXXX
35+
HMD_GITHUB_CLIENTSECRET=2a8e682948eee0c580XXXXXXXXXXXXXXXXXXXXXX
36+
````
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# GitLab (self-hosted)
2+
===
3+
4+
1. Sign in to your GitLab
5+
2. Navigate to the application management page at `https://your.gitlab.domain/admin/applications` (admin permissions required)
6+
3. Click **New application** to create a new application and fill out the registration form:
7+
8+
![New GitLab application](images/auth/gitlab-new-application.png)
9+
10+
4. Click **Submit**
11+
5. In the list of applications select **HackMD**. Leave that site open to copy the application ID and secret in the next step.
12+
13+
![Application: HackMD](images/auth/gitlab-application-details.png)
14+
15+
16+
6. In the `docker-compose.yml` add the following environment variables to `app:` `environment:`
17+
18+
```
19+
- HMD_DOMAIN=your.hackmd.domain
20+
- HMD_URL_ADDPORT=443
21+
- HMD_PROTOCOL_USESSL=true
22+
- HMD_GITLAB_BASEURL=https://your.gitlab.domain
23+
- HMD_GITLAB_CLIENTID=23462a34example99XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
24+
- HMD_GITLAB_CLIENTSECRET=5532e9dexamplXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
25+
```
26+
27+
7. Run `docker-compose up -d` to apply your settings.
28+
8. Sign in to your HackMD using your GitLab ID:
29+
30+
![Sign in via GitLab](images/auth/gitlab-sign-in.png)

docs/guides/auth/saml-onelogin.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Authentication guide - SAML (OneLogin)
2+
===
3+
4+
1. Sign-in or sign-up for an OneLogin account. (available free trial for 2 weeks)
5+
2. Go to the administration page.
6+
3. Select the **APPS** menu and click on the **Add Apps**.
7+
8+
![onelogin-add-app](../images/auth/onelogin-add-app.png)
9+
10+
4. Find "SAML Test Connector (SP)" for template of settings and select it.
11+
12+
![onelogin-select-template](../images/auth/onelogin-select-template.png)
13+
14+
5. Edit display name and icons for OneLogin dashboard as you want, and click **SAVE**.
15+
16+
![onelogin-edit-app-name](../images/auth/onelogin-edit-app-name.png)
17+
18+
6. After that other tabs will appear, click the **Configuration**, and fill out the below items, and click **SAVE**.
19+
* RelayState: The base URL of your hackmd, which is issuer. (last slash is not needed)
20+
* ACS (Consumer) URL Validator: The callback URL of your hackmd. (serverurl + /auth/saml/callback)
21+
* ACS (Consumer) URL: same as above.
22+
* Login URL: login URL(SAML requester) of your hackmd. (serverurl + /auth/saml)
23+
24+
![onelogin-edit-sp-metadata](../images/auth/onelogin-edit-sp-metadata.png)
25+
26+
7. The registration is completed. Next, click **SSO** and copy or download the items below.
27+
* X.509 Certificate: Click **View Details** and **DOWNLOAD** or copy the content of certificate ....(A)
28+
* SAML 2.0 Endpoint (HTTP): Copy the URL ....(B)
29+
30+
![onelogin-copy-idp-metadata](../images/auth/onelogin-copy-idp-metadata.png)
31+
32+
8. In your hackmd server, create IdP certificate file from (A)
33+
9. Add the IdP URL (B) and the Idp certificate file path to your config.json file or pass them as environment variables.
34+
* config.json:
35+
````javascript
36+
{
37+
"production": {
38+
"saml": {
39+
"idpSsoUrl": "https://*******.onelogin.com/trust/saml2/http-post/sso/******",
40+
"idpCert": "/path/to/idp_cert.pem"
41+
}
42+
}
43+
}
44+
````
45+
* environment variables
46+
````
47+
HMD_SAML_IDPSSOURL=https://*******.onelogin.com/trust/saml2/http-post/sso/******
48+
HMD_SAML_IDPCERT=/path/to/idp_cert.pem
49+
````
50+
10. Try sign-in with SAML from your hackmd sign-in button or OneLogin dashboard (like the screenshot below).
51+
52+
![onelogin-use-dashboard](../images/auth/onelogin-use-dashboard.png)

0 commit comments

Comments
 (0)