Restrict XUI Access with a Reverse Proxy

Use the public reverse proxy to expose the XUI sign-in flow for a policy-agent-protected application. These examples target OpenAM 16.1.4 with XUI enabled, the top-level realm, and a shared cookie domain for OpenAM and the application. They use /openam as the example deployment path. Substitute your deployment path throughout.

Configure the agent to send browser redirects to the public HTTPS URL and to reach OpenAM’s agent services over the private network. Keep the backend, administrative console, and internal endpoints such as /sessionservice, /policyservice, /namingservice, and /notifications off the public listener. Configure the OpenAM site and servlet container for the public URL, and add the application’s return URLs to Valid goto URL Resources. See Installation Considerations for Multiple Servers and Configuring Valid goto URL Resources.

The path rules cover the top-level realm’s XUI requests. OpenAM can resolve the effective authentication realm independently of the path matched by the proxy. If public authentication must be limited to the top-level realm, use a backend with only that realm available for authentication or enforce the effective realm with a separate control in front of a shared backend.

When an administrator signs in through the public listener, XUI can receive HTTP 403 on background requests for console data and display an incomplete page. Use the private administrative URL for console access.

Requests to Allow

The following paths are relative to the deployment path. A dash in the query column means the request does not need an _action selector.

Method Path Query Used for

GET

/UI/Login, /XUI, /XUI/, and XUI assets

—

The agent’s login redirect, XUI bootstrap, and static assets. In the 16.1.4 trace, /UI/Login redirects through /XUI before reaching /XUI/.

GET

/json/serverinfo/ or /json/realms/root/serverinfo/

—

Public server settings. The asterisk is a literal path segment.

POST

/json/realms/root/authenticate or /json/authenticate

Authentication parameters, as needed

Sign-in and authentication callbacks, including a password change prompted by the authentication chain.

POST

/json/users or /json/realms/root/users

_action=idFromSession

Session identification. The unqualified request can return 401 before login. The realm-qualified request identifies the user after login.

POST

/json/users

_action=validateGoto

Validation of the return URL.

POST

/json/sessions

_action=getSessionInfo or _action=logout

Session information and sign-out. XUI appends &tokenId=… when it can read the session token. With an HttpOnly session cookie, OpenAM obtains the token from the cookie.

GET

/UI/Logout (optional)

—

Allow when the policy agent redirects browsers to this logout URL. OpenAM redirects the browser to XUI, which then calls the session logout action. See Logout URL Properties.

GET

/json/realms/root/users/{id}

—

Read the signed-in user’s record before the redirect and display the self-service profile.

Keep the user record GET even for a sign-in-only deployment. In the OpenAM 16.1.4 browser trace, denying it returned the browser to XUI and ended the session after authentication had succeeded.

For self-service, enable PUT /json/realms/root/users/{id} to save profile attributes and POST /json/realms/root/users/{id}?_action=changePassword to change the password from the profile. Enable each operation as needed. The XUI route #profile/details is a browser fragment. The proxy controls the underlying HTTP requests.

The user record rule allows requests for any matching ID. Before exposing it, verify which records and attributes a regular user’s session can access. If the deployment requires access to one’s own record only, enforce that restriction in the backend or an identity-aware gateway and verify it with two test accounts.

These rules cover the standard sign-in and profile details flows. For sub-realms, CDSSO, extra profile tabs, or authentication modules with extra browser requests, capture the traffic for the selected feature and allow the specific requests it needs. For example, some CDSSO agents use /cdcservlet. See Configuring Cross-Domain Single Sign-On.

Before exposing the public listener, configure every access log that records these requests, including any upstream proxy or backend access logs, to record the method, path, and status without the query string. A session request can carry a live session token in the query.

Apache HTTP Server 2.4

Place these directives in a dedicated HTTPS virtual host for OpenAM. Load mod_rewrite, mod_proxy, and mod_proxy_http, and replace am-backend.internal:8080 with the private backend. Uncomment the optional rules for the flows you want to expose.

Keep the existing access log destinations for this virtual host and use the openam_xui format below. For a new log, replace /path/to/apache-log-directory with the absolute path to an existing Apache log directory. Check any additional logs, such as those configured with GlobalLog, for the same site. See Apache log formats.

LogFormat "%h %t \"%m %U\" %>s" openam_xui
CustomLog "/path/to/apache-log-directory/openam-xui-access.log" openam_xui

ProxyRequests Off
ProxyPreserveHost On
ProxyErrorOverride Off
ProxyPassReverse "/openam" "http://am-backend.internal:8080/openam"
RewriteEngine On

RewriteCond %{REQUEST_METHOD} =GET
RewriteRule "^(/openam/(?:UI/Login|XUI(?:/(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*/)*(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*)?)?|json/(?:realms/root/)?serverinfo/\*))$" "http://am-backend.internal:8080$1" [P,L]

# Optional logout URL for the policy agent
# RewriteCond %{REQUEST_METHOD} =GET
# RewriteRule "^(/openam/UI/Logout)$" "http://am-backend.internal:8080$1" [P,L]

RewriteCond %{REQUEST_METHOD} =POST
RewriteRule "^(/openam/json/(?:realms/root/)?authenticate)$" "http://am-backend.internal:8080$1" [P,L]

RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{QUERY_STRING} ^_action=idFromSession$
RewriteRule "^(/openam/json/(?:realms/root/)?users)$" "http://am-backend.internal:8080$1" [P,L]

RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{QUERY_STRING} ^_action=validateGoto$
RewriteRule "^(/openam/json/users)$" "http://am-backend.internal:8080$1" [P,L]

RewriteCond %{REQUEST_METHOD} =POST
RewriteCond %{QUERY_STRING} ^_action=(getSessionInfo|logout)(&tokenId=[^&;\s]+)?$
RewriteRule "^(/openam/json/sessions)$" "http://am-backend.internal:8080$1" [P,L]

RewriteCond %{REQUEST_METHOD} =GET
RewriteCond %{QUERY_STRING} ^$
RewriteRule "^(/openam/json/realms/root/users/[A-Za-z0-9_-][A-Za-z0-9_.@-]*)$" "http://am-backend.internal:8080$1" [P,L]

# Optional profile attribute updates
# RewriteCond %{REQUEST_METHOD} =PUT
# RewriteCond %{QUERY_STRING} ^$
# RewriteCond %{HTTP:If-None-Match} ^$
# RewriteRule "^(/openam/json/realms/root/users/[A-Za-z0-9_-][A-Za-z0-9_.@-]*)$" "http://am-backend.internal:8080$1" [P,L]

# Optional password changes from the profile
# RewriteCond %{REQUEST_METHOD} =POST
# RewriteCond %{QUERY_STRING} ^_action=changePassword$
# RewriteRule "^(/openam/json/realms/root/users/[A-Za-z0-9_-][A-Za-z0-9_.@-]*)$" "http://am-backend.internal:8080$1" [P,L]

RewriteRule "^" "-" [F]

IIS with URL Rewrite and Application Request Routing

Install URL Rewrite and Application Request Routing (ARR), enable ARR proxying, and configure it to preserve the public Host header. Place the following web.config at the root of a dedicated HTTPS site. Replace am-backend.internal:8080 with the private backend. Set enabled="true" for the optional rules you need. If you enable PUT, check that WebDAV and request filtering on this site allow ARR to forward the request. See Reverse Proxy with URL Rewrite and ARR.

In IIS Manager, open Logging for this site, select the W3C format, and choose Select Fields. Clear URI Query and keep Method, URI Stem, and HTTP Status. Apply the changes. See IIS site logging.

<configuration>
  <system.webServer>
    <httpErrors existingResponse="PassThrough" />
    <rewrite>
      <rules>
        <rule name="OpenAM XUI and public server settings" stopProcessing="true">
          <match url="^openam/(?:UI/Login|XUI(?:/(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*/)*(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*)?)?|json/(?:realms/root/)?serverinfo/\*)$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_METHOD}" pattern="^GET$" />
          </conditions>
          <action type="Rewrite" url="http://am-backend.internal:8080/{R:0}" appendQueryString="true" />
        </rule>
        <rule name="OpenAM policy agent logout URL" enabled="false" stopProcessing="true">
          <match url="^openam/UI/Logout$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_METHOD}" pattern="^GET$" />
          </conditions>
          <action type="Rewrite" url="http://am-backend.internal:8080/{R:0}" appendQueryString="true" />
        </rule>
        <rule name="OpenAM authentication" stopProcessing="true">
          <match url="^openam/json/(?:realms/root/)?authenticate$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_METHOD}" pattern="^POST$" />
          </conditions>
          <action type="Rewrite" url="http://am-backend.internal:8080/{R:0}" appendQueryString="true" />
        </rule>
        <rule name="OpenAM session identification" stopProcessing="true">
          <match url="^openam/json/(?:realms/root/)?users$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_METHOD}" pattern="^POST$" />
            <add input="{QUERY_STRING}" pattern="^_action=idFromSession$" ignoreCase="false" />
          </conditions>
          <action type="Rewrite" url="http://am-backend.internal:8080/{R:0}" appendQueryString="true" />
        </rule>
        <rule name="OpenAM return URL validation" stopProcessing="true">
          <match url="^openam/json/users$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_METHOD}" pattern="^POST$" />
            <add input="{QUERY_STRING}" pattern="^_action=validateGoto$" ignoreCase="false" />
          </conditions>
          <action type="Rewrite" url="http://am-backend.internal:8080/{R:0}" appendQueryString="true" />
        </rule>
        <rule name="OpenAM session information and sign-out" stopProcessing="true">
          <match url="^openam/json/sessions$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_METHOD}" pattern="^POST$" />
            <add input="{QUERY_STRING}" pattern="^_action=(getSessionInfo|logout)(&amp;tokenId=[^&amp;;\s]+)?$" ignoreCase="false" />
          </conditions>
          <action type="Rewrite" url="http://am-backend.internal:8080/{R:0}" appendQueryString="true" />
        </rule>
        <rule name="OpenAM read user profile" stopProcessing="true">
          <match url="^openam/json/realms/root/users/[A-Za-z0-9_-][A-Za-z0-9_.@-]*$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_METHOD}" pattern="^GET$" />
            <add input="{QUERY_STRING}" pattern="^$" />
          </conditions>
          <action type="Rewrite" url="http://am-backend.internal:8080/{R:0}" appendQueryString="true" />
        </rule>
        <rule name="OpenAM update user profile" enabled="false" stopProcessing="true">
          <match url="^openam/json/realms/root/users/[A-Za-z0-9_-][A-Za-z0-9_.@-]*$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_METHOD}" pattern="^PUT$" />
            <add input="{QUERY_STRING}" pattern="^$" />
            <add input="{HTTP_IF_NONE_MATCH}" pattern="^$" />
          </conditions>
          <action type="Rewrite" url="http://am-backend.internal:8080/{R:0}" appendQueryString="true" />
        </rule>
        <rule name="OpenAM change profile password" enabled="false" stopProcessing="true">
          <match url="^openam/json/realms/root/users/[A-Za-z0-9_-][A-Za-z0-9_.@-]*$" ignoreCase="false" />
          <conditions>
            <add input="{REQUEST_METHOD}" pattern="^POST$" />
            <add input="{QUERY_STRING}" pattern="^_action=changePassword$" ignoreCase="false" />
          </conditions>
          <action type="Rewrite" url="http://am-backend.internal:8080/{R:0}" appendQueryString="true" />
        </rule>
        <rule name="Deny other requests" stopProcessing="true">
          <match url=".*" />
          <action type="CustomResponse" statusCode="403" statusReason="Forbidden"
                  statusDescription="The request is outside the OpenAM allowlist." />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

NGINX

Place this example inside the http block. Set the public hostname, certificate and key paths, and private backend address for your deployment. Uncomment the optional rules for the flows you want to expose. The map directives check the method, normalized path, and query before location / proxies the request. Keep the trailing slash on proxy_pass so NGINX forwards the normalized path with the original query string. See NGINX map and NGINX proxy_pass.

map $args $openam_xui_query {
    default other;
    "" empty;
    "~^_action=idFromSession$" identify;
    "~^_action=validateGoto$" validate_goto;
    "~^_action=(getSessionInfo|logout)(&tokenId=[^&;\s]+)?$" session;
    "~^_action=changePassword$" change_password;
}

map $http_if_none_match $openam_xui_profile_update {
    default 0;
    "" 1;
}

map "$request_method:$openam_xui_query:$uri" $openam_xui_allowed {
    default 0;
    "~^GET:[^:]+:/openam/(?:UI/Login|XUI(?:/[A-Za-z0-9_-][A-Za-z0-9_.-]*)*/?|json/(?:realms/root/)?serverinfo/\*)\z" 1;
    "~^POST:[^:]+:/openam/json/(?:realms/root/)?authenticate\z" 1;
    "~^POST:identify:/openam/json/(?:realms/root/)?users\z" 1;
    "~^POST:validate_goto:/openam/json/users\z" 1;
    "~^POST:session:/openam/json/sessions\z" 1;
    "~^GET:empty:/openam/json/realms/root/users/[A-Za-z0-9_-][A-Za-z0-9_.@-]*\z" 1;

    # Optional logout URL for the policy agent
    # "~^GET:[^:]+:/openam/UI/Logout\z" 1;

    # Optional profile attribute updates
    # "~^PUT:empty:/openam/json/realms/root/users/[A-Za-z0-9_-][A-Za-z0-9_.@-]*\z" $openam_xui_profile_update;

    # Optional password changes from the profile
    # "~^POST:change_password:/openam/json/realms/root/users/[A-Za-z0-9_-][A-Za-z0-9_.@-]*\z" 1;
}

# Keep session tokens in query strings out of the access log.
log_format openam_xui '$remote_addr $request_method $uri $status';

server {
    listen 443 ssl;
    server_name am.example.test;
    ssl_certificate /etc/nginx/tls/fullchain.pem;
    ssl_certificate_key /etc/nginx/tls/privkey.pem;
    access_log /var/log/nginx/openam-access.log openam_xui;

    location / {
        if ($openam_xui_allowed = 0) {
            return 403;
        }

        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_intercept_errors off;
        proxy_cache off;
        proxy_pass http://am-backend.internal:8080/;
    }
}

Verify Your Deployment

The examples accept simple ASCII asset paths and single-segment user IDs. If your deployment has different IDs or customized assets, adjust the corresponding path pattern for the characters you need. Keep the method, path, and _action checks and the final deny rule. Check parent and global proxy rules for any routes that would forward requests before this allowlist runs.

  1. Open the protected application with a fresh browser session and preserve the network log in developer tools. Check that XUI loads, authentication sets the session cookie, the user record request succeeds, and the protected application accepts the session after the redirect.

  2. Try an incorrect password and an account whose authentication chain prompts for a password change. Verify that XUI shows the expected failure or completes the callbacks through /json/realms/root/authenticate.

  3. Sign out from XUI and confirm that opening the protected application requires a new login. If the policy agent uses /UI/Logout, repeat the check by signing out from the protected application. If the agent specifies a post-logout URL, also verify that the browser reaches it. OpenAM 16.1.4 can end the session without following a goto URL supplied in the /UI/Logout query string.

  4. If you enable self-service operations, change an allowed profile attribute and the password of a test account. Sign in again with the new password.

  5. Make a request to /XUI/ with a harmless query marker such as ?proxyLogCheck=example. Confirm that the access logs recording this request show the method, path, and status without the marker.

  6. Check the proxy and backend logs. Public requests for the administrative console, agent services, user collection queries, and unlisted _action values should be rejected at the proxy. Use two regular test accounts to verify that reads and optional writes respect the deployment’s profile access policy.

Repeat these checks after changing the OpenAM version, realm, authentication chain, agent, or proxy configuration.