| 1 |
OpenCTI |
| 2 |
========= |
| 3 |
|
| 4 |
.. image:: /applications/opencti.png |
| 5 |
:class: align-center |
| 6 |
|
| 7 |
Presentation |
| 8 |
------------ |
| 9 |
|
| 10 |
`OpenCTI <https://filigran.io/solutions/open-cti/>`__ is an open source platform allowing organizations to manage their cyber threat intelligence knowledge and observables. |
| 11 |
|
| 12 |
OpenCTI allows SSO via the SAML or OIDC protocols. |
| 13 |
|
| 14 |
|
| 15 |
Configuring OpenCTI (SAML) |
| 16 |
-------------------------- |
| 17 |
|
| 18 |
Prerequisites |
| 19 |
~~~~~~~~~~~~~ |
| 20 |
|
| 21 |
First, generate a key/certificate pair for OpenCTI :: |
| 22 |
|
| 23 |
openssl req -x509 -newkey rsa:4096 -keyout octi-saml-key.pem -out octi-saml-cert.pem -sha256 -days 3650 -noenc |
| 24 |
|
| 25 |
|
| 26 |
Then, download the LemonLDAP::NG SAML metadata at https://auth.example.com/saml/metadata/idp |
| 27 |
|
| 28 |
In this certificate, extract the ``ds:X509Certificate`` element inside the ``KeyDescriptor use="signing"`` element, and remove all spaces, you will get a long Base64 string that looks like :: |
| 29 |
|
| 30 |
# On a single line, with no spaces |
| 31 |
MIIFazCCA1OgAwIBAgIUDuUn+nT550rK0Qsej28PlQpZoFkwDQYJKoZIhvcN.... |
| 32 |
|
| 33 |
Do the same with ``octi-saml-key.pem`` in order to get a long Base64 string representing the OpenCTI signing key. |
| 34 |
|
| 35 |
Regular installation |
| 36 |
~~~~~~~~~~~~~~~~~~~~ |
| 37 |
|
| 38 |
In your OpenCTI configuration :: |
| 39 |
|
| 40 |
"saml": { |
| 41 |
"identifier": "saml", |
| 42 |
"strategy": "SamlStrategy", |
| 43 |
"config": { |
| 44 |
"issuer": "opencti", |
| 45 |
"entry_point": "https://auth.example.com/saml/singleSignOn", |
| 46 |
"saml_callback_url": "https://opencti.example.com/auth/saml/callback", |
| 47 |
"private_key": "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwg...", |
| 48 |
"cert": "MIICmzCCAYMCBgF2Qt3X1zANBgkqhkiG9w0BAQsFADARMQ8w...", |
| 49 |
"roles_management": { |
| 50 |
"role_attributes": ["groups"], |
| 51 |
"roles_mapping": ["my_lemonldap_group:Administrator"] |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
* ``private_key`` must contain the concatenated content of ``octi-saml-key.pem`` |
| 56 |
* ``cert`` must contain the concatenated content of the LemonLDAP::NG signing certificate, from SAML metadata |
| 57 |
* The ``roles_management`` element is only useful if you want to automatically affect roles to your LemonLDAP::NG users depending on their groups. |
| 58 |
|
| 59 |
Docker |
| 60 |
~~~~~~ |
| 61 |
|
| 62 |
In a docker setup, add the following environment variables :: |
| 63 |
|
| 64 |
- PROVIDERS__SAML__STRATEGY=SamlStrategy |
| 65 |
- "PROVIDERS__SAML__CONFIG__LABEL=Login with SAML" |
| 66 |
- PROVIDERS__SAML__CONFIG__ISSUER=opencti |
| 67 |
- PROVIDERS__SAML__CONFIG__ENTRY_POINT=https://auth.example.com/saml/singleSignOn |
| 68 |
- PROVIDERS__SAML__CONFIG__SAML_CALLBACK_URL=https://opencti.example.com/auth/saml/callback |
| 69 |
- PROVIDERS__SAML__CONFIG__CERT=MIICmzCCAYMCBgF2Qt3X1zANBgkqhkiG9w0BAQsFADARMQ8w... |
| 70 |
- PROVIDERS__SAML__CONFIG__PRIVATE_KEY=MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwg... |
| 71 |
- "PROVIDERS__SAML__CONFIG__ROLES_MANAGEMENT__ROLE_ATTRIBUTES=[\"groups\"]" |
| 72 |
- "PROVIDERS__SAML__CONFIG__ROLES_MANAGEMENT__ROLES_MAPPING=[\"my_lemonldap_group:Administrator\"]" |
| 73 |
|
| 74 |
* ``PRIVATE_KEY`` must contain the concatenated content of ``octi-saml-key.pem`` |
| 75 |
* ``CERT`` must contain the concatenated content of the LemonLDAP::NG signing certificate, from SAML metadata |
| 76 |
* The ``ROLES_MANAGEMENT`` variables are only useful if you want to automatically affect roles to your LemonLDAP::NG users depending on their groups. |
| 77 |
|
| 78 |
|
| 79 |
Configuring LemonLDAP (SAML) |
| 80 |
---------------------------- |
| 81 |
|
| 82 |
Generating OpenCTI metadata |
| 83 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 84 |
|
| 85 |
Edit the following template to create the metadata for OpenCTI :: |
| 86 |
|
| 87 |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
| 88 |
<EntityDescriptor |
| 89 |
entityID="opencti" |
| 90 |
xmlns="urn:oasis:names:tc:SAML:2.0:metadata"> |
| 91 |
<SPSSODescriptor |
| 92 |
AuthnRequestsSigned="true" |
| 93 |
WantAssertionsSigned="true" |
| 94 |
protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"> |
| 95 |
<KeyDescriptor use="signing"><ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:X509Data><ds:X509Certificate> |
| 96 |
###paste the content of octi-saml-cert.pem here, without the BEGIN and END line### |
| 97 |
</ds:X509Certificate></ds:X509Data></ds:KeyInfo></KeyDescriptor> |
| 98 |
<AssertionConsumerService |
| 99 |
index="0" |
| 100 |
isDefault="true" |
| 101 |
Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" |
| 102 |
Location="https://opencti.example.com/auth/saml/callback" /> |
| 103 |
</SPSSODescriptor> |
| 104 |
|
| 105 |
</EntityDescriptor> |
| 106 |
|
| 107 |
Don't forget to replace the ``Location=`` attribute and the content of ``X509Certificate``. |
| 108 |
|
| 109 |
Adding OpenCTI::NG to LemonLDAP configuration |
| 110 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 111 |
|
| 112 |
Add a new :ref:`new SAML Service Provider to the LemonLDAP::NG configuration<samlidp-register-sp>` |
| 113 |
with the following parameters: |
| 114 |
|
| 115 |
* **Metadata** |
| 116 |
* Copy the Metadata generated at the previous step |
| 117 |
* **Exported Attributes** |
| 118 |
* variable name: ``groups`` |
| 119 |
* attribute name: ``groups`` |
| 120 |
|
| 121 |
|
| 122 |
OIDC Interconnection |
| 123 |
-------------------- |
| 124 |
|
| 125 |
This section describe the OpenID Connect configuration |
| 126 |
|
| 127 |
Configure OpenCTI (OIDC) |
| 128 |
~~~~~~~~~~~~~~~~~~~~~~~~ |
| 129 |
|
| 130 |
Here is the basic configuration for a docker installation |
| 131 |
|
| 132 |
Define and replace ``<clientid>`` and ``<clientsecret>``, and also adapt issuer and redirect uri: |
| 133 |
|
| 134 |
.. code-block:: |
| 135 |
|
| 136 |
- PROVIDERS__OPENID__STRATEGY=OpenIDConnectStrategy |
| 137 |
- "PROVIDERS__OPENID__CONFIG__LABEL=Login with OpenID" |
| 138 |
- PROVIDERS__OPENID__CONFIG__ISSUER=https://auth.example.com |
| 139 |
- PROVIDERS__OPENID__CONFIG__CLIENT_ID=<clientid> |
| 140 |
- PROVIDERS__OPENID__CONFIG__CLIENT_SECRET=<clientsecret> |
| 141 |
- "PROVIDERS__OPENID__CONFIG__REDIRECT_URIS=[\"https://opencti.mydomain.com/auth/oic/callback\"]" |
| 142 |
|
| 143 |
For an advanced usage, you can also map lemonldap groups to openCTI groups with these paramters: |
| 144 |
|
| 145 |
.. code-block:: |
| 146 |
|
| 147 |
- "PROVIDERS__OPENID__CONFIG__GROUPS_MANAGEMENT__GROUPS_SCOPE=groups" |
| 148 |
- "PROVIDERS__OPENID__CONFIG__GROUPS_MANAGEMENT__GROUPS_PATH=[\"groups\", \"realm_access.groups\", \"resource_access.account.groups\"]" |
| 149 |
- "PROVIDERS__OPENID__CONFIG__GROUPS_MANAGEMENT__GROUPS_MAPPING=[\"OpenID_Group_1:OpenCTI_Group_1\", \"OpenID_Group_2:OpenCTI_Group_2\", ...]" |
| 150 |
|
| 151 |
|
| 152 |
Configure LemonLDAP (OIDC) |
| 153 |
~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 154 |
|
| 155 |
Configure LemonLDAP as an :doc:`OpenID Connect provider <../idpopenidconnect>`. |
| 156 |
|
| 157 |
As describe in documentation link above, also define a new Relying Party in LL::NG. |
| 158 |
|
| 159 |
Take care to configure at least these parameters: |
| 160 |
|
| 161 |
* ``Public client``: disabled |
| 162 |
* ``Client ID``: client id defined in previous section |
| 163 |
* ``Client secret``: client secret defined in previous section |
| 164 |
* ``Allowed redirection addresses for login``: redirect uri defined in previous section |
| 165 |
* ``Security -> ID Token signature algorithm``: make sure you select **RS256**, as HS512 is not supported in OpenCTI |
| 166 |
* ``Advanced -> User attribute``: take care to use the user unique identifier defined in OpenCTI, usually ``mail`` |
| 167 |
|
| 168 |
Advanced usage, for group mapping: |
| 169 |
|
| 170 |
* ``Exported attributes (claims)``: add claim ``groups -> groups`` |
| 171 |
* ``Options -> Scope``: add scope ``groups -> groups`` |
| 172 |
|
| 173 |
|