@@ -75,3 +75,138 @@ To do this Click your profile icon --> Settings and privacy --> Mobile --> Sele
7575 HMD_GITHUB_CLIENTID=3747d30eaccXXXXXXXXX
7676 HMD_GITHUB_CLIENTSECRET=2a8e682948eee0c580XXXXXXXXXXXXXXXXXXXXXX
7777 ````
78+
79+ ### SAML (OneLogin)
80+ 1. Sign-in or sign-up for an OneLogin account. (available free trial for 2 weeks)
81+ 2. Go to the administration page.
82+ 3. Select the **APPS** menu and click on the **Add Apps**.
83+
84+ 
85+
86+ 4. Find "SAML Test Connector (SP)" for template of settings and select it.
87+
88+ 
89+
90+ 5. Edit display name and icons for OneLogin dashboard as you want, and click **SAVE**.
91+
92+ 
93+
94+ 6. After that other tabs will appear, click the **Configuration**, and fill out the below items, and click **SAVE**.
95+ * RelayState: The base URL of your hackmd, which is issuer. (last slash is not needed)
96+ * ACS (Consumer) URL Validator: The callback URL of your hackmd. (serverurl + /auth/saml/callback)
97+ * ACS (Consumer) URL: same as above.
98+ * Login URL: login URL(SAML requester) of your hackmd. (serverurl + /auth/saml)
99+
100+ 
101+
102+ 7. The registration is completed. Next, click **SSO** and copy or download the items below.
103+ * X.509 Certificate: Click **View Details** and **DOWNLOAD** or copy the content of certificate ....(A)
104+ * SAML 2.0 Endpoint (HTTP): Copy the URL ....(B)
105+
106+ 
107+
108+ 8. In your hackmd server, create IdP certificate file from (A)
109+ 9. Add the IdP URL (B) and the Idp certificate file path to your config.json file or pass them as environment variables.
110+ * config.json:
111+ ````javascript
112+ {
113+ "production": {
114+ "saml": {
115+ "idpSsoUrl": "https://*******.onelogin.com/trust/saml2/http-post/sso/******",
116+ "idpCert": "/path/to/idp_cert.pem"
117+ }
118+ }
119+ }
120+ ````
121+ * environment variables
122+ ````
123+ HMD_SAML_IDPSSOURL=https://*******.onelogin.com/trust/saml2/http-post/sso/******
124+ HMD_SAML_IDPCERT=/path/to/idp_cert.pem
125+ ````
126+ 10. Try sign-in with SAML from your hackmd sign-in button or OneLogin dashboard (like the screenshot below).
127+
128+ 
129+
130+ ### SAML (Other cases)
131+ The basic procedure is the same as the case of OneLogin which is mentioned above. If you want to match your IdP, you can use more configurations as below.
132+
133+ * If your IdP accepts metadata XML of the service provider to ease configuraion, use this url to download metadata XML.
134+ * {{your-serverurl}}/auth/saml/metadata
135+ * _Note: If not accessable from IdP, download to local once and upload to IdP._
136+ * Change the value of `issuer`, `identifierFormat` to match your IdP.
137+ * `issuer`: A unique id to identify the application to the IdP, which is the base URL of your HackMD as default
138+ * `identifierFormat`: A format of unique id to identify the user of IdP, which is the format based on email address as default. It is recommend that you use as below.
139+ * urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress (default)
140+ * urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified
141+ * config.json:
142+ ````javascript
143+ {
144+ "production": {
145+ "saml": {
146+ /* omitted */
147+ "issuer": "myhackmd"
148+ "identifierFormat": "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"
149+ }
150+ }
151+ }
152+ ````
153+ * environment variables
154+ ````
155+ HMD_SAML_ISSUER=myhackmd
156+ HMD_SAML_IDENTIFIERFORMAT=urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified
157+ ````
158+
159+ * Change mapping of attribute names to customize the displaying user name and email address to match your IdP.
160+ * `attribute`: A dictionary to map attribute names
161+ * `attribute.id`: A primary key of user table for your HackMD
162+ * `attribute.username`: Attribute name of displaying user name on HackMD
163+ * `attribute.email`: Attribute name of email address, which will be also used for Gravatar
164+ * _Note: Default value of all attributes is NameID of SAML response, which is email address if `idfentifierFormat` is default._
165+ * config.json:
166+ ````javascript
167+ {
168+ "production": {
169+ "saml": {
170+ /* omitted */
171+ "attribute": {
172+ "id": "sAMAccountName",
173+ "username": "displayName",
174+ "email": "mail"
175+ }
176+ }
177+ }
178+ }
179+ ````
180+ * environment variables
181+ ````
182+ HMD_SAML_ATTRIBUTE_ID=sAMAccountName
183+ HMD_SAML_ATTRIBUTE_USERNAME=nickName
184+ HMD_SAML_ATTRIBUTE_EMAIL=mail
185+ ````
186+
187+ * If you want to controll permission by group membership, add group attribute name and required group (allowed) or external group (not allowed).
188+ * `groupAttribute`: An attribute name of group membership
189+ * `requiredGroups`: Group names array for allowed access to HackMD. Use vertical bar to separate for environment variables.
190+ * `externalGroups`: Group names array for not allowed access to HackMD. Use vertical bar to separate for environment variables.
191+ * _Note: Evaluates `externalGroups` first_
192+ * config.json:
193+ ````javascript
194+ {
195+ "production": {
196+ "saml": {
197+ /* omitted */
198+ "groupAttribute": "memberOf",
199+ "requiredGroups": [ "hackmd-users", "board-members" ],
200+ "externalGroups": [ "temporary-staff" ]
201+ }
202+ }
203+ }
204+ ````
205+ * environment variables
206+ ````
207+ HMD_SAML_GROUPATTRIBUTE=memberOf
208+ HMD_SAML_REQUIREDGROUPS=hackmd-users|board-members
209+ HMD_SAML_EXTERNALGROUPS=temporary-staff
210+ ````
211+
212+
0 commit comments