> For the complete documentation index, see [llms.txt](https://rc.sunbird.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rc.sunbird.org/use/developer-guide/generic-iam.md).

# Generic IAM

SunbirdRC was originally tightly coupled to Keycloak. It now supports any OAuth2-compliant identity layer for both purposes an IAM platform serves here: authN/authZ between user and entity, and managing the user accounts created for entities.

## Configure the registry core

```bash
oauth2_resource_uri=https://domain/auth/
oauth2_resource_email_path=email
oauth2_resource_consent_path=consent
oauth2_resource_roles_path=realm_access.roles
oauth2_resource_entity_path=entity
```

| Platform   | `oauth2_resource_uri`                            |
| ---------- | ------------------------------------------------ |
| Keycloak   | `https://keycloak-domain/auth/realms/sunbird-rc` |
| Auth0      | `https://xxxx.us.auth0.com/` (API domain)        |
| FusionAuth | The tenant's configured issuer URL               |

## Enabling user-account creation on a new IAM platform

SunbirdRC ships **three** submodules under [`java/middleware/registry-middleware`](https://github.com/Sunbird-RC/sunbird-rc-core/tree/main/java/middleware/registry-middleware):

| Submodule      | Keycloak                                           | auth0                                       | generic-iam                                       |
| -------------- | -------------------------------------------------- | ------------------------------------------- | ------------------------------------------------- |
| Path           | `java/middleware/registry-middleware/keycloak`     | `java/middleware/registry-middleware/auth0` | `java/middleware/registry-middleware/generic-iam` |
| Provider class | `dev.sunbirdrc.auth.keycloak.KeycloakProviderImpl` | —                                           | `dev.sunbirdrc.auth.genericiam.AuthProviderImpl`  |

To support a different platform, take one of two paths.

{% tabs %}
{% tab title="Build a submodule" %}
{% stepper %}
{% step %}

#### Create the submodule

Under `java/middleware/registry-middleware`.
{% endstep %}

{% step %}

#### Implement IdentityProvider

Implement the [`IdentityProvider`](https://github.com/Sunbird-RC/sunbird-rc-core/blob/generic-auth/java/middleware/registry-middleware/identity-provider/src/main/java/dev/sunbirdrc/registry/identity_providers/providers/IdentityProvider.java) interface (returns an `IdentityManager`); see the [Keycloak implementation](https://github.com/Sunbird-RC/sunbird-rc-core/blob/generic-auth/java/middleware/registry-middleware/keycloak/src/main/java/dev/sunbirdrc/auth/keycloak/KeycloakProviderImpl.java) as an example.
{% endstep %}

{% step %}

#### Implement IdentityManager

[`IdentityManager`](https://github.com/Sunbird-RC/sunbird-rc-core/blob/generic-auth/java/middleware/registry-middleware/identity-provider/src/main/java/dev/sunbirdrc/registry/identity_providers/pojos/IdentityManager.java) handles user creation and returns the user id.
{% endstep %}

{% step %}

#### Register as a Service Provider

Under `META-INF/services` — file name is the fully-qualified SPI name, contents are the fully-qualified implementation name.
{% endstep %}

{% step %}

#### Point the registry at it

Set `identity_provider` to your new implementation's package name.
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Build an external wrapper" %}
Skip the submodule and build an external wrapper service exposing an API to create users in your IAM platform, following [this API spec](https://github.com/Sunbird-RC/sunbird-rc-core/blob/6a99ab9d564ef0518ff5fa8f6730a58e51808f6d/services/sample-fusionauth-service/api-spec.yml). A [sample FusionAuth implementation](https://github.com/Sunbird-RC/sunbird-rc-core/tree/6a99ab9d564ef0518ff5fa8f6730a58e51808f6d/services/sample-fusionauth-service) is provided.

{% hint style="info" %}
Both links are pinned to a historical commit — the `services/` directory has since evolved, but the commit links still resolve.
{% endhint %}

Then set:

```bash
identity_provider=dev.sunbirdrc.auth.genericiam.AuthProviderImpl
sunbird_sso_url=http://localhost:8080/auth/   # replace with your service endpoint
```

{% endtab %}
{% endtabs %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://rc.sunbird.org/use/developer-guide/generic-iam.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
