Debian Codegraph @

doc/sources/admin/applications/simplesamlphp.rst

raw
1 simpleSAMLphp
2 =============
3
4 |image0|
5
6 Presentation
7 ------------
8
9 `simpleSAMLphp <https://simplesamlphp.org/>`__ is an identity/service
10 provider written in PHP. It supports a lot of protocols like CAS, OpenID
11 and SAML.
12
13 This documentation explains how to interconnect LemonLDAP::NG and
14 simpleSAMLphp using SAML 2.0 protocol.
15
16 Pre-requisites
17 --------------
18
19 .. _simplesamlphp-1:
20
21 simpleSAMLphp
22 ~~~~~~~~~~~~~
23
24 You need to `install the
25 software <https://simplesamlphp.org/docs/stable/simplesamlphp-install>`__.
26 If using Debian, just run:
27
28 ::
29
30 apt install simplesamlphp
31
32 We suppose that configuration is done in ``/etc/simplesamlphp`` and that
33 simpleSAMLphp is accessible at http://localhost/simplesamlphp.
34
35 To be able to sign SAML messages, you need to create a certificate.
36 First set where certificates are stored:
37
38 ::
39
40 vi /etc/simplesamlphp/config.php
41
42 .. code-block:: php
43
44 'certdir' => '/etc/simplesamlphp/certs/',
45
46 Create directory and generate the certificate
47
48 ::
49
50 mkdir /etc/simplesamlphp/certs/
51 cd /etc/simplesamlphp/certs/
52 openssl req -newkey rsa:2048 -new -x509 -days 3652 -nodes -out saml.crt -keyout saml.pem
53
54 Then associate this certificate to the default SP:
55
56 ::
57
58 vi /etc/simplesamlphp/authsources.php
59
60 .. code-block:: php
61
62 'default-sp' => array(
63 'saml:SP',
64 'privatekey' => 'saml.pem',
65 'certificate' => 'saml.crt',
66
67 LemonLDAP::NG
68 ~~~~~~~~~~~~~
69
70 You need to configure :doc:`SAML Service<../samlservice>`. Be sure to
71 convert public key in a certificate, as described in the
72 :doc:`security chapter<../samlservice>` as simpleSAMLphp can't use the
73 public key.
74
75 simpleSAMLphp as Service Provider
76 ---------------------------------
77
78 We suppose you configured LemonLDAP::NG as
79 :doc:`SAML Identity Provider<../idpsaml>` and want to use simpleSAMLphp
80 as Service Provider.
81
82 In LL::NG Manager, create an new SP and load simpleSAMLphp metadata
83 through URL (by default:
84 http://localhost/simplesamlphp/module.php/saml/sp/metadata.php/default-sp):
85
86 |image1|
87
88 Then set some attributes that will be sent to simpleSAMLphp:
89
90 |image2|
91
92
93 .. tip::
94
95 Set ``Mandatory`` to ``On`` to force attributes in
96 authentication response.
97
98 You can also force all signatures:
99
100 |image3|
101
102 On simpleSAMLphp side, use the metadata converter (by default:
103 http://localhost/simplesamlphp/admin/metadata-converter.php) to convert
104 LL::NG metadata (by default: http://auth.example.com/saml/metadata) into
105 internal PHP representation. Copy the ``saml20-idp-remote`` content:
106
107 ::
108
109 vi /etc/simplesamlphp/metadata/saml20-idp-remote.php
110
111 .. code-block:: php
112
113 <?php
114 $metadata['http://auth.example.com/saml/metadata'] = array (
115 'entityid' => 'http://auth.example.com/saml/metadata',
116 ...
117 // Add this option to force SLO requests signature
118 'sign.logout' => true,
119 );
120 ?>
121
122
123 .. tip::
124
125 Don't forget PHP start and end tag to have a valid PHP
126 file.
127
128 All is ready, you can now test the authentication (by default:
129 http://localhost/simplesamlphp/module.php/core/authenticate.php). You
130 should see something like that:
131
132 |image4|
133
134 simpleSAMLphp as Identity Provider
135 ----------------------------------
136
137 We suppose you configured LemonLDAP::NG as
138 :doc:`SAML Service Provider<../authsaml>` and want to use simpleSAMLphp
139 as Identity Provider.
140
141 First, you need to activate IDP feature in simpleSAMLphp:
142
143 ::
144
145 vi /etc/simplesamlphp/config.php
146
147 .. code-block:: php
148
149 'enable.saml20-idp' => true,
150
151 And create a default IDP configuration:
152
153 ::
154
155 vi /etc/simplesamlphp/metadata/saml20-idp-hosted.php
156
157 .. code-block:: php
158
159 <?php
160 $metadata['__DYNAMIC:1__'] = array(
161 /*
162 * The hostname for this IdP. This makes it possible to run multiple
163 * IdPs from the same configuration. '__DEFAULT__' means that this one
164 * should be used by default.
165 */
166 'host' => '__DEFAULT__',
167
168 /*
169 * The private key and certificate to use when signing responses.
170 * These are stored in the cert-directory.
171 */
172 'privatekey' => 'saml.pem',
173 'certificate' => 'saml.crt',
174
175 /*
176 * The authentication source which should be used to authenticate the
177 * user. This must match one of the entries in config/authsources.php.
178 */
179 'auth' => 'admin',
180 // Sign SLO messages
181 'sign.logout' => true,
182 );
183 ?>
184
185
186 .. attention::
187
188 You need to configure your own certificates and
189 authentication scheme
190
191 Now in LL::NG Manager, create a new IDP and import metadata with URL (by
192 default: http://localhost/simplesamlphp/saml2/idp/metadata.php):
193
194 |image5|
195
196 List attributes you want to collect:
197
198 |image6|
199
200
201 .. tip::
202
203 You can keep ``Mandatory`` to ``Off`` to not fail if attribute
204 is not sent by IDP
205
206 And activate all signatures:
207
208 |image7|
209
210 To finish, you need to declare LL::NG SP in simpleSAMLphp. Use the
211 metadata converter (by default:
212 http://localhost/simplesamlphp/admin/metadata-converter.php) to convert
213 LL::NG metadata (by default: http://auth.example.com/saml/metadata) into
214 internal PHP representation. Copy the ``saml20-sp-remote`` content:
215
216 ::
217
218 vi /etc/simplesamlphp/metadata/saml20-sp-remote.php
219
220 .. code-block:: php
221
222 <?php
223 $metadata['http://auth.example.com/saml/metadata'] = array (
224 'entityid' => 'http://auth.example.com/saml/metadata',
225 ...
226 );
227 ?>
228
229
230 .. tip::
231
232 Don't forget PHP start and end tag to have a valid PHP
233 file.
234
235 All is ready, you can now test the authentication from LL::NG portal.
236
237 .. |image0| image:: /applications/simplesamlphp_logo.png
238 :class: align-center
239 .. |image1| image:: /applications/simplesamlphp_sp_metadata.png
240 :class: align-center
241 .. |image2| image:: /applications/simplesamlphp_sp_attributes.png
242 :class: align-center
243 .. |image3| image:: /applications/simplesamlphp_sp_signature.png
244 :class: align-center
245 .. |image4| image:: /applications/simplesamlphp_sp_authentication.png
246 :class: align-center
247 .. |image5| image:: /applications/simplesamlphp_idp_metadata.png
248 :class: align-center
249 .. |image6| image:: /applications/simplesamlphp_idp_attributes.png
250 :class: align-center
251 .. |image7| image:: /applications/simplesamlphp_idp_signature.png
252 :class: align-center
253