Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add keycloak documentation #430

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions docs/guides/stream-security/keycloak-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
title: Keycloak Integration
description: This guide explains how you can integrate your streaming application with [Keycloak](https://www.keycloak.org/) Identity Management to make WebRTC pages secure.
keywords: [Keycloak, Stream security, Ant Media Server Documentation, Ant Media Server Tutorials]
sidebar_position: 7
---

[Keycloak](https://www.keycloak.org/) is an Identity Management tool which makes authentication and authorization easy for different services by providing a single sign-on (SSO) solution. We can use Keycloak to make WebRTC pages secure by Keycloak authentication.

Ant Media default streaming application `StreamApp.war` has Keycloak integration as disabled. So if you create your own streaming application using from `StreamApp.war` or configure an existing application coming from installation, you should enable and configure Keycloak configurations. Here we will tell Keycloak and Ant Media Side configurations.

# Keycloak Confiuration

1. Please check [Keycloak Getting Started](https://www.keycloak.org/guides#getting-started) documentation to Setup Keycloak.
2. After make it run we will create a **Realm** from Keycloak Dashboard. Lets name it **antmedia**
3. Create an **Open ID Client** in the Realm (**antmedia**) we created in step2. Lets name it **stream-application**. Then set the URL as in the image below.
![](@site/static/img/stream-security/keycloak-client-creation.png)

4. Create a role in the Client (**stream-application**) we created in step3. Lets make role name **user**
5. Create a User in Realm with the role (**user**) we created in step4. Lets make user name **streamer1**


With the above configurations Keycloak side is ready. Now we will proceed with AMS configuration.

# AMS Configuration
1. Please navigate to the application folder in your AMS installation like:
`cd /usr/local/antmedia/webapps/{APP-NAME}/WEB-INF`
2. Uncomment the following lines in red5-web.xml and set the values according to you Keycloak server configurations.
```xml
<!-- For Keycloak Integration -->
<!--
<bean id="openid.config" class="io.antmedia.SecurityConfiguration">
<property name="realmUrl" value="http://keycloak.antmedia.cloud:8080/realms/antmedia" />
<property name="appName" value="demo" />
<property name="clientId" value="stream-application" />
<property name="role" value="user" />
</bean>
-->
```
**Note that:** appName should be the same with the application name we are configuring. Also all these parameters shoul be compatible with the configuration in the Keycloak.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@burak-58 I think we used :::infoTEXT HERE::: for the notes in other documents so lets keep it consistent ! :D


3. Uncomment the following lines in web.xml
```xml
<!-- For Keycloak Integration -->
<!--
<filter>
<filter-name>ContentSecurityPolicyHeaderFilter</filter-name>
<filter-class>io.antmedia.filter.ContentSecurityPolicyHeaderFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>ContentSecurityPolicyHeaderFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-->
```
4. Restart the antmedia service

`sudo service antmedia restart`

# AMS Configuration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header is a duplicate + i think we should use the one with ## since it add's a link for navigation at the top right of the screen


Try to publish a WebRTC stream through sample publish page. It should requires Keycloak authentication.
`https://{AMS-URL}/{APP-NAME}/samples/publish_webrtc.html`


Try to play a stream through sample play page:
`https://{AMS-URL}/{APP-NAME}/player.html`
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.