# Microsoft ADFS

How to Connect ROR Enterprise with SAML and ADFS

ReadonlyREST (ROR) Enterprise allows for complex authentication and authorization configurations with Kibana and Elasticsearch. When Elasticsearch is combined with Kibana, a data visualization dashboard, the combination provides a powerful way to ingest logs and analyze data.

To access that data, many enterprises manage users in a central directory. This directory could be an Active Directory (AD) instance, in the case of a Windows-centric environment, or a cloud directory provider, such as Google Cloud Identity, in a cloud-based environment. Instead of integrating these services directly into a product, an abstraction layer such as SAML can provide authentication and authorization and tie into different back ends as necessary.

ReadonlyREST provides a free Elasticsearch plugin that provides advanced authentication options. When it is combined with the ReadonlyREST Enterprise plugin for Kibana, integrating SAML authentication into the authentication process becomes easy.

This article will walk through the process of setting up an entire environment in order to demonstrate how the ReadonlyREST free and Enterprise plugins integrate with Active Directory Federation Services (AD FS) to provide SAML authentication.

In this tutorial, you will learn how to:

* Provision Azure Virtual Machines to host Active Directory, Elasticsearch, and Kibana
* Install and configure Active Directory (AD) Services
* Provision sample AD users
* Install and configure Active Directory Certificate Services (AD CS)
* Install and configure Active Directory Federation Services (AD FS)
* Install and configure ElasticSearch and the ReadonlyREST Free Plugin
* Install and configure Kibana and the ReadonlyREST Enterprise Plugin

## Provisioning Azure Virtual Machines to Host Active Directory, Elasticsearch, and Kibana

Any Windows Server 2016 Virtual Machines (VM) can be used for this process; however, in this demonstration, the Microsoft Azure environment will be used to provision and host the VMs.

You can name your VMs whatever you would like. This article will refer to the names listed below for consistency.

* Virtual Machine 1: lc-win2019-02
  * **Roles**: Active Directory, AD Certificate Services, AD Federation Services, DNS
  * **Memory**: 4GB
* Virtual Machine 2: lc-win2019-03
  * **Roles**: Elasticsearch, Kibana
  * **Memory**: 8GB

These Azure VMs will be Pay-As-You-Go and Spot Instances for affordability. The example shown below is for the Elasticsearch and Kibana VM which will be duplicated for the Active Directory VM but will have 4GBs of memory instead of 8GB.

*Please note that Azure Spot Instances cannot be resized after creation.*

### Provisioning Virtual Machines

1. Log into the **Azure portal** using a **Pay-As-You-Go** subscription.
2. Create a **new virtual machine.**
3. If you do not already have a **resource group** created to serve as a home for the VMs, select **Create new** and create the **resource group.**
4. Name your virtual machine appropriately, and choose the details for your instance, as shown in the example below.
5. You can use the default hard drive sizes and **Standard HDD** disks for this environment.
6. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-bff41c308b120c139d41da8b3e5b7ec16fececd2%2F2.png?alt=media\&token=435706f8-2dbb-4289-9e54-96b28a355e17)
7. The default **Networking** options will also work here.
8. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-0d5e8f1e7cac20fb50305714fc958e7cc8937830%2F3.png?alt=media\&token=baf09518-12ac-4e18-ab34-dd498fed050c)
9. As will the default **Management** options.
10. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-063084bc2dd752655fb5b117085f8ed894bfb5cb%2F4.png?alt=media\&token=f6a84cbb-5b8d-4a2f-b24e-dd291c096977)
11. No additional **Advanced** options are necessary.
12. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-5d84665e442d2b79f4aec552d09c3469f1157520%2F5.png?alt=media\&token=fb51b15c-947b-40d7-aca0-5bf53ee46f13)
13. If you would like to tag your VMs for later categorization and tracking, you can do so here.
14. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-dd0e5f135dd453f40c57d6a01d44c2ab5dabcaa1%2F6.png?alt=media\&token=0dacd596-1be6-4cbe-8eaa-a7c077cff617)
15. Finally, create the VM.

After this VM has been created, create one more to host the Active Directory and related services. In the end, you should have two VMs as outlined above.

## Installing and Configuring Active Directory (AD) Services

After the two VMs have been provisioned, the next step is to set up directory services on the first VM, lc-win2019-02.

### Installing Active Directory Services

1. Once you are logged into lc-win2019-02, choose **Add Roles and Features** on the **Server Manager** screen.
2. Select **Role-based or feature-based installation**.
3. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-78bf14f58e9f948e5e780774034909b3d451b69b%2F9.png?alt=media\&token=9ae4eaa8-154b-40d9-8ec6-0be361050818)
4. Select the correct server from the server pool.
5. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-890cb812980c6526acd7aa8650e8155512e9619c%2F10.png?alt=media\&token=af0013cd-7b15-444a-ae72-db38a24740b4)
6. Select **Active Directory Domain Services,** and add the additional features as prompted.
7. No additional features are necessary since the default options work.
8. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-4fcfb6c97837131fd2cf5d55d02972e5f26e31d1%2F13.png?alt=media\&token=5510043e-9c7f-4c28-8bb1-e3ae50e28c83)
9. Click **Next** on the **Active Directory Domain Services** informational screen.
10. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-11a231a6fac211ba4bec411e2f7f1a2d410dd0b3%2F14.png?alt=media\&token=1034d12b-def0-4e50-b0c0-e5920bf2447b)
11. Finally, select **Restart the destination server automatically if required**. Click **Yes** when prompted, and then click **Install.**
12. Once installation has finished, click on **Close.**
13. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-d25d7f4b4d16c4e662beabe8eb9cfff83e67f05f%2F17.png?alt=media\&token=e0d41625-a32f-4ea1-ba40-36d1b7a872bf)

### Configuring Active Directory Services

If DNS has not been installed already, the role installation screen may pop up in the middle of the Active Directory installation. Installation instructions for the DNS role are shown after the Configuring Active Directory Services section below.

1. Click on **Promote this server to a domain controller,** which will allow you to see the **Deployment Configuration** screen.
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-6c98caa27975621a302b3fccc0dadb40b7b6ffa7%2F18.png?alt=media\&token=b29439e0-360a-41a6-943c-397147db3711)
3. Name the domain. In this case, use ad.lc-test.local.
4. This name was arbitrarily chosen. Using a subdomain such as “ad” instead of your actual domain (i.e., \[lc-test.local]\([http://lc-test.local\\](http://lc-test.local/\)\)%20by%20itself/) is recommended.
5. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-690dfc639f4d232f4bf3ffa962d4dede8a14ce87%2F19.png?alt=media\&token=8f62755d-d1d5-454a-8343-7ab62b5c9759)
6. Select **Windows Server 2016** as the **functional level**. For the **domain controller capabilities**, choose **Domain Name System (DNS) server**. Set a Directory Services Restore Mode (DSRM) **password.**
7. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-ee6298d420d7cb10fbf41bb400fdcaeee6fb8912%2F20.png?alt=media\&token=8c9ea26a-78b7-4a54-9dab-2ca9b2075cda)
8. The following **DNS Options** warning message can be disregarded:
9. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-c5bf3cd8c1372f480df5834c6f5fef95c1cbc954%2F21.png?alt=media\&token=dd7a3e91-343d-40e3-a088-d1a76cbb8290)
10. Set the **NetBIOS domain name**, which is usually the short name prior to the host name (e.g., AD), and click **Next.**
11. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-6206bbaf9e90d1c3e725229c280103619ce102d7%2F22.png?alt=media\&token=54b34866-2084-42dd-b200-b1718a0dac61)
12. Use the default paths, and click on **Next.**
13. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-665fda4aab448a296780afbd6646e27d422fbeff%2F23.png?alt=media\&token=05e41d36-1349-4c43-b790-d20b6507c17b)
14. On the **Review Options** screen, click **Next** if everything looks correct.
15. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-485171c06d99f59ea00d8f66bd67b564a60aa82a%2F24.png?alt=media\&token=f75025f8-318f-47ca-81c4-a0e79da91346)
16. On the **Prerequisites Check** screen, click **Install.**
17. You’ll see a number of warnings related to the fact that this is a test environment. They can be safely ignored.
18. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-3a3a44693369546c948781c844ee164d0efbf031%2F25.png?alt=media\&token=427ea278-e966-4567-906f-cbd15eed24e5)
19. When you click **Close**, you will have a successful configuration.
20. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-ae62e37f7c8e26fbb0a91637a1aad30dc34bda80%2F26.png?alt=media\&token=0e4271f1-bde0-4bb7-9ee2-0bfb787b5902)
21. Click **Close** on the restart prompt.
22. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-a88817728e412859cc42ad6a10e28d168e5ae8e6%2F27.png?alt=media\&token=ae45c0e8-9df1-4ecb-a70f-6b604b383ed7)

### Configuring the Domain Name Services (DNS) Role

1. Click on the **DNS Services** role, add the additional features as requested, and click **Next.**
2. If you are using DHCP for the server (this is not recommended for a production service), then you will see the validation warning shown below. It can be disregarded. Click on **Continue** and **Install.**
3. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-908c7bb5fd382d4b7ce10a3a5e711b284bc34993%2F30.png?alt=media\&token=6ca5f6ba-e2c9-422f-914b-fcf6a2484e86)
4. Click **Next** on the **Features** screen, since no additional features are necessary.
5. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-26343639a4ea49fef35bd7366adcc4465dc148c2%2F31.png?alt=media\&token=4b60ca3f-be6f-487f-a4be-1e69b62b0878)
6. Click **Next** on the informational **DNS Server** screen.
7. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-5a620b6cc4c46f1086dc1c4acac869504f4916db%2F32.png?alt=media\&token=270dafdc-adff-4129-8b5a-536051dd418b)
8. Click **Install** on the **Confirmation** screen.
9. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-e3f930b8de2270c2bcee49fe253f6076d2ee7f90%2F33.png?alt=media\&token=229ebc20-e403-482e-acd1-07675ee54590)
10. Select **Restart the destination server automatically if required,** and click **Install.** Finally, click **Close,** and you will have a successful installation.
11. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-b5ad325789e16949f73d8df0c04da589ff4fcb6a%2F34.png?alt=media\&token=1d789a36-656a-4e4d-b11c-c646fd8e6869)

### Joining Computers to the Domain

Next we need to join the second server—the one hosting Elasticsearch and Kibana—to the domain.

1. Open an RDP connection to the second server. Then, open **Notepad** as an Administrator, and open the file C:\Windows\System32\drivers\etc\hosts.
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-e6de50489bc9c0c45f9ec32e6a6c0bb3be52544c%2F35.png?alt=media\&token=5de6d69e-8f20-468d-af34-9ddfc27d9eb4)
3. Add the IP address and hostnames for the domain controller.
4. These will reflect the IP addresses and hostnames you chose for your configuration:
   * **FQDN**: 10.0.0.5 - ad.lc-test.local
   * **NetBIOS**: 10.0.0.5 - ad
5. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-ef15d87eccea38a983a5909d9d672ac9b4579099%2F36.png?alt=media\&token=ece8fdee-f35e-44e3-9e6a-4e2cd091aa9e)
6. Additionally, you will need to change your network adapter DNS to point to your domain server; in this case, it is 10.0.0.5.
7. If the system restarted, open an RDP connection, and then open the **System** screen under the **Control Pane** and select **Advanced System** settings.
8. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-58ac8db7da78dd8a340db34bece5ce5f5e302fed%2F39.png?alt=media\&token=369b8f76-0628-4aec-b0ae-48c3b301d49d)
9. Click on **Change** to add this server to the domain.
10. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-fdcc72c30de43cd68fb4ccb9ec1b03fcc89782fe%2F40.png?alt=media\&token=60227cfc-e8ca-4285-9009-929900d1ff5e)
11. Enter the domain (e.g., ad.lc-test.local).
12. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-1f3fe3d6783217a8c737cf90a7dc276a6816f29d%2F41.png?alt=media\&token=9c84a86b-676c-47bd-9ad4-a0abd2aa7014)
13. Click on **OK,** and enter the credentials of the account that has privileges enabling it to add the domain.
14. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-07ec5c3169a0ca3dc66fd17b395e10adab258b1f%2F42.png?alt=media\&token=c20bec60-3c35-4aea-bcb6-0f7519d6fb2e)
15. Restart the server after joining it to the domain.

## Provisioning Sample AD Users

For testing purposes, it can be useful to provision additional users within the Active Directory. The following PowerShell script, which should be run on the domain controller, will make this easy. Note that we are setting the mail attribute which will be used for the SAML username.

Import-Module -Name 'ActiveDirectory'

$Domain = 'ad.lc-test.local'\
$OU = 'CN=Users,DC=ad,DC=lc-test,DC=local'

$Users = @{\
"TestUser1" = "testPass1"\
"TestUser2" = "testPass2"\
"TestUser3" = "testPass3"\
"TestUser4" = "testPass4"\
"TestUser5" = "testPass5"\
}

$Users.GetEnumerator() | ForEach-Object {\
$Name = $\_.Key\
$Password = $\_.Value

$Params = @{\
"Name" = $Name\
"Path" = $OU\
"AccountPassword" = (ConvertTo-SecureString -AsPlainText $Password -Force)\
"Enabled" = $True\
"DisplayName" = $Name\
"PasswordNeverExpires" = $True\
"CannotChangePassword" = $True\
"EmailAddres" = "$Name@$Domain"\
}

New-ADUser @Params\
}

## Installing Active Directory Certificate Services (AD CS)

1. Click on **Active Directory Certificate Services,** and add the additional features as prompted.
2. Since no additional features are necessary, allow defaults, and click on **Next.**
3. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-a5fed77a15e7a1da9eda7777f5b6bbf9310034dd%2F45.png?alt=media\&token=699b5607-5b8b-4b24-b29e-314a59cd8cf1)
4. On the **Active Directory Certificate Services** informational screen, click **Next** to continue.
5. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-5b6252ea1d94b74e4371a2291ea5942dd5823527%2F46.png?alt=media\&token=8de7ede0-b5ae-4615-946f-a6235431bc96)
6. Select the **Certification Authority** role services, and click **Next.**
7. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-37d9e10f5f4b4585aa8ddbaa3992de4dc105ebb1%2F47.png?alt=media\&token=d40a312f-c67c-4863-875f-f973bc130391)
8. Select **Restart the destination server automatically if required,** and click on **Install.**
9. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-4d7152ed463a232644d3dd9099cdcd5181fe3033%2F48.png?alt=media\&token=b2c4fa05-d98e-46a2-8ea3-12a71807fd0d)
10. Finally, click on **Close** when the installation has been completed.
11. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-ee7fd615511ebbd7b6ed9f6221309f10bc3b653c%2F49.png?alt=media\&token=16b60b54-ca47-48af-8cf7-8711c6c29f52)

### Configuring Active Directory Certificate Services

1. Click on **Configure Active Directory Certificate Services.**
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-5efcc39888748cc4a0edcb70a29264c17790843a%2F50.png?alt=media\&token=94f782ff-ff6d-4cb4-a8e6-2366c8e9df89)
3. Select the default administrative user for AD CS credentials.
4. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-34881a24fe4eb40c0b863588ae86870069a17ac3%2F51.png?alt=media\&token=0dc82241-8367-4820-a896-bc9af0280845)
5. Under **Role Services**, check **Certification Authority,** and click Next.
6. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-1bf637dad78b8dd03511f4e8cc082695ec363175%2F52.png?alt=media\&token=d1159af0-7d71-4fcf-beda-95bce06dc126)
7. Select **Enterprise CA,** and click on **Next.**
8. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-42687e331b7088f764b06becb73018d5d9b95394%2F53.png?alt=media\&token=27c88c5f-a22e-409d-84ce-e1972ff4e3d4)
9. Click on **Root CA**, then click on **Next.**
10. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-1410f241b55cc3607a957ac0e62045d324d5dc61%2F54.png?alt=media\&token=c8f7f815-a986-4e29-abb5-5c07973b8043)
11. Click on **Create a new private key,** and then click on **Next.**
12. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-28c2aaba99039807cf6e3ea03b487b09226ff05e%2F55.png?alt=media\&token=78d480ed-e469-4bfa-9790-6daec5e0f8de)
13. Select **RSA#Microsoft Software Key Storage Provider**, a default key length of **2048**, and a hash algorithm of **SHA256.** Click **Next.**
14. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-026a38545aec793b0986c246929417615d6518c8%2F56.png?alt=media\&token=d9cdfb23-00df-4265-a16b-f5475b9d31fb)
15. Use the defaults given for the CA Name, and click on **Next.**
16. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-c118917c3d4866ba35126129b7207a1fecb7be26%2F57.png?alt=media\&token=3df28e47-ff48-4c54-80bc-d0c7b590f70b)
17. Select a validity period of 5 years, and click on **Next.**
18. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-bc0398bfef213635720c10bd5c397b6f1720ec25%2F58.png?alt=media\&token=c1481084-e328-464e-8f12-4eec7b8fa17a)
19. Leave the default database locations in place, and click on **Next.**
20. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-ce4124e2aac1bbbc3e82458df52e2c12dca08297%2F59.png?alt=media\&token=59655b77-91f3-47ad-99b7-6adaf2f300a5)
21. Click on **Configure** and **Close** when the configuration process has been completed.
22. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-7a4b15a0383e0c7aaba28f2456976e1618bc3214%2F60.png?alt=media\&token=ad60b5bb-0c67-48ff-9470-04866142550e)

## Installing and Configuring Active Directory Federation Services (AD FS)

Previously, it was recommended that AD FS should not be installed on the same server as the DC because IIS was installed as part of that process. As of 2012, this recommendation has changed, since AD FS does not use IIS anymore. Now, mounting AD FS and DC on the same server is advised for domains under 1000 users.

### Provisioning SSL Certificate Templates

1. Open the **Certification Authority** MMC snapin, right-click on **Certificate Templates,** and click on **Manage.**
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-4cf93036a466b01ea3c96384e546cc776e23b163%2F61.png?alt=media\&token=54c31492-ad19-4623-8514-07a09715f586)
3. Select **Duplicate Template** on the **Web Server** template.
4. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-05ce5cfb37432df279491531c0552f28daf6305c%2F62.png?alt=media\&token=cc9032a9-3932-426d-b74e-70f1b7000ccc)
5. Enter “SSL Certificates” in the box labeled **Template display name** on the **General** tab.
6. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-e8d826ddb2086b1a1c5a09f8f06443f20704b22f%2F63.png?alt=media\&token=4640f77c-e2b9-491c-8fa0-ef9e0fd39532)
7. On the **Security** tab, click on **Enroll** and **Allow for Authenticated Users,** and, finally, **Apply** the configuration.
8. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-bb21cea48e848c32721e89fea8c849322cee237a%2F64.png?alt=media\&token=06116d0a-7096-4c81-879c-749de2c7baef)
9. Right-click on **Certificate Templates → New → Certificate Template to Issue.**
10. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-ff35a5dcdaa414ac58a86ced58558ca66e0f2371%2F65.png?alt=media\&token=c2855d4c-d3f5-4cd8-805a-bd8210b1aefe)
11. Select **SSL Certificates** from the **Certificate Template** list, and click **OK.**

### Provisioning the SSL Certificate

1. Open the Certificates MMC snapin for the Local Computer. Navigate to **Personal → Certificates,** and right-click to open **All Tasks → Request New Certificate.**
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-f099c46b7b98ffa885e17849436c21720ee19572%2F68.png?alt=media\&token=1bc09917-92cc-495d-891d-ec90c9f00347)
3. Click **Next** on the **Before you Begin** screen.
4. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-8dd37a502b6fab51403a769418ec97ddae618ff9%2F69.png?alt=media\&token=d9a6fe3d-68a1-4f70-9f44-d127c99c0a68)
5. Click **Next** on the **Select Certificate Enrollment Policy** screen.
6. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-b5687ecbb822cd3f0e6a27afcfc668e706a83a7f%2F70.png?alt=media\&token=65417350-9691-4eea-a06b-fe8c23bcbb27)
7. Select **SSL Certificates,** and click on **More information is required to enroll for this certificate.** Select **Click here to configure settings** to configure the certificate.
8. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-58fec3e57a15a50067b522c75390f69780ace6d0%2F71.png?alt=media\&token=874f6ff7-8e3a-4ca0-bfcb-0462a144d564)
9. Add the following details on the **Certificate Properties Subject** screen, then click **OK**:
   * **Subject Name**
     * **Common Name**: CN=lc-win2019-02.ad.lc-test.local
   * **Alternative Name**
     * **DNS**: lc-win2019-02.ad.lc-test.local
     * **DNS**: enterpriseregistration.ad.lc-test.local
10. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-ac07ff7cd0b6f6c195bf170bf8cf0d8e6cfc9008%2F72.png?alt=media\&token=3d43ba3a-cbf3-4e2b-9fe7-c0058d1c989c)
11. Click on **Enroll** to request the certificate, then click **Finish**.
12. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-5ac7c7cf3874d04a6cdb34a2902ef5222f3ef637%2F73.png?alt=media\&token=01968be7-6b10-4170-b281-01eac1a1bcc6)

### Setting up Active Directory Federation Services

1. Select the **Active Directory Federation Services** role, and click **Next.**
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-95b1bd5fd17a47785fcbb857dfeaee3d2c6eb8d2%2F74.png?alt=media\&token=e76ffe07-0d1a-4d5b-86c4-34cfb8a64695)
3. Click **Next** on **Select Features**, since no additional features are needed.
4. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-1c155cf9e4dd61393e05550e2fbf87cc884eb920%2F75.png?alt=media\&token=59aadfdd-bd69-4c4b-aa85-814680aee425)
5. Click **Next** on the **Active Directory Federation Services** informational screen.
6. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-5d5a515dd87e105a1c47eb0919164b06e4f99f9f%2F76.png?alt=media\&token=aae2d9d1-5b32-4b1a-a709-8705cfea9177)
7. Check **Restart the destination server automatically if required,** and click **Install** and **Close** when the installation has completed.
8. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-704526b8e22df2f6b015dd0a58f0528e00bd3319%2F77.png?alt=media\&token=36d1b80e-2dc4-4933-a374-6270fe58ff94)

### Creating a Group Managed Service Account and Adding a KDS Key

It is best to use a **gMSA** (group Managed Service Account) instead of a traditional **sMSA** (standalone Managed Service Account). The primary difference between the two is that, in a gMSA, the Windows operating system manages the password for the account instead of relying on the administrator to do it.

Before we can select the gMSA, however, we need to add a **KDS Root Key**. To avoid non-blocking warnings later in the process, this key should be added with an effective date of 10 hours prior to the current date and time.

Open a **PowerShell** session as an Administrator, and run the following command to add the KDS root key:

Add-KdsRootKey -EffectiveTime ((Get-Date).AddHours(-10))

If you do not take this step, you will see the following error when attempting to add the gMSA account:

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-90d0c0c587cd6524c829462a1b6ac33439a9f344%2F78.png?alt=media\&token=6c284a4a-a456-4f76-aa09-670f74b9fd38)

To create a gMSA account to use with the AD FS service, use the PowerShell script provided below. If you get an “access denied” error when running Install-ADServiceAccount, you may need to restart the server first.

$Name = 'sa\_adfs'

$Params = @{\
"Name" = $Name\
"DNSHostName" = 'lc-win2019-02.ad.lc-test.local'\
"PrincipalsAllowedToRetrieveManagedPassword" = 'lc-win2019-02$'\
"ServicePrincipalNames" = 'http/lc-win2019-02.ad.lc-test.local'\
}

$ServiceAccount = New-ADServiceAccount @Params

Install-ADServiceAccount -Identity $Name

Add-ADComputerServiceAccount -Identity 'lc-win2019-02' -ServiceAccount $ServiceAccount

### Configuring Federation Services

1. Click on the link that says **Configure the federation service on this server**.
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-6b932b51bbbcc066c1ef3e4da043b3741fcf2dff%2F79.png?alt=media\&token=4bcc9c62-0c36-4aec-9afa-4008eb4cf704)
3. Select **Create the first federation server in a federation server farm,** and click **Next.**
4. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-18e270f7e02f0a527dcaa928d880cd9c5356c298%2F80.png?alt=media\&token=c1362bc1-92f3-4445-a18d-900f49473928)
5. On the **Connect to Active Directory Domain Services** screen, leave the default user selected, then click on **Next**.
6. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-2761d93b79530a394a00057133633449028403f5%2F81.png?alt=media\&token=eeec4e83-ab16-4d83-8927-d93001ffaaa9)
7. Select the previously created SSL Certificate, and enter “LC Test” for the **Federation Service Display Name.** Click **Next.**
8. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-7813dab4f9aa6a5cc1ea5fe4330a6e393ef13836%2F82.png?alt=media\&token=5707fcca-7ffc-4604-9ec8-d2881a8fd8e7)
9. On the **Specify Service Account** screen, click on **Select** to use an existing account and locate the sa\_adfs service account that was previously created. Click **Next.**
10. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-90d07d102bf22b70314426b7303162b86d82a948%2F83.png?alt=media\&token=b17b7d18-13e6-4997-9565-07222e1f5892)
11. Select **Create a database on this server using Windows Internal Database,** and click **Next**.
12. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-63ae1856077c022944d47fca8d6e084b5da3cb98%2F84.png?alt=media\&token=d9dfb835-4728-4bba-868e-41a1134f6afd)
13. Click on **Next** under **Review Options.**
14. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-e1120746cdd96047204b4531950d7b8c418801b7%2F85.png?alt=media\&token=7e53370c-af3f-4291-83f9-bae3f4d81123)
15. Verify the **Pre-requisite Checks,** and click on **Configure.**
16. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-39ed4391af978ee9b61c20df396b911e08132254%2F86.png?alt=media\&token=02f8ffd3-2260-4e03-8607-e7a7aaa50418)
17. Click on **Close,** and restart the server.
18. The warnings shown below can be disregarded for this test instance:
19. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-4a4617139e88a84ecc061bfcaf7da17ccf67f8ec%2F87.png?alt=media\&token=7af89758-4c25-44b0-b9e6-83ae3adbc3e4)
20. Once the server has restarted, open an Administrative PowerShell session, and run the following command to enable the **IdP Signon Page:**
21. Set-ADFSProperties -EnableIdPInitiatedSignonPage $True
22. Verify that AD FS metadata is being returned by navigating to the following URL:
23. [https://{FQDN](https://{fqdn) of AD FS Server}/adfs/fs/federationserverservice.asmx
24. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-a500d6c49794d0444013b7f1a471abbec95f0074%2F88.png?alt=media\&token=9b1afae6-4bf8-4528-b888-8a6ec4bec5cc)

### Setting Up ReadonlyREST Relying Trust

1. Open the **AD FS** MMC snapin, right-click on the **Relying Party Trusts** folder, and select **Add Relying Party Trust.**
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-e535e928bc276fa1c520d5b71fe4403a14dfb47d%2F89.png?alt=media\&token=118f6fac-b845-4ea1-a383-e1247c2341a0)
3. Select **Claims aware,** and click **Start.**
4. Choose **Enter data about the relying party manually,** and click **Next.**
5. Enter a **Display Name** (in this case, “ror”), and click **Next.**
6. It’s not necessary to specify a token encryption certificate, so click **Next** to continue.
7. Select the option **Enable support for the SAML 2.0 SSL service URL,** and enter:
8. [https://{IP Address of Kibana Server}:5601/ror\_kbn\_sso\_saml\_adfs/assert](https://10.0.0.6:5601/ror_kbn_sso_saml_adfs/assert)
9. The saml\_adfs will change depending on the name chosen in the configuration of the kibana.yml file.
10. Enter the **Relying party trust identifiers**, in this case, “ror.” This will match the **Issuer** in the Kibana configuration. Click **Next** when you are done with this step.
11. On the **Access Control Policy** screen, select **Permit everyone,** and click **Next.**
12. Click **Next** to finish adding the trust.
13. Verify that **Configure claims insurance policy for this application** is selected, and click on **Close.**

### Configuring Claims

Though we have not yet configured claims for Kibana, the metadata for the SAML configuration in Kibana would look similar to the following, if you were able to view it:

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-e6dd96aa1c7fe1fcf74bdabd4c5cba2bc7b936a4%2F90.png?alt=media\&token=a4ac622c-d066-470d-a9e0-107fe7c0fd74)

The important section to note concerns the claims issuance policy. We need to return a **NameID** format in the form of an **emailAddress** by entering the following code\*\*:\*\*

\<NameIDFormat>\
urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress\
\</NameIDFormat>

Therefore, we need two rules: one to pull back the LDAP attribute from the Active Directory, and another to transform that data into the correct format.

1. Click on **Add Rule** on the **Edit Claim Issuance Policy** **for ror** screen.
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-c28e73db62cbff6837c80e5d06523dcffdfc14c4%2F91.png?alt=media\&token=327ddc31-5c33-4df2-bd95-553d57e34dce)
3. For the first rule, choose **Send LDAP Attributes as Claims,** and click **Next.**

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-ba8e19c1167016d96ae584ee245193d6e464c588%2F92.png?alt=media\&token=271c3ab0-4ba6-4483-a1bc-b0427a58dabb)

1. Choose the AD Attribute to return—in this case, the email address—and click **Finish** on the **Configure Rule** screen of the **Add Transform Claim Rule Wizard.**
   * **Claim rule name**: LDAP Email
   * **Active Store**: Active Directory
   * **LDAP Attribute**: E-Mail-Addresses
   * **Outgoing Claim Type**: E-Mail Address

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-a92db705b8811bbf423571de1d3ecc002ebedeb3%2F93.png?alt=media\&token=aa6ba303-8c72-4453-a3eb-f72350d4e157)

1. Click on **Add Rule,** then choose the **Transform an Incoming Claim** claim rule template, and click on **Next.**

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-947a64a1eb205db84b04e7eb0985ba254556ae77%2F94.png?alt=media\&token=889869cf-6b01-4f93-95a6-ea8f1a3613f9)

1. Enter the transformation details as listed below, and, on the **Edit Rule** screen, click on **OK.**
   * **Claim rule name**: Email Transform
   * **Incoming claim type**: E-Mail Address
   * **Outgoing claim type**: Name ID
   * **Outgoing name ID format**: Email
   * **Pass through all claim values**: Selected

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-5df28bc10774875aa51528830a1fccf38c52b9b1%2F95.png?alt=media\&token=842d1e14-4585-4ca7-b79d-3fb3834ca3ca)

1. Click **OK** to save the rules.
2. Please note that the order of the rules on the **Edit Claim Issuance Policy** screen is important.
3. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-d67917b6ba1c789ab2ed5db20e96eaf2a73a299e%2F96.png?alt=media\&token=a745b4a5-1502-4249-bb79-273ae21c5d9b)

### Updating Relying Party Trusts

1. Navigate to the **Relying Party Trusts** folder, right-click on the **ror trust,** and select **Properties.**

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-b58fa9f72cfbd8ca5dad64a363501695a8ed7326%2F97.png?alt=media\&token=d7ddc6ea-4718-4ede-a73e-1c314686dcfa)

1. Click on the **Endpoints** tab, select the **SAML Assertion Consumer Endpoints,** and click on **Edit.**

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-e86848175d48835d704d5e3b6c3480fbd3a021c1%2F98.png?alt=media\&token=02c45d88-1526-44c5-91ab-29aa36c8356f)

1. Click on **Set the trusted URL as default,** and change the Index to 1 from 0. Click **OK.**

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-53b02a8121f5c7b37442e361cd035bf3f944c016%2F99.png?alt=media\&token=dc4f3e80-e50f-44d2-a37f-c61d6faa9849)

1. On the **Endpoints** screen, click on **Add SAML,** and enter the **SAML Logout** details as follows:
   * **Endpoint Type**: SAML Logout
   * **Binding**: POST
   * **Trusted URL**: [https://{IP](https://{ip) Address of Kibana Server}:5601/ror\_kbn\_sso\_saml\_adfs/notifylogout

![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-22227dc8204371ec39bcf421306c01371ea7c2b9%2F100.png?alt=media\&token=589088c6-3412-4215-9dae-066db7242df2)

1. Click on **OK** to save the modified properties. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-0967557e46893893ea9b0402aeb57a4d084df6f5%2F101.png?alt=media\&token=3e54a5dd-b4fa-4649-8577-f5d822e27fdf)

## Installing and Configuring Elasticsearch and the ReadonlyREST Free Plugin

### Installing Elasticsearch

Elasticsearch will be installed on the lc-win2019-03 server provisioned with 8GB of RAM in Azure.

1. Locate a recent download of [Elasticsearch](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/windows.html), and install the [MSI](https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2.msi) package.
2. At the time this article was written, the most recent version available was 7.6.2; however, you may want to check for more updated versions as they become available.
3. Launch the downloaded installer and click **Next** on the **Locations** screen, leaving the defaults in place.
4. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-0182290052b377bfac15ef54d5911a20d57b83be%2F102.png?alt=media\&token=aaf81dbf-f1e7-4e74-9894-7a76727892c9)
5. Use the defaults on the **Service** screen, and click **Next.**
6. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-9e587c2fe7d3e0821b789456a12b2bb74eeab10a%2F103.png?alt=media\&token=ac5e4052-db8e-457f-8e8e-c2eb127c1f71)
7. Use the defaults on the **Configuration** screen, and click **Next.**
8. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-f6a02e321f182eba8b6aafff5d6b5abf5ead56d7%2F104.png?alt=media\&token=7d795108-7efc-4b84-b6b9-4b1e93f8e43a)
9. No additional plugins are necessary; therefore, click **Next.**
10. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-fd70edbf642636ff7fce97b3542ddbe158cbb9ec%2F105.png?alt=media\&token=db6e6594-4f85-4ab5-a030-cab0543e5791)
11. Leave the **X-Pack** licenses set to **Basic,** and click on **Install.**
12. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-1b5650d0b9f4213aa222b491eb19a615847bb3ce%2F106.png?alt=media\&token=a58339b2-7c1a-421c-bc8d-1b60a140a4c6)
13. Click on **Exit.**
14. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-49e7341b7a09990820e62bf1ff117819f13eaa16%2F107.png?alt=media\&token=328f8d0a-965a-41b8-bcbe-72ddb27fb5d0)

### Installing the Elasticsearch Plugin

1. Navigate to the [ReadonlyREST Plugin download page](https://readonlyrest.com/download/) to enter your details. You will receive the download link in your email. Make sure to choose the **Free Elasticsearch Plugin** that matches your Elasticstack version.
2. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-704be0180a1f20394a637e1c5ec7c135ad66e680%2F108.png?alt=media&#x26;token=2dc404c8-1fb8-47e4-a9fe-3912f311729a" alt="" data-size="original">
3. Download the plugin, open an Administrative command prompt, and navigate to the Elasticsearch program directory. Run the plugin installation by entering the following:
4. cd "C:\Program Files\Elastic\ElasticSearch\7.6.2\bin"

   elasticsearch-plugin.bat install file:///C:/Users/lc-admin.AD/Downloads/readonlyrest-1.19.4\_es7.6.2.zip
5. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-5791edbd016504bdba8b4d2b2d7f0077d20ff6c6%2F109.png?alt=media&#x26;token=2ed16c7f-6e47-45c7-80f5-5f05533d98d2" alt="" data-size="original">
6. Navigate to the C:\ProgramData\Elastic\ElasticSearch\config directory, and create the file readonlyrest.yml.
7. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-fc2e08ea5996e932d83e258c0ffa6e0e3345f731%2F110.png?alt=media&#x26;token=536f539a-ea46-4cee-bf42-59e5eb28cfeb" alt="" data-size="original">
8. Open the readonlyrest.yml file in Notepad to run this very basic configuration that configures the following two different access control rules: 1. **“**::KIBANA-SRV::**”**—this rule allows the Kibana server to authenticate to Elasticsearch using digest authentication with the username “kibana” and password “kibana.” 2. “ADFS Users”—this rule uses the ror\_kbn\_auth method which allows SAML authenticates to succeed.
9. Create a random 256-character signature\_key. This key will be shared between Kibana and Elasticsearch.
10. Please note that the kbn1 identifier must match in the ror\_kbn\_authentication and ror\_kbn sections; however, any names can be used for them.

    ```yaml
    readonlyrest:  
     access_control_rules:

     - name: "::KIBANA-SRV::"  
       auth_key: kibana:kibana

     - name: "ADFS Users"  
       ror_kbn_authentication:  
         name: "kbn1"

     ror_kbn:  
     - name: kbn1  
       signature_key: "VEGj@YLLhsAigspnNi2Xsopsqja_nrKUqU__eQW9VQ2!9p!RoeHwc-G.y-MVJtYYcDFCH.e3W2BKcZsoynJaHyjjXyh7kDHjsYKPkczvai-xCzP@Ez3QW23ZBFuReA7kPAqnc6pQ3VeNeFf3sWNoKeJAt_d9J7aFwEvCP2Gb-kQcA8YR*wNWHQuo-jwmmo2Qqpu_Fq3aKFCbNFWUbK@BVwmmKezxn3h687mAkuyhV4.hnfrjVjF-Rphjqmy4.tB8"
    ```

There are three rule types available, depending on what you want to achieve:

* [ror\_kbn\_authentication](https://docs.readonlyrest.com/elasticsearch#ror_kbn_authentication) (handles only authentication)
* [ror\_kbn\_authorization](https://docs.readonlyrest.com/elasticsearch#ror_kbn_authorization) (handles only authorization)
* [ror\_kbn\_auth](https://docs.readonlyrest.com/elasticsearch#ror_kbn_auth) (authentication + authorization in a single rule)

11. Restart **Elasticsearch** **Windows Service**. This can be done in the **Services** MMC snapin.

## Installing and Configuring Kibana and the ReadonlyREST Enterprise Plugin

### Installing Kibana

1. Locate a recent download of [Kibana](https://artifacts.elastic.co/downloads/kibana/kibana-7.6.2-windows-x86_64.zip), and download the zip package. At the time this article was written, the most recent version was 7.6.2. You may want to check for more updated links as they become available.
2. Extract the Kibana installation. Note that this is a rather large file. If you have trouble with the default Windows zip extractor, you may want to try a tool such as 7-Zip.
3. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-e9aa2d483df60e98e1480329008733b61d5e0870%2F111.png?alt=media\&token=031c619b-469f-4975-8498-ec501567693a)
4. Move the extracted folder to C:\kibana. This may require you to rename the folder.
5. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-a27f5e76ca4ef3f1d4fa36cfba74952461ba4b35%2F112.png?alt=media\&token=3ddd788e-cf76-489b-a8e1-7d30dd858aa9)
6. Open an administrative command prompt, and navigate to the **Kibana** directory to run the kibana.bat batch file and start **Kibana.**
7. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-beab965dbcd027dce064a380775454028bfd8155%2F113.png?alt=media\&token=c306accb-c037-4072-8d8d-c22a11f76b57)
8. Once Kibana has started, navigate to <http://localhost:5601> to verify that Kibana is functional.
9. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-cafe95628625505ff1cf52e8d4f62ffc1877313f%2F114.png?alt=media\&token=8ae0d979-dcf9-4dc9-be15-0330623870be)

### Creating a Self-Signed Certificate for Kibana

It is necessary to make Kibana operate under SSL for AD FS to perform SAML authentication.

1. The easiest way to generate a self-signed certificate using the required format is to use **OpenSSL**. A Windows version of this tool available for download is located [here](https://slproweb.com/products/Win32OpenSSL.html).
2. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-07686d65e90f990cf2599755642d2fd12e21a18d%2F115.png?alt=media&#x26;token=1ba5cba3-02e0-4638-b31b-659211124fe5" alt="" data-size="original">
3. If **Microsoft Visual C++ 2017 Redistributables (64-bit)** is not already installed, click **Yes** to download the installation and run the installer first.
4. Accept the license agreement, and click on **Install.**
5. Back on the OpenSSL installation, click on **I accept the agreement**, then click on **Next.**
6. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-fea305d63d48c76b76dc88f57d09fcbfb6ecc443%2F120.png?alt=media&#x26;token=1b1d7a1b-0407-4d9f-991d-91c4004d2d07" alt="" data-size="original">
7. Click **Next** on the **Destination Location** screen.
8. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-550c343c608f9b1fd9b200b03457401385825a9e%2F121.png?alt=media&#x26;token=ff576519-50aa-4163-b7bb-43b03fba1297" alt="" data-size="original">
9. Click **Next** on the **Select Start Menu Folder** screen.
10. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-6c982a85a0d029e509cf593760b7f09d25b449b8%2F122.png?alt=media&#x26;token=f68128ca-7e70-451f-b580-bd1d0be85599" alt="" data-size="original">
11. Select **The** **Windows system directory** on the **Additional Tasks** screen, and click **Next.**
12. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-9b2a32a01cf4f1bb73fec10871bbb35ec5323445%2F123.png?alt=media&#x26;token=0dffddff-9996-409c-ae89-2107150c1f5b" alt="" data-size="original">
13. Click on **Install.**
14. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-b995b218a5f07c9fb44809f3a5779bca8fd8fe3f%2F124.png?alt=media&#x26;token=d7437dfe-5e4a-4be6-ae42-ca47022eca76" alt="" data-size="original">
15. Click on **Finish.**
16. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-5c7a92e505f33a72b788a170c0e7fc0d21773ba3%2F125.png?alt=media&#x26;token=be0c5e3d-7a53-49f0-b779-ef1b16927470" alt="" data-size="original">
17. Open an administrative command prompt, and run the following command to create the certificates in the specific X509 PEM format that Kibana requires:
18. "C:\Program Files\OpenSSL-Win64\bin\openssl.exe"

    req -x509 -sha256 -nodes -days 730 -newkey rsa:2048 -keyout localhost-key.pem -out localhost.pem -subj "/C=US/ST=IL/L=Bloomington/O=lc-test/CN=10.0.0.6"
19. Change the subj to one that is more indicative of your installation. Make sure the CN={IP Address} matches the accessible IP of your Elasticsearch/Kibana server.
20. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-098170f7ee63d6fe5d3399fd505b3d1c9887a7f1%2F126.png?alt=media&#x26;token=a310892a-6eab-4514-a38d-be793683ba8e" alt="" data-size="original">
21. Locate the newly created pem certificates and copy them to C:\kibana\ssl\_cert.
22. The ssl\_cert directory will need to be created first. For our purposes here, it has been arbitrarily named.
23. <img src="https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-a213191e65432c4f3b056371cb9198e500c6d5f2%2F127.png?alt=media&#x26;token=db7f5d5d-71d2-4f38-bf0f-145d742815d2" alt="" data-size="original">
24. Restart Kibana by entering **Ctrl-C** in the running command prompt window and then re-running kibana.bat.

### Installing the ReadonlyREST Enterprise Plugin

1. Navigate to the [ReadonlyREST Plugin download page](https://readonlyrest.com/download/) to enter your details. You will get the download link in your email. Making sure to choose the **Enterprise Kibana Plugin** and match it with your Elasticstack version.
2. The email that you receive will contain installation instructions. The link will be time-limited, as shown below.
3. Navigate to C:\kibana\config, and locate the kibana.yml configuration file.
4. Open the kibana.yml file in Notepad and update it with the following details:

```yaml
    elasticsearch.username: kibana  # This field matches the first part (pre-colon) of the auth\_key in the readonlyrest.yml Elasticsearch configuration file.
    elasticsearch.password: kibana # This field matches the second part (post-colon) of the auth\_key in the readonlyrest.yml Elasticsearch configuration file.
    elasticsearch.ssl.verificationMode: true # Set the value to “true” to ignore SSL errors. This is useful when working in a test environment.
    xpack.security.enabled: false # This must be disabled for ReadonlyREST to work. Skip this setting in the Kibana configuration for version 8.x, as it has been removed.
    server.host: 10.0.0.6 # We need to use a routable address, which, in this case, is the 10.0.0.6 IP of this server.
    server.ssl.enabled: true # This is used to turn on SSL and respond to https.
    server.ssl.certificate: '/etc/kibana/ssl_cert/localhost.pem' # This is the location of the public key certificate.
    server.ssl.key: '/etc/kibana/ssl_cert/localhost-key.pem' # This is the location of the private key for the certificate.
    readonlyrest_kbn:
      logLevel: debug # The value is set to “debug” to enable troubleshooting in the console.
      clearSessionOnEvents: [ login ] # This clears the session on a successful login event.
      auth:
        signature_key: "VEGj@YLLhsAigspnNi2Xsopsqja_nrKUqU__eQW9VQ2!9p!RoeHwc-G.y-MVJtYYcDFCH.e3W2BKcZsoynJaHyjjXyh7kDHjsYKPkczvai-xCzP@Ez3QW23ZBFuReA7kPAqnc6pQ3VeNeFf3sWNoKeJAt_d9J7aFwEvCP2Gb-kQcA8YR*wNWHQuo-jwmmo2Qqpu_Fq3aKFCbNFWUbK@BVwmmKezxn3h687mAkuyhV4.hnfrjVjF-Rphjqmy4.tB8" # This must match the 256-character value in the signature\_key attribute of the readonlyrest.yml Elasticsearch configuration file.
        saml_adfs:
          buttonName: "ADFS SAML SSO" # This is the name of the login button on the login screen of Kibana.
          enabled: true # This enables the SAML SSO configuration.
          type: "saml" #  For AD FS, this must be “saml.”
          issue: "ror" #  This is the unique identifier that was defined in the AD FS Relying Party Trust configuration, in this case, “ror”.
          protocol: "https" # AD FS requires https.
          entryPoint: "https://{AD_FS Server}/adfs/ls" # This is the entry point for AD FS
          logoutUrl: "https://{AD_FS Server}/adfs/ls?wa=wsignout1.0" # This is the logout call to AD FS
          kibanaExternalHost: "10.0.0.6:5601" # This is the address and port without the protocol preceding (i.e., https).
          usernameParameter: "nameID" # This configuration is only doing authentication, and it must match the nameID parameter.
          # disableRequestedAuthnContext: false # This is optional configuration which can fix known `SAML provider returned Responder error: NoAuthnContext` https://github.com/node-saml/passport-saml/issues/226. Allowed value is true/false
          # authnContext: "http://schemas.microsoft.com/ws/2008/06/identity/authenticationmethod/windows" # Name identifier format to request auth context. Allowed value is a string array of strings. Default: `urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport`
          # identifierFormat: null # Name identifier format to request from identity provider. Allowed value is a string. Default: `urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`
```

### Opening the Firewall Port

To allow the AD FS server to talk to Kibana, we need to open the 5601 port on the Kibana server since \[localhost]\([http://localhost\\](http://localhost\)) is not routable.

1. Open the **Windows Firewall with Advanced Security** screen, and add a new rule under **Inbound Rules.** Choose **Port.**
2. Add the specific local port of **5601,** and click **Next.**
3. Select **Allow the connection,** and click **Next.**
4. Choose all profiles (the default), and click **Next.**
5. Name the rule “Kibana,” and click **Finish.**

## Demonstration

1. Navigate to your Kibana URL ([https://10.0.0.6:5601\\](https://10.0.0.6/:5601\)/) using Chrome or Firefox. Do not use IE or the SSO button may not show up.
2. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-7e81ac84c08bc276833b624d9c35bfac9f2499e4%2F128.png?alt=media\&token=8d8e658c-63fd-4ed2-9fd2-1c3380cb91f7)
3. Click on ADFS, the button configured in the kibana.yml file, and log in with one of the created AD users. Use the defined mail attribute on the AD account (an email address).
4. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-b0165c56a985f14fb0920529642f2f38cac2382a%2F129.png?alt=media\&token=a9f91e50-5439-450d-9bfe-1a3a8d34bb16)
5. With a successful login, the Kibana screen will appear, and you will see your SAML authenticated user in the lower right corner.
6. ![](https://2649711535-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MIs6FnSQk86FxD8nNwy-887967055%2Fuploads%2Fgit-blob-9c6365b130e7f2933e2f37fdb189b88ad7e1d676%2F130.png?alt=media\&token=73a9e146-59ac-4ec4-bdbd-ffed206313b0)

## Conclusion

ReadonlyREST combined with Elasticsearch and Kibana opens a world of advanced authentication and authorization options to you. Though only a basic configuration was outlined here, many more useful configuration options are available. You can find out more information about these advanced configurations in the ReadonlyREST documentation and in the ROR forums.
