| 1 |
NextCloud |
| 2 |
========= |
| 3 |
|
| 4 |
|image0| |
| 5 |
|
| 6 |
Presentation |
| 7 |
------------ |
| 8 |
|
| 9 |
`NextCloud <https://nextcloud.com/>`__ is a fork of Owncloud, suite of |
| 10 |
client-server software for creating file hosting services and using |
| 11 |
them. |
| 12 |
|
| 13 |
This documentation explains how to interconnect LemonLDAP::NG and |
| 14 |
NextCloud using Open ID Connect or SAML 2.0 protocol. |
| 15 |
|
| 16 |
OpenID Connect |
| 17 |
-------------- |
| 18 |
|
| 19 |
Requirements |
| 20 |
~~~~~~~~~~~~ |
| 21 |
|
| 22 |
Your LemonLDAP::NG server must be configured as OpenID Connect provider. |
| 23 |
|
| 24 |
Your NextCloud server must be able to join directly the LemonLDAP::NG server. |
| 25 |
It using SSL, be sure that certificate of LL::NG portal is trusted on NextCloud server. |
| 26 |
|
| 27 |
LemonLDAP::NG |
| 28 |
~~~~~~~~~~~~~ |
| 29 |
|
| 30 |
Create a new OpenID Connect RP with these settings: |
| 31 |
|
| 32 |
* Client ID: generate a value |
| 33 |
* Client Secret: generate a value |
| 34 |
* Login redirection URL: https://nextcloud.example.com/index.php/apps/oidc_login/oidc |
| 35 |
* Attributes: at least ``email`` and ``name`` |
| 36 |
* User attribute: you must set here the identifier that is already used by NextCloud (if you already plugged NextCloud to your LDAP directory). |
| 37 |
It can be ``entryUUID`` for OpenLDAP or ``objectGUID`` for AD. If this is not correctly configured, a new account will be created instead |
| 38 |
of using the existing account. |
| 39 |
|
| 40 |
You can also share groups trough OpenID Connect. In this case, create a ``groups`` claim. |
| 41 |
|
| 42 |
Another optional claim is a boolean to let NextCloud know if user is admin or not. You can easily create a macro for this. |
| 43 |
|
| 44 |
NextCloud |
| 45 |
~~~~~~~~~ |
| 46 |
|
| 47 |
Install and enable `"OpenID Connect Login" plugin <https://apps.nextcloud.com/apps/oidc_login>`__. |
| 48 |
|
| 49 |
In your ``config.php``, configure OIDC parameters: |
| 50 |
|
| 51 |
.. code-block:: php |
| 52 |
|
| 53 |
'oidc_login_hide_password_form' => true, |
| 54 |
'oidc_login_auto_redirect' => true, |
| 55 |
'oidc_login_redir_fallback' => false, |
| 56 |
'oidc_login_provider_url' => 'https://auth.example.com', |
| 57 |
'oidc_login_tls_verify' => true, |
| 58 |
'oidc_login_client_id' => 'clientid', |
| 59 |
'oidc_login_client_secret' => 'clientsecret', |
| 60 |
'oidc_login_disable_registration' => false, |
| 61 |
'oidc_login_use_id_token' => false, |
| 62 |
'oidc_login_attributes' => |
| 63 |
array ( |
| 64 |
'id' => 'sub', |
| 65 |
'name' => 'name', |
| 66 |
'mail' => 'email', |
| 67 |
), |
| 68 |
'oidc_login_scope' => 'openid profile email', |
| 69 |
'oidc_login_logout_url' => 'https://auth.example.com', |
| 70 |
|
| 71 |
|
| 72 |
For advanced conifguration, with groups and admin claims: |
| 73 |
|
| 74 |
.. code-block:: php |
| 75 |
|
| 76 |
'oidc_login_attributes' => |
| 77 |
array ( |
| 78 |
'id' => 'sub', |
| 79 |
'name' => 'name', |
| 80 |
'mail' => 'email', |
| 81 |
'groups' => 'groups', |
| 82 |
'is_admin' => 'nextcloud_admin', |
| 83 |
), |
| 84 |
'oidc_create_groups' => true, |
| 85 |
|
| 86 |
|
| 87 |
SAML |
| 88 |
---- |
| 89 |
|
| 90 |
Requirements |
| 91 |
~~~~~~~~~~~~ |
| 92 |
|
| 93 |
Make sure you have :doc:`set up LemonLDAP::NG a SAML IDP <../samlservice>` |
| 94 |
|
| 95 |
.. warning:: |
| 96 |
Nextcloud requires your public SAML Signature key to be in `BEGIN CERTIFICATE` |
| 97 |
format, if this is not the case, you need to :ref:`convert your SAML key to |
| 98 |
a certificate<samlservice-convert-certificate>`. Note that recent versions of |
| 99 |
LL:NG are already configured to use certificates instead public key. |
| 100 |
|
| 101 |
.. _nextcloud-1: |
| 102 |
|
| 103 |
NextCloud |
| 104 |
~~~~~~~~~ |
| 105 |
|
| 106 |
.. tip:: |
| 107 |
|
| 108 |
If your NextCloud is behind a proxy (thus having a private |
| 109 |
IP), metadata generated by NextCloud won't work. |
| 110 |
|
| 111 |
Consider changing the configuration of NextCloud to force the domain and the protocol, in |
| 112 |
**$nextcloudrootwww/config/config.php**, add the following: |
| 113 |
|
| 114 |
.. code:: php |
| 115 |
|
| 116 |
'overwritehost' => 'nextcloud.example.com', |
| 117 |
'overwriteprotocol' => 'https', |
| 118 |
|
| 119 |
Enable the `"SAML authentication" plugin <https://apps.nextcloud.com/apps/user_saml>`__. |
| 120 |
|
| 121 |
Create Certificate of Service Provider for Nextcloud |
| 122 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 123 |
|
| 124 |
You will need private key and public key within a certificate to identify your SP in LL:NG IDP. |
| 125 |
|
| 126 |
Select a host with a secure filesystem as a secure random source since private keys are generated. |
| 127 |
|
| 128 |
To create a private key and self-sign a certificate for its public key please adapt to your country/state. |
| 129 |
|
| 130 |
It is recommended to use nextcloud hostname for Common Name. |
| 131 |
|
| 132 |
:: |
| 133 |
|
| 134 |
certname=nextcloud_saml |
| 135 |
openssl req -new -newkey rsa:4096 -keyout $certname.key -nodes -out $certname.pem -x509 -days 3650 |
| 136 |
|
| 137 |
Country Name (2 letter code) [AU]:BTN |
| 138 |
State or Province Name (full name) [Some-State]:North |
| 139 |
Locality Name (eg, city) []:Thimphou |
| 140 |
Organization Name (eg, company) [Internet Widgits Pty Ltd]:NGO |
| 141 |
Organizational Unit Name (eg, section) []: |
| 142 |
Common Name (e.g. server FQDN or YOUR name) []:nextcloud.example.com |
| 143 |
Email Address []: |
| 144 |
|
| 145 |
Please note that once you have copied those in following process it is recommended to remove private |
| 146 |
key file from your system. |
| 147 |
|
| 148 |
Configure Service provider within Nextcloud |
| 149 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 150 |
|
| 151 |
:: |
| 152 |
|
| 153 |
Administration -> SSO & SAML authentication |
| 154 |
|
| 155 |
You will find the following fields: |
| 156 |
|
| 157 |
- **Allow the use of multiple user back-ends (e.g. LDAP)** |
| 158 |
Activate it during configuration, remove it later only once a saml |
| 159 |
user with administration rights can login. |
| 160 |
|
| 161 |
- **Attribute to map the UID to**: Identity attribute provided by your |
| 162 |
LL:NG that will be used as UID in NextCloud. |
| 163 |
- **Optional display name of the identity provider**: choose a name |
| 164 |
meaningfull to identify this nextcloud app without spaces to use |
| 165 |
it in LL:NG too. |
| 166 |
- **Service Provider Data**: |
| 167 |
|
| 168 |
- **Name ID format**: select Email Address |
| 169 |
- **X509 certificate of Service provider**: a Certificate you have |
| 170 |
created previously for this purpose |
| 171 |
- **Private key of the Service provider**: private key corresponding |
| 172 |
to public key within certificate of Service provider. |
| 173 |
- **Identity Provider Data**: |
| 174 |
|
| 175 |
- **Identifier of the IdP entity**: SAML Metadata URL of your LL:NG |
| 176 |
- **URL Target of the IdP where the SP will send the Authentication |
| 177 |
Request Message**: SingleSignOn URL of your LL:NG |
| 178 |
- **URL Location of the IdP where the SP will send the SLO |
| 179 |
Request**: SingleLogOut URL of your LL:NG |
| 180 |
- **Public X.509 certificate of the IdP**: Certificate of your LL:NG |
| 181 |
|
| 182 |
Your fields should look like this: |image3| |
| 183 |
|
| 184 |
Recent versions of LL:NG are already configured to use Certificates |
| 185 |
instead public key so you can obtain pem encoded certificate directly |
| 186 |
by Copy/Paste of certificate field in the "Public X.509 certificate of |
| 187 |
the IdP" field of your NextCloud. |
| 188 |
|
| 189 |
You can now download your metadata xml file. |
| 190 |
|
| 191 |
|
| 192 |
LL:NG, SAML 2.0 Service Provider configuration |
| 193 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 194 |
|
| 195 |
We now have to define a service provider (e.g our nextcloud) in LL:NG. |
| 196 |
|
| 197 |
Go to "SAML service providers", click on "Add SAML SP" and name it as |
| 198 |
you want (example : 'NextCloud') (was 'NGOSSO' in previous screenshoot) |
| 199 |
|
| 200 |
In the new subtree 'NextCloud', open 'Metadata' and paste the content of |
| 201 |
your previously downloaded file (or upload the file) |
| 202 |
|
| 203 |
|image4| |
| 204 |
|
| 205 |
Now go in "Exported attributes" and add, at least, the 'uid' |
| 206 |
|
| 207 |
|image5| |
| 208 |
|
| 209 |
You might need to add 'mail' to fill expected NameID from NextCloud or |
| 210 |
to configure explicit 'uid' NameID mapping in **Force NameID session key**. |
| 211 |
|
| 212 |
Don't forget to save your configuration. |
| 213 |
|
| 214 |
You are now good to go, and you can add the application in |
| 215 |
:doc:`your menu<../portalmenu>` and |
| 216 |
:doc:`your virtual hosts<../configvhost>`. |
| 217 |
|
| 218 |
.. |image0| image:: /applications/nextcloud-logo.png |
| 219 |
:class: align-center |
| 220 |
.. |image1| image:: /applications/nextcloud_saml_activation.png |
| 221 |
:class: align-center |
| 222 |
.. |image2| image:: /applications/nextcloud_certificate_keys.png |
| 223 |
:class: align-center |
| 224 |
.. |image3| image:: /applications/nextcloud_saml_configuration.png |
| 225 |
:class: align-center |
| 226 |
.. |image4| image:: /applications/nextcloud_service_metadata.png |
| 227 |
:class: align-center |
| 228 |
.. |image5| image:: /applications/nextcloud_service_exportedattributes.png |
| 229 |
:class: align-center |
| 230 |
.. |image6| image:: /applications/nextcloud_certificate_keys.png |
| 231 |
:class: align-center |