# How to Configure a New Tenant?

In this section, we will go through the steps involved in a typical flow, starting from creating new tenants to enabling them to create schemas and verifiable credentials (VCs).

## Set up Keycloak

* Login to the Keycloak console (localhost/auth/admin) as admin (password: admin). If you are getting https required error while trying to access the Keycloak console, run the following commands to set the SSL requirement of external requests to NONE (Note: This should be reverted back once the https is set up and moved to production).

&#x20;    \- Connect to the registry DB and run the following query (Postgres DB configured in the docker compose file):

```
update REALM set ssl_required='NONE' where id = 'master';
```

&#x20;    \- Restart Keycloak service:

```
docker-compose -f docker-compose-vc-issuance.yml up -d --build --no-deps keycloak
```

* The Sunbird-RC realm must have already been created due to the volume mounting of the realm file in the docker compose file.
* Click on Clients in the configure section on the left pane and click on admin-api.
* Go to the credentials tab. Click on Regenerate Secret and copy the new secret.
* Change the sunbird\_sso\_admin\_client\_secret to the copied secret in the docker-compose-vc-issuance.yml.
* Rebuild and restart the registry service that uses sunbird\_sso\_admin\_client\_secret.

```
docker-compose -f docker-compose-vc-issuance.yml up -d --build --no-deps vc-registry
```

## Set up Mail for Admin User on Keycloak

This step can be skipped during the development phase and user activation can be directly done in Keycloak. The following section explains how that can be done: The admin user can create tenants using the token generated with client-credentials of the admin-api. When a tenant is created, Keycloak should send out an email to the tenant user id (email id of tenant). The email account should be configured to the Keycloak admin user.

* Click on the ‘Admin’ username at the top right corner, select “manage account” >> “Personal Info” and update the first name, the last name, and the email address in the admin user profile.
* Go back to the Sunbird-RC realm page. Navigate to the ‘Email’ tab in the “realm-settings” section.
* Update the email configuration with smtp address, host, email address and password (The app password should be used in the password field, which can be obtained after setting up your email to send emails via third-party applications).

<figure><img src="/files/myeEQuVr2JYLJGfnTP94" alt=""><figcaption></figcaption></figure>

* Test the connection to check if the email has been properly set up.

## Create Tenant

* Make a request to Keycloak with the client\_credentials to generate a JWT, which will further be used to create tenants.

<figure><img src="/files/DGYP5UXvV5WoMFjzqrvV" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/xuC51renkkNkpOsuY3Jm" alt=""><figcaption></figcaption></figure>

* Create a tenant using the token received in the above step, with the userId as the email Id of the tenant. This creates a tenant with the default password: abcd\@123.

<figure><img src="/files/M18YZ5LvGnxCHmWMxpxt" alt=""><figcaption></figcaption></figure>

* The tenant account can either be:

  \- Enabled/activated using the tenant portal (localhost) by setting up a new password and email confirmation,&#x20;
* (or)

  \- Navigate to the Keycloak UI users section in the Sunbird-RC realm and select the tenant user created. Toggle the “Email Verified” button to ‘ON’ and empty the “Required user actions” and save.

[![Creative Commons License](https://i.creativecommons.org/l/by/4.0/80x15.png)](http://creativecommons.org/licenses/by/4.0/)*All content on this page by* [*eGov Foundation*](https://egov.org.in/) *is licensed under a* [*Creative Commons Attribution 4.0 International License*](http://creativecommons.org/licenses/by/4.0/)*.*


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://divoc.digit.org/platform/divocs-verifiable-certificate-features-3.0/how-to-configure-a-new-tenant.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
