Kasm (VDI/DaaS/RBI) - Part 2
- Kasm is installed on Rocky Linux 9.6 in a web DMZ and is accessible from the outside.
- Configuring Kasm and publishing resources (workspaces).
- OIDC authentication delegated to Azure (Entra ID).
- Testing access and observations; data persistence is possible but not by default.
Introduction
The previous article about Kasm aimed to introduce the solution and present the lab architecture to be implemented. If you haven't read the latter, I invite you to do so before starting this one.
Kasm is now installed on a Rocky Linux 9.6 virtual machine running on an XCP-ng node.
The server is deployed in my web DMZ so that it can be reached from the outside via the URL https://kasm.coolcorp.fr.
This same URL is exposed via Traefik as an external resource to my Kubernetes cluster, with Kasm being completely outside of my K8S infrastructure. However, in my first article, I explained how to benefit from the advantages of Traefik, particularly with the integration of Cert-Manager for certificate automation, which is an application not present on Kubernetes.
Also, please remember that this URL in coolcorp.fr is intended only for external access.
Internally, I use the URL https://kasm.coolcorp.priv, whose certificate is associated with my internal Windows PKI.This internal URL is reserved for Kasm administration.
For this, I can use the default admin account generated during Kasm installation.Don't hesitate to read my previous article again to learn more.
Configuring Kasm
Setting up OAuth2/OIDC authentication with Azure Entra ID
Azure Part
To start the next part of the lab deployment, we will begin by integrating authentication on the public side via Azure Entra ID and combining OAUTH2 (authorization management) and OIDC (OpenID Connect: authentication management).
This is to take advantage of Microsoft's cloud directory, which is itself synchronized with my internal Active Directory.
I won't go into detail at this level, but this is an authentication logic that is commonly found in businesses.
Note that it is not necessary to have an internal directory. What we are going to see now also applies to architectures based solely on Azure Entra ID.
The process involves declaring an app in your Azure tenant for which you will generate a secret. This secret, along with the ID of our application, will be configured in Kasm, which can then request the Azure application created in Azure Entra ID and relay user authentication to it. If authentication is successful, a session token containing information about the validated user is returned to Kasm. Kasm can then offer the various resources accessible to that user.
The advantage of this type of method is that it leverages modern authentication mechanisms, which can also benefit from Azure Entra ID protections such as conditional access rules and the implementation of good security practices (requiring the use of MFA - Multi-Factor Authentication).
In my case, since I only have a free account, I do not have access to conditional access rules, but I can activate MFA without being able to configure its behavior; MS reserves the right to identify or not the need for MFA based on the connection location. This is one of the limitations of the free version of Azure Entra ID, but we can still learn about its use and implement the necessary prerequisites.
Therefore, we go to your Azure Entra ID administration console in your Azure tenant.
At this level, we are in App Registration.

Click the image to enlarge.
Then, we create our application, named here for example "app-coolcorp-kasm". I encourage you to follow a precise naming convention for your authentication apps.

Click the image to enlarge.
I authorize the use of this application only to users in my tenant via the default option.
My application is of type web, and the redirection page will be that of my public Kasm exposure, supplemented by the API tree referencing oidc for the callback.
Specifically: https://kasm.coolcorp.fr/api/oidc_callback.

Click the image to enlarge.
Once the application is in place, we obtain several elements that will need to be saved.
- The application ID: this is what references the newly created application on the MS side
- Directory ID: This is the Azure tenant ID where the application is registered (in this example, my tenant).

Click the image to enlarge.
This is not sufficient to allow Kasm to request apps and delegate authentication to them.
To complete the process, you need to create a secret in the app's Certificates & Secret menu.

Click the image to enlarge.
We generate a new secret.

Click the image to enlarge.
We configure an expiration date for this secret. Ideally, for security reasons, it is best not to exceed 6 months, or even 3 months for critical items.
Since this is a lab environment, I will allow myself to be a little more lenient and set it to 12 months.

Click the image to enlarge.
You then obtain a secret value: this is obviously critical and sensitive. It must be saved in a secure location. Note that you will no longer be able to display it once it has been shown for the first time. If it is lost, you will need to regenerate a new secret.
Be careful, the secret ID is not the same as the secret value.

Click the image to enlarge.
To complete this "application registration" section, you must go to the API Permission option.
At this level, you will need to add permissions to allow the application to access additional attributes associated with the user, in order to provide these elements in the token that will be provided to Kasm.

Click the image to enlarge.
To do this, we add the email, openid, profile permissions, in addition to User.read, which should already be present.

Click the image to enlarge.

Click the image to enlarge.

Click the image to enlarge.

Click the image to enlarge.
Do not forget to click on Grant admin consent for default directory to validate these permissions.

Click the image to enlarge.
Once the application registration is complete, you can return to the main menu of Azure Entra and switch to the All Application option and choose the newly created application.

Click the image to enlarge.
The goal is to assign a limited number of users who can be authenticated via this application.

Click the image to enlarge.
For my part, I will simply add my user synchronized from my local AD.

Click the image to enlarge.

Click the image to enlarge.
Before closing the Azure console, check at the global level of your tenant, in the Security section, that the Your organization is protected by security default option is enabled. In a free tenant, this guarantees a minimum level of security by allowing Microsoft to manage the authentication policy, including the use of MFA.

Click the image to enlarge.
For those who have a paid subscription, the options are much more advanced at this level, and I strongly encourage you to set up conditional access rules associated with the application (restrictions on devices used, geographic connection zones, etc.).
That's all for Azure.
Kasm Part
Now we need to configure Kasm to declare this authentication delegation.
To do this, we use the internal URL (in my case, https://kasm.coolcorp.priv) to authenticate with the administrator account (for more details, see my first article).

Click the image to enlarge.
In the Access Management section, click on Authentication, then on OpenID.

Click the image to enlarge.
Then click on Add Config.

Click the image to enlarge.
We declare an Azure Entra configuration.

Click the image to enlarge.
If you enable "Auto Login", your user will be automatically redirected to the Azure Entra ID authentication portal if they access your Kasm platform via the hostname you specify below (in my case, kasm.coolcorp.fr).
In a corporate environment, this can be useful if the user has already authenticated with Azure Entra using an account from the company directory. If they access Kasm, they will benefit from SSO to directly access the published resources.
After that, you need to enter the data retrieved from the application declared previously, namely the Client ID and Secret.

Click the image to enlarge.
As for the Authorization URL and the Token URL, they are composed as follows:
- https://login.microsoftonline.com/$id_tenant/oauth2/v2.0/authorize
- https://login.microsoftonline.com/$id_tenant/oauth2/v2.0/token

Click the image to enlarge.
For the User Info URL, you need to enter this URL:
https://graph.microsoft.com/oidc/userinfo

Click the image to enlarge.
In the scope field, we specify the information about the user that we want to retrieve in the authentication token, corresponding to the permissions you added in the Azure app. Specifically:
- openid
- profile
- user read

Click the image to enlarge.
As the login attribute, in the username attribute, we use the user's email address.

Click the image to enlarge.
In my example configuration, I do not use any group concept.
The redirect URL must match what was entered in the same field at the Azure app level, which in my case is:
https://kasm.coolcorp.fr/api/oidc_callback

Click the image to enlarge.
You can click on save to save the configuration.
If authentication delegation is in place, so that Kasm can use Azure Entra ID as a trusted source, the user, although present in Azure Entra, is not yet in the Kasm database.
To do this, you need to go to Access Management, and then to Users to create the user.

Click the image to enlarge.
You indicate that it is associated with the OIDC authentication profile that we created, and most importantly, use their email address as the Username. This ensures consistency with the OpenID configuration choice made earlier.

Click the image to enlarge.
Now that the public login part is handled, it's time to declare resources so that Kasm can expose them to the user once they are logged in.
Configuring resources to expose
Exposing a physical Windows 11 machine via RDP
The first resource I want to offer in my case is access to my desktop PC running Windows 11 via an RDP connection.
First, go to the Infrastructure option, then to Server, and click on Add.

Click the image to enlarge.
Specify the protocol to use, which in my case is RDP.
Enter the IP address or hostname of the target. (Be aware of network traffic openings if there is an intermediate firewall).

Click the image to enlarge.
For everything else, I leave the options at their defaults, until I reach the Kasm Desktop Service Installed parameter, which I will activate to obtain a Registration Token.

Click the image to enlarge.
Indeed, to make the experience more efficient, I am going to deploy the Kasm agent on my desktop PC. This is not mandatory, but its presence will allow for more advanced interaction, such as file uploads and other interesting benefits.
The agent is available on the Kasm website.

Click the image to enlarge.
Download the version specific to your operating system, then start the installation.
Once you have reached the end of the wizard, fill in the information requested for configuring the agent.
Enter the URL of the KASM API, in my case, the internal access, which is kasm.coolcorp.priv.
It is at this level that I enter the token obtained previously in the Kasm administration console.

Click the image to enlarge.
Note that the Kasm server must be able to connect to the agent on TCP port 4902; access must be open for the agent registration to work. In my case, I had to create a rule on my OPNsense firewall (feel free to read the introduction to Kasm, where I explain where I have located my server and the details of the network part).

Click the image to enlarge.
If everything goes well, you should see the following window:

Click the image to enlarge.
On the Kasm side, you should see this result.

Click the image to enlarge.
Having created the "RDP" resource for my desktop computer in Kasm, I now need to offer it within a Workspace.
This is the basic principle of Kasm: we create resources of various types and then associate them with workspaces, which can be offered to a user or a group of users.
We therefore go to the Workspace section of the Kasm administration menu.

Click the image to enlarge.
Click on Add Workspace.

Click the image to enlarge.
Specify the type of workspace; in this case, a Server workspace. Give it a descriptive name. For example, since this is access to my desktop computer, I'll indicate its name and specify that it's an RDP connection.
I also provide a brief description.
And I select the resource I created just before.
If needed, you can add an SVG icon for better illustration of the workspace.

Click the image to enlarge.
Exposing a Linux VM via SSH (accessing the KUB API)
The second resource I want to expose is access to my Kubernetes cluster.
To do this, we go back to the Server section to create a new resource.
This time, I'll give it the name of my Kubernetes cluster's API.
Instead of RDP, I'll be using SSH.
I will point the resource to the IP address of my first control plane, selecting the static Credentials option.

Click the image to enlarge.
Therefore, I need to specify the login for the connection. For me, it's "admink8s", which is an existing user on my K8S control plane node (see my Kubernetes cookbook).
I won't go into detail about this part, but the idea is to have previously created an SSH key directly on my K8S node for this user, using the following command:
ssh-keygen -t ed25519 -a 100 -C "kasm@admink8s"

Click the image to enlarge.
I specified a password to protect the private key, and then I retrieved the value of that key to enter it (along with its password) in the Kasm interface, at the level of my resource.

Click the image to enlarge.
The purpose of this operation is to highlight the fact that we can also use Kasm as a kind of bastion host.
The end user can easily access an SSH connection via Kasm without having to enter any connection details, because this information is directly integrated into the settings of the published resource.
In my example, I could directly access my Kubernetes node as the admink8s user without needing to know its authentication details.
As with my RDP server, I will now create a workspace of type Server, but this time referencing my SSH connection pointing to my first control plane.

Click the image to enlarge.

Click the image to enlarge.
Here too, I can add a logo if needed to further differentiate my workspace.
Exposing a temporary Chrome instance
Before testing everything, I am going to create one last workspace. This is probably the most interesting for a Kasm configuration.
This workspace will not be of type Server like the other two, but Container.

Click the image to enlarge.
I haven't had to create a dedicated Docker server component before because, being on a single-server Kasm installation, it already acts as a Docker agent by default. This means that the Kasm server itself will execute the containers that I might need to deploy and expose. It is important to note this.
You can see this in the Infrastructure menu.

Click the image to enlarge.
If we go back to my Container workspace, I will dedicate this one to running a Chrome browser.
The idea is to be able to launch a temporary, isolated browser. This can be extremely useful for various needs, such as temporarily accessing a web resource that would otherwise be blocked from its connection location (e.g., webmail). We might also want to test access to a URL whose legitimacy is questionable and ensure that we are accessing it via a controlled environment or sandbox.
In the case of this workspace, the idea is to have, on demand, the launch of a container with a version of Chrome that can be controlled via streaming, perform the desired tasks, and then destroy the container once the session is complete.
.For this purpose, Kasm comes with access to a specific registry maintained by the company behind Kasm, which already contains several ready-to-use Docker images.
Simply select the image you need, for example Chrome in my case, and associate it with your workspace.

Click the image to enlarge.
All the following options allow you to configure the container, including the resources that will be allocated to it.
I will leave these options at their defaults here.
Testing access and observations
If I go back to the list of my Workspaces, I now have three available.
Two are of type Server: one for RDP access to my physical machine and the other with SSH access to my first Kubernetes control plane.
The third workspace, of type Container, is the one we just created, dedicated to running a temporary Chrome instance.
For those wondering what other images are available, simply click on Registry.

Click the image to enlarge.
The selection is already very extensive.
It's worth noting that you can declare your own registry to present your custom images (subject to certain requirements for use with Kasm).
Another interesting point: in a multi-node installation (see the first article), you can have multiple Docker proxies, or even Kubernetes directly, to configure pools dedicated to running your containers.
This allows you to build an entire architecture dedicated to provisioning different resources based on expressed needs.
Furthermore, it extends the ability to offer different access levels and different resources to users or groups of users.
For example, in my case, my account is in the All Users group.

Click the image to enlarge.
I have given this group access to my three workspaces.

Click the image to enlarge.
Therefore, I should be able to access all the resources I have created through this user, from outside using a simple web browser pointing to https://kasm.coolcorp.fr.
In fact, that's what I'm going to test right now.
Typing in https://kasm.coolcorp.fr immediately redirects me to the Azure Entra authentication portal (since I have enabled the Auto Login option).

Click the image to enlarge.

Click the image to enlarge.
Once logged in, Azure sends me back to Kasm, and I'm pleased to see my Workspaces there.

Click the image to enlarge.
I can access each of them without difficulty.
Whether it's to access my desktop PC via RDP,

Click the image to enlarge.

Click the image to enlarge.

Click the image to enlarge.
to my Kubernetes API thanks to SSH access,

Click the image to enlarge.

Click the image to enlarge.

Click the image to enlarge.
or to launch a temporary Chrome instance.

Click the image to enlarge.

Click the image to enlarge.
The magic is that everything is done through a simple internet connection and a web browser, without any other interaction than HTTPS pages.
Container streaming is one of Kasm's features. As a reminder, a container does not have a graphical interface, but the images offered by Kasm include a rendering server, such as X11, Xvfb or TurboVNC.
This integrated server within the image can provide a streaming channel via protocols like noVNC or other references based on WebRTC to display the graphical interface of the containerized application in the user's browser and interact with it.
Kasm therefore acts as a "gateway" by streaming the display to the client browser.
Here is a simplified diagram:
Regarding the user experience, once logged in to the home menu, I can see all my active sessions and switch between them to resume my work or decide to close those that have become unnecessary.

Click the image to enlarge.
For example, if I delete my Chrome session, the underlying container is destroyed, and everything from my browsing history is erased.

Click the image to enlarge.

Click the image to enlarge.
On the administration interface (via the URL https://kasm.coolcorp.priv), you can monitor everything happening on the platform.

Click the image to enlarge.
This includes a listing and details of all open sessions.

Click the image to enlarge.

Click the image to enlarge.
We also have monitoring of resource consumption for each component.

Click the image to enlarge.
It's really very comprehensive and very useful.
As a user, I can choose to end all my sessions at once.

Click the image to enlarge.
Conclusion
That concludes our exploration of Kasm, through these two articles. For me, it's clearly a superb product and a very interesting platform.
To answer my initial question from the first article, namely whether Kasm can be an alternative to VMware Horizon... I will give a Normand-style answer: it depends.
This will depend on the intended uses. In its free version, Kasm cannot automatically provision VMs on a vCenter and then make them available to users.
However, it is still possible, through other mechanisms, including RDP and SSH publishing, to provide access to existing work environments.
However, the premium version of Kasm offers VMware vSphere AutoScale, which seems capable of handling these on-demand VDI use cases.
Application publishing is also possible through a different approach than Citrix, but it remains perfectly achievable thanks to Kasm's ability to stream containerized content, knowing that it is possible to persist the data, even if this is not the default behavior.
In any case, I am certain that I will continue to use this platform in my lab and develop my skills on it, because I find it extremely relevant in the IT market and very useful for many situations.