aboutsummaryrefslogtreecommitdiffstats
path: root/keystone-moon/doc/source/federation/shibboleth.rst
blob: b82bd7036a5bffb8a6b8bfea1ca2f7eaa3762346 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
:orphan:

..
      Licensed under the Apache License, Version 2.0 (the "License"); you may
      not use this file except in compliance with the License. You may obtain
      a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
      License for the specific language governing permissions and limitations
      under the License.

================
Setup Shibboleth
================

Configure Apache HTTPD for mod_shibboleth
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Follow the steps outlined at: `Running Keystone in HTTPD`_.

.. _`Running Keystone in HTTPD`: ../apache-httpd.html

You'll also need to install `Shibboleth <https://wiki.shibboleth.net/confluence/display/SHIB2/Home>`_, for
example:

.. code-block:: bash

    $ apt-get install libapache2-mod-shib2

Configure your Keystone virtual host and adjust the config to properly handle SAML2 workflow:

Add *WSGIScriptAlias* directive to your vhost configuration::

    WSGIScriptAliasMatch ^(/v3/OS-FEDERATION/identity_providers/.*?/protocols/.*?/auth)$ /var/www/keystone/main/$1

Make sure the *wsgi-keystone.conf* contains a *<Location>* directive for the Shibboleth module and
a *<Location>* directive for each identity provider::

    <Location /Shibboleth.sso>
        SetHandler shib
    </Location>

    <Location /v3/OS-FEDERATION/identity_providers/idp_1/protocols/saml2/auth>
        ShibRequestSetting requireSession 1
        ShibRequestSetting applicationId idp_1
        AuthType shibboleth
        ShibExportAssertion Off
        Require valid-user

        <IfVersion < 2.4>
            ShibRequireSession On
            ShibRequireAll On
       </IfVersion>
    </Location>

.. NOTE::
    * ``saml2`` may be different in your deployment, but do not use a wildcard value.
      Otherwise *every* federated protocol will be handled by Shibboleth.
    * ``idp_1`` has to be replaced with the name associated with the idp in Keystone.
      The same name is used inside the shibboleth2.xml configuration file but they could
      be different.
    * The ``ShibRequireSession`` and ``ShibRequireAll`` rules are invalid in
      Apache 2.4+.
    * You are advised to carefully examine `Shibboleth Apache configuration
      documentation
      <https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPApacheConfig>`_

Enable the Keystone virtual host, for example:

.. code-block:: bash

    $ a2ensite wsgi-keystone.conf

Enable the ``ssl`` and ``shib2`` modules, for example:

.. code-block:: bash

    $ a2enmod ssl
    $ a2enmod shib2

Restart Apache, for example:

.. code-block:: bash

    $ service apache2 restart

Configuring shibboleth2.xml
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Once you have your Keystone vhost (virtual host) ready, it's then time to
configure Shibboleth and upload your Metadata to the Identity Provider.

If new certificates are required, they can be easily created by executing:

.. code-block:: bash

    $ shib-keygen -y <number of years>

The newly created file will be stored under ``/etc/shibboleth/sp-key.pem``

You should fetch your Service Provider's Metadata file. Typically this can be
achieved by simply fetching a Metadata file, for example:

.. code-block:: bash

    $ wget --no-check-certificate -O <name of the file> https://service.example.org/Shibboleth.sso/Metadata

Upload your Service Provider's Metadata file to your Identity Provider.
This step depends on your Identity Provider choice and is not covered here.

Configure your Service Provider by editing ``/etc/shibboleth/shibboleth2.xml``
file. You are advised to examine `Shibboleth Service Provider Configuration documentation <https://wiki.shibboleth.net/confluence/display/SHIB2/Configuration>`_

An example of your ``/etc/shibboleth/shibboleth2.xml`` may look like
(The example shown below is for reference only, not to be used in a production
environment):

.. code-block:: xml

    <!--
    File configuration courtesy of http://testshib.org

    More  information:
    https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPConfiguration
    -->

    <SPConfig xmlns="urn:mace:shibboleth:2.0:native:sp:config"
    xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" clockSkew="1800 ">

        <!-- The entityID is the name TestShib made for your SP. -->
        <ApplicationDefaults entityID="https://<yourhosthere>/shibboleth">

            <!--
            You should use secure cookies if at all possible.
            See cookieProps in this Wiki article.
            -->
            <!-- https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPSessions  -->
            <Sessions lifetime="28800" timeout="3600" checkAddress="false"
            relayState="ss:mem" handlerSSL="false">

                <!-- Triggers a login request directly to the TestShib IdP. -->
                <!-- https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPServiceSSO -->
                <SSO entityID="https://<idp-url>/idp/shibboleth" ECP="true">
                    SAML2 SAML1
                </SSO>

                <!-- SAML and local-only logout. -->
                <!-- https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPServiceLogout -->
                <Logout>SAML2 Local</Logout>

                <!--
                Handlers allow you to interact with the SP and gather
                more information. Try them out!
                Attribute value s received by the SP through SAML
                will be visible at:
                http://<yourhosthere>/Shibboleth.sso/Session
                -->

                <!--
                Extension service that generates "approximate" metadata
                based on SP configuration.
                -->
                <Handler type="MetadataGenerator" Location="/Metadata"
                signing="false"/>

                <!-- Status reporting service. -->
                <Handler type="Status" Location="/Status"
                acl="127.0.0.1"/>

                <!-- Session diagnostic service. -->
                <Handler type="Session" Location="/Session"
                showAttributeValues="true"/>
                <!-- JSON feed of discovery information. -->
                <Handler type="DiscoveryFeed" Location="/DiscoFeed"/>
            </Sessions>

            <!--
            Error pages to display to yourself if
            something goes horribly wrong.
            -->
            <Errors supportContact  ="<admin_email_address>"
                logoLocation="/shibboleth-sp/logo.jpg"
                styleSheet="/shibboleth-sp/main.css"/>

            <!--
            Loads and trusts a metadata file that describes only one IdP
            and  how to communicate with it.
            -->
            <MetadataProvider type="XML" uri="<idp-metadata-file>"
                 backingFilePath="<local idp metadata>"
                 reloadInterval="180000" />

            <!-- Attribute and trust options you shouldn't need to change. -->
            <AttributeExtractor type="XML" validate="true"
            path="attribute-map.xml"/>
            <AttributeResolver type="Query" subjectMatch="true"/>
            <AttributeFilter type="XML" validate="true"
            path="attribute-policy.xml"/>

            <!--
            Your SP generated these credentials.
            They're used to talk to IdP's.
            -->
            <CredentialResolver type="File" key="sp-key.pem"
            certificate="sp-cert.pem"/>

            <ApplicationOverride id="idp_1" entityID="https://<yourhosthere>/shibboleth">
               <Sessions lifetime="28800" timeout="3600" checkAddress="false"
               relayState="ss:mem" handlerSSL="false">

                <!-- Triggers a login request directly to the TestShib IdP. -->
                <SSO entityID="https://<idp_1-url>/idp/shibboleth" ECP="true">
                    SAML2 SAML1
                </SSO>

                <Logout>SAML2 Local</Logout>
               </Sessions>

               <MetadataProvider type="XML" uri="<idp_1-metadata-file>"
                 backingFilePath="<local idp_1 metadata>"
                 reloadInterval="180000" />

            </ApplicationOverride>

            <ApplicationOverride id="idp_2" entityID="https://<yourhosthere>/shibboleth">
               <Sessions lifetime="28800" timeout="3600" checkAddress="false"
               relayState="ss:mem" handlerSSL="false">

                <!-- Triggers a login request directly to the TestShib IdP. -->
                <SSO entityID="https://<idp_2-url>/idp/shibboleth" ECP="true">
                    SAML2 SAML1
                </SSO>

                <Logout>SAML2 Local</Logout>
               </Sessions>

               <MetadataProvider type="XML" uri="<idp_2-metadata-file>"
                 backingFilePath="<local idp_2 metadata>"
                 reloadInterval="180000" />

            </ApplicationOverride>

        </ApplicationDefaults>

        <!--
        Security policies you shouldn't change unless you
        know what you're doing.
        -->
        <SecurityPolicyProvider type="XML" validate="true"
        path="security-policy.xml"/>

        <!--
        Low-level configuration about protocols and bindings
        available for use.
        -->
        <ProtocolProvider type="XML" validate="true" reloadChanges="false"
        path="protocols.xml"/>

    </SPConfig>

Keystone enforces `external authentication`_ when the ``REMOTE_USER``
environment variable is present so make sure Shibboleth doesn't set the
``REMOTE_USER`` environment variable.  To do so, scan through the
``/etc/shibboleth/shibboleth2.xml`` configuration file and remove the
``REMOTE_USER`` directives.

Examine your attributes map file ``/etc/shibboleth/attribute-map.xml`` and adjust
your requirements if needed. For more information see
`attributes documentation <https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPAddAttribute>`_

Once you are done, restart your Shibboleth daemon:

.. _`external authentication`: ../external-auth.html

.. code-block:: bash

    $ service shibd restart
    $ service apache2 restart