> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gradial.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Install the Gradial OBO package on AEM

> Install the Gradial OBO bundle (gradial.obo 1.3.0) on AEM 6.5, LTS or AEM as a Cloud Service, add its OSGi configuration, and get the values Gradial needs for per-user sign-in.

## Overview

Per-user sign-in (**Connect AEM**) needs one extra bundle on the AEM Author, `gradial.obo`. It adds three endpoints under `/bin/gradial/obo/` and lets AEM accept a short-lived Gradial token as the person who connected. AEM then applies that person's own permissions and records them as the user who made the change.

This page is the AEM side. For the Gradial side, see [Per-user AEM sign-in](https://docs.gradial.com/docs/integrations-administration-and-setup/integrations/aem/aem-gradial-setup.md#per-user-aem-sign-in-connect-aem).

**Access:** Must be enabled for your organization. Contact your Gradial team to get access.

| | Supported |
| :- | :- |
| AEM 6.5 | Service Pack 8 or later. On an older AEM the bundle can stay in the **Installed** state and do nothing. |
| AEM 6.5 LTS | Supported |
| AEM as a Cloud Service | Deployed through a Cloud Manager pipeline. Cloud Service is not verified end to end: only the deployment, the service user and the endpoint responses have been checked on Cloud. See [AEM as a Cloud Service](#aem-as-a-cloud-service). |
| Java | 11, 17 or 21. The bundle is Java 8 bytecode, but Java 8 is not tested. |
| Run mode | Author only. Nothing installs on Publish. |

The bundle does not replace the Granite OAuth scopes in [AEM 6.5 / LTS setup](https://docs.gradial.com/docs/integrations-administration-and-setup/integrations/aem/aem-on-prem.md), and your existing connection keeps working.

## How it ships

The release is [gradial-65-oauth 1.3.0](https://github.com/gradial/gradial-65-oauth/releases/tag/1.3.0). It is also on Maven Central under the group `io.github.gradial`.

| | AEM 6.5 and LTS | AEM as a Cloud Service |
| :- | :- | :- |
| What you install | `gradial.all-1.3.0.zip` from the GitHub release, in Package Manager | `io.github.gradial:gradial.obo:1.3.0` from Maven Central, embedded in your own project |
| Configurations you add | One: the [OboService configuration](#oboservice-configuration) | Three: two foundation configurations and the [OboService configuration](#oboservice-configuration) |
| Deployed by | Package Manager for the package. Your normal deployment for the configuration | Your Cloud Manager pipeline |

Delegation does nothing until the `OboService` configuration exists with `"enabled": true`.

## AEM 6.5 and LTS

**1. Install the package**

Download [`gradial.all-1.3.0.zip`](https://github.com/gradial/gradial-65-oauth/releases/download/1.3.0/gradial.all-1.3.0.zip) from the release and install it in **Package Manager** at `/crx/packmgr` on the Author. It is the same package as in [AEM 6.5 / LTS setup](https://docs.gradial.com/docs/integrations-administration-and-setup/integrations/aem/aem-on-prem.md), so if you already installed 1.3.0 there, skip this step.

The package contains `gradial.core` (the Granite OAuth scopes), `gradial.obo` (installed to `/apps/gradial-packages/obo/install.author`, so Author only) and `gradial.ui.config`. `gradial.ui.config` ships the foundation configurations for per-user sign-in: the service user mapping, the repository initializer and the audit log.

On every Author, the install creates the system users `gradial-obo-state` and `gradial-oauth-scope-reader`, their access control entries, and `/var/gradial/obo`, even while delegation stays off.

**2. Add the OboService configuration**

Add `com.gradial.core.oauth.obo.OboService.cfg.json` to your own project's `config.author` folder, for example `/apps/<project>/osgiconfig/config.author/`, and deploy it the way you deploy your other configurations. Never put it under `/apps/gradial`, and don't edit the files in `/apps/gradial/osgiconfig` by hand. See [OboService configuration](#oboservice-configuration) for the file.

> [!WARNING]
>
> Don't add your own copy of the foundation configurations as well. The package already ships them. If two packages ship a file with the same name, the Sling installer applies only one of them, and it may be the older one.

> [!NOTE]
>
> If you deploy with Maven, the release notes give the same package as `io.github.gradial:gradial.all:1.3.0:zip`, embedded at `/apps/vendor-packages/gradial/install`.

Upgrading from 1.2.0 is safe and removes nothing under `/apps/gradial`. Do not roll back to 1.2.0 on an Author that has other content under `/apps/gradial`: the 1.2.0 package filters can delete it.

## AEM as a Cloud Service

On AEM as a Cloud Service you don't install `gradial.all`. Package Manager on Cloud can't deploy Java bundles, so the bundle (`io.github.gradial:gradial.obo:1.3.0` on Maven Central) and its configurations go in your own project and deploy through Cloud Manager.

> [!WARNING]
>
> Per-user sign-in refuses anyone whose effective AEM user, groups or principals include administrator membership, unless `allowAdministrators` is `true`. On AEM as a Cloud Service, check each person's membership in AEM: an AEM Users product-profile assignment alone does not show they have none. Test with an account that is not an administrator.

**1. Add the bundle to your project**

In the `pom.xml` of your `all` container package, add the dependency:

```xml theme={null}
<dependency>
  <groupId>io.github.gradial</groupId>
  <artifactId>gradial.obo</artifactId>
  <version>1.3.0</version>
</dependency>
```

In the same file, embed it in the `filevault-package-maven-plugin` configuration, in the Author-only install folder:

```xml theme={null}
<plugin>
  <groupId>org.apache.jackrabbit</groupId>
  <artifactId>filevault-package-maven-plugin</artifactId>
  <extensions>true</extensions>
  <configuration>
    <embeddeds>
      <embedded>
        <groupId>io.github.gradial</groupId>
        <artifactId>gradial.obo</artifactId>
        <target>/apps/<project>-packages/application/install.author</target>
      </embedded>
    </embeddeds>
  </configuration>
</plugin>
```

Replace `<project>` with the name your project already uses in its other `<embedded>` targets. The `install.author` folder keeps the bundle off Publish.

**2. Add the two foundation configurations**

In your `ui.config` module, add these files to `/apps/<project>/osgiconfig/config.author/`.

`org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~gradial-obo.cfg.json` maps the bundle to its service user:

```json theme={null}
{
  "user.mapping": ["gradial.obo:obo=[gradial-obo-state]"]
}
```

`com.gradial.core.oauth.obo.OboRepositoryInitializer.cfg.json` turns on the bundle's repository initializer, which creates the service user and its folders when AEM starts. The file is empty on purpose:

```json theme={null}
{}
```

**3. Add the OboService configuration**

Add `com.gradial.core.oauth.obo.OboService.cfg.json` with Cloud Manager variables in place of the values that change per environment:

```json theme={null}
{
  "enabled": "$[env:GRADIAL_OBO_ENABLED;type=Boolean;default=false]",
  "clientId": "gradial",
  "clientSecretSha256": "$[secret:GRADIAL_OBO_CLIENT_SECRET_SHA256;default=]",
  "redirectUris": [
    "https://app.gradial.com/api/integrations/aem-obo/callback"
  ],
  "publicOrigin": "https://author-p<program>-e<environment>.adobeaemcloud.com",
  "accessTokenSeconds": 300,
  "grantSeconds": 2592000
}
```

`publicOrigin` differs for each environment. Put one copy of the file in each run mode folder, for example `config.author.dev`, `config.author.stage` and `config.author.prod`, each with that environment's Author origin. See [OboService configuration](#oboservice-configuration) for each field.

**4. Set the Cloud Manager variables**

In Cloud Manager, add these environment variables to each environment, applied to the Author service:

| Name | Store as a secret | Value |
| :- | :- | :- |
| `GRADIAL_OBO_ENABLED` | No | `true` |
| `GRADIAL_OBO_CLIENT_SECRET_SHA256` | Yes | The SHA-256 of your client secret. See [Create the client secret](#create-the-client-secret). |

The variable names are examples. Use any names, as long as they match the configuration. While `GRADIAL_OBO_ENABLED` is not set, delegation stays off.

**5. Deploy**

Commit the changes and run your Cloud Manager pipeline. The bundle and the configurations reach the Author only.

## OboService configuration

`com.gradial.core.oauth.obo.OboService.cfg.json` turns the feature on. The component stays inactive until this file exists, and nothing is delegated until `enabled` is `true`. It belongs in your own project's `config.author`, never under `/apps/gradial`.

```json theme={null}
{
  "enabled": true,
  "clientId": "gradial",
  "clientSecretSha256": "<64 lowercase hex characters>",
  "redirectUris": [
    "https://app.gradial.com/api/integrations/aem-obo/callback"
  ],
  "publicOrigin": "https://author.example.com",
  "accessTokenSeconds": 300,
  "grantSeconds": 2592000
}
```

| Property | Meaning |
| :- | :- |
| `enabled` | Main switch. Default `false`. |
| `clientId` | The OBO client ID you give to Gradial. |
| `clientSecretSha256` | The SHA-256 of the client secret, as 64 lowercase hex characters. AEM stores only the hash. |
| `redirectUris` | The exact callback URLs Gradial may use. See [Callback URLs](#callback-urls). |
| `publicOrigin` | The Author origin people open in their browser: scheme and host only, no path and no trailing slash. HTTPS is required, except for `localhost`, `127.0.0.1` and `[::1]` during development. |
| `accessTokenSeconds` | Access token lifetime. Default `300`, allowed `30` to `3600`. |
| `grantSeconds` | Absolute lifetime of a grant. Default `2592000` (30 days), the maximum. It must be at least `accessTokenSeconds`, or the service fails to activate. |
| `allowAdministrators` | Optional. Lets `admin` and members of `administrators` connect. Default `false`. |

Leave `allowAdministrators` off. Delegation hands the connected person's AEM permissions to Gradial, and for an administrator that bypasses every ACL. With it off, administrators can't connect, and a grant held by someone who later becomes an administrator stops working on the next request.

### Callback URLs

Callbacks must match exactly, and anything other than `localhost`, `127.0.0.1` and `[::1]` must use HTTPS.

* Gradial production: `https://app.gradial.com/api/integrations/aem-obo/callback`
* A dedicated Gradial host: `https://<host>/api/integrations/aem-obo/callback`

The **Per-user AEM sign-in** form in Gradial shows the callback URL to allow.

### Create the client secret

Generate the secret from at least 32 random bytes. Keep the plain value for Gradial, and put only its hash in the configuration (on Cloud, in the Cloud Manager secret). Never use a person's password.

```bash theme={null}
SECRET=$(openssl rand -base64 32)
printf '%s' "$SECRET" | shasum -a 256
```

The 64 hex characters at the start of the output are the value for `clientSecretSha256`. Store the plain `$SECRET` in your own secrets manager.

### Enter the values in Gradial

In Gradial, open the AEM integration's **General** settings. Under **Per-user AEM sign-in**, enter:

* **AEM sign-in origin**: the same Author origin as `publicOrigin`.
* **OBO client ID**: the `clientId`.
* **OBO client secret**: the plain secret, not the hash.

Then select **Enable per-user sign-in**. See [Per-user AEM sign-in](https://docs.gradial.com/docs/integrations-administration-and-setup/integrations/aem/aem-gradial-setup.md#per-user-aem-sign-in-connect-aem).

### What ends existing grants

* Changing `clientId` or the client secret ends every grant. Use this as a kill switch.
* Lowering `grantSeconds` shortens live grants. Raising it never extends one.
* Changing `redirectUris`, `publicOrigin` or `accessTokenSeconds` does not end grants.

### Audit log

The bundle writes events such as `grant_issued`, `grant_revoked` and `consent_refused` to the logger `com.gradial.core.oauth.obo.audit`. On AEM 6.5 and LTS, the package already sends them to `logs/gradial-obo-audit.log`.

## Users and permissions

You do not grant `jcr:impersonate` to anyone and you do not create a mapping per person. The bundle's login module validates each Gradial token and resolves the person's own user and groups. What the person can do is exactly what their ACLs allow in AEM.

* A person who is impersonating another user (a Sling sudo session) cannot connect.
* The `admin` user and anyone with effective administrator membership are refused unless `allowAdministrators` is `true`.
* A delegated token is refused with HTTP 403 on `/bin/gradial/obo`, `/oauth`, `/libs/granite/oauth`, `/crx/packmgr`, `/crx/de`, `/crx/server`, `/libs/granite/security` (except `currentuser`, `whoami` and `userinfo`) and `/system/console`.
* Each person can hold at most ten active grants.

The repository initializer creates the system user `gradial-obo-state` under `/home/users/system/gradial`. It stores grants under `/var/gradial/obo/grants` and `/var/gradial/obo/consents`. It gives that user `jcr:read,rep:write` on `/var/gradial/obo` and read access to user and group nodes under `/home/users` and `/home/groups`, with `rep:password` denied. It has no content-write permission. `everyone` is denied read and write on `/var/gradial/obo`, and `administrators` keep access so they can inspect or delete grants.

> [!WARNING]
>
> If a regular user or group named `gradial-obo-state` already exists, the initializer changes nothing, logs one error, and per-user sign-in stays unavailable. Rename or remove that account first.

## Network, dispatcher and proxies

The bundle exposes these Author endpoints.

| Path | Purpose |
| :- | :- |
| `/bin/gradial/obo/authorize` | Sign-in and consent page. Requires an AEM login. |
| `/bin/gradial/obo/token` | Gradial exchanges the sign-in code for a token. Form-encoded POST. |
| `/bin/gradial/obo/revoke` | Gradial ends a grant when someone disconnects. Form-encoded POST. |

Allow all three through any proxy or dispatcher in front of the Author. Delegated requests carry the header `Authorization: GradialOBO <token>`, so do not strip it. Keep AEM's CSRF protection on for the authorize page. If the Author blocks traffic by address, allowlist [Gradial's egress IPs](https://docs.gradial.com/docs/integrations-administration-and-setup/ip-allowlist.md).

## Verify

> [tab] AEM 6.5 and LTS
>
> 1. Open `/system/console/bundles` on the Author and search for `gradial.obo`. The bundle must be **Active**. **Installed** usually means the AEM is older than 6.5 SP8, or a dependency did not resolve. Check the bundle's details in the console.
> 2. Open `/system/console/components` and confirm `com.gradial.core.oauth.obo.OboService` is **active**. If it is unsatisfied, the `OboService` configuration is missing.
> 3. Check that a system user with the ID `gradial-obo-state` exists under `/home/users/system/gradial`. AEM may give its node a generated name.

> [tab] AEM as a Cloud Service
>
> 1. Sign in to the Author and open `https://<author>/bin/gradial/obo/authorize`. If the bundle is running and enabled, it answers `client_id is not the one configured on this AEM`, because the request has no client ID. `temporarily_unavailable` can mean `enabled` is not `true` (usually the Cloud Manager variable isn't set) or that AEM could not reach its repository.
> 2. Check that a system user with the ID `gradial-obo-state` exists under `/home/users/system/gradial`. AEM gives its node a generated name.

Then enter the values in Gradial and select **Connect AEM**. See [Per-user AEM sign-in](https://docs.gradial.com/docs/integrations-administration-and-setup/integrations/aem/aem-gradial-setup.md#per-user-aem-sign-in-connect-aem).

## Troubleshooting

| What you see | What to check |
| :- | :- |
| The sign-in window shows `client_id is not the one configured on this AEM` | **OBO client ID** in Gradial does not match `clientId`. |
| The sign-in window shows `redirect_uri is not registered` | The callback URL is missing from `redirectUris`, or differs by a character. |
| `temporarily_unavailable` | `enabled` is `false`, the configuration was not deployed, or AEM could not reach its repository. On Cloud, check the Cloud Manager variable. |
| `access_denied` after sign-in | The person is an administrator and `allowAdministrators` is `false`, or they are using Sling sudo. |
| Everyone has to reconnect | `clientId` or the client secret changed, or the grant reached `grantSeconds`. |

## Remove it

Always remove the `OboService` configuration first. Every grant stops working at once.

* **AEM 6.5 and LTS:** that is enough to turn per-user sign-in off. Keep `gradial.all` installed while any classic integration still uses its Granite scopes. Uninstall it only if nothing else needs it, and know that an uninstall can remove or revert the deployed scope files.
* **AEM as a Cloud Service:** then remove the dependency, the `<embedded>` entry and the two foundation configurations from your project, and deploy.

The service user and the folders under `/var/gradial/obo` stay in the repository and do nothing. An administrator can delete them by hand.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.