> For the complete documentation index, see [llms.txt](https://docs.sunbirdrc.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sunbirdrc.dev/use/developers-guide/custom-keycloak-build.md).

# Custom Keycloak Build

SunbirdRC uses a custom keycloak image which is configured to enable/disable NONCE validation. The required changes are made in this repository, <https://github.com/Sunbird-RC/keycloak/tree/configurable-nonce-validation>.

NONCE validation is default enabled in keycloak, to turn off the validation `VALIDATE_NONCE` should be set to `"false".`

This configuration is not provided by keycloak by default even in the latest version. We have configured this change, particularly for enabling Digilocker Meripehchaan SSO (Task: <https://github.com/Sunbird-RC/community/issues/593>).

### Build custom keycloak image

#### Pre-requisites

* JAVA 11 (tested with 11.0.8)
* Maven

#### Build keycloak distribution jar

* Clone <https://github.com/Sunbird-RC/keycloak/tree/configurable-nonce-validation> the repository (Contains the source code)
* Run the below command to generate the distribution jar. Reference <https://github.com/Sunbird-RC/keycloak/blob/configurable-nonce-validation/docs/building.md> `mvn clean install -Pdistribution`
* The above command should create `keycloak-14.0.0.tar.gz` in `distribution/server-dist/target` directory

#### Build keycloak docker image

* Clone <https://github.com/keycloak/keycloak-containers/tree/main/> the repository (Contains the build files)
* `git checkout 14.0.0`
* `cd server`
* Run a Python HTTP server in the [keycloak repo](#build-keycloak-distribution-jar) to access the distributed jar file.\
  `python -m http.server 8001`
* Build the keycloak docker image,\
  `docker build -t sunbirdrc/keycloak --build-arg KEYCLOAK_DIST=http://<YOUR_IP_ADDRESS>:8001/keycloak-14.0.0.tar.gz .`
* Tag the new docker image and publish it to dockerhub / docker registry


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.sunbirdrc.dev/use/developers-guide/custom-keycloak-build.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
