Introduction
HTTP Header Variable Authentication in Oracle APEX is used when user
credentials are passed through HTTP headers, typically by an external system
such as a reverse proxy, single sign-on service, or identity provider. In this
setup, the authentication is handled outside of APEX, and the application
receives a trusted HTTP header containing the authenticated username. This
method is useful in enterprise environments where centralized identity
management is required and helps streamline secure access across multiple
systems.
HTTP Header Variable Authentication in Oracle APEX allows your application to trust a user identity passed through an HTTP header. This method is typically used when authentication is handled externally—such as by a reverse proxy, identity provider, or load balancer—which validates the user and then passes the authenticated username to APEX through a secure HTTP header. APEX uses this value to establish a session without prompting the user for login credentials again. This setup is often used in enterprise environments that use Single Sign-On (SSO) or centralized authentication systems.
To configure HTTP Header Variable Authentication in Oracle APEX, start by going to Shared Components > Authentication Schemes. Click Create, then select Based on a Preconfigured Scheme from Gallery. Choose HTTP Header Variable and proceed through the wizard. Give your scheme a name like "SSO Header Auth" and click Next.
In the scheme settings, locate the field labeled Header Variable Name. This is where you enter the name of the HTTP header that your external system will pass to APEX. For example, if your reverse proxy is configured to pass the username in a header called X-USERNAME, then enter X-USERNAME here.
Set the Username Transformation if needed. For example, you may want to convert the value to uppercase using UPPER(:USERNAME) so that it matches user records or works consistently across your application.
If the HTTP header is present and contains a valid value, APEX will automatically log the user in using that value. The assumption is that the header is trusted and cannot be modified by the user, which is why this method should always be used in combination with a secure, validated proxy or gateway. Never expose this type of authentication on a public-facing application without proper safeguards.
You can optionally create a Post-Authentication Procedure. This PL/SQL procedure runs after the user is identified from the header. It is commonly used to load user roles, set application-level preferences, or perform logging. For example:
BEGIN
apex_util.set_session_state('CURRENT_ROLE', get_user_role(:APP_USER));
END;
To test the authentication, you must access the APEX application through the proxy or system that sets the header. APEX does not allow you to simulate HTTP headers through a browser URL or developer tools, as this would compromise the security model. Your external system must be configured to insert the correct header after successful authentication and to strip or block any unauthorized headers coming from the client.
You can still define Authorization Schemes in APEX to control access to pages or regions based on the value of :APP_USER or any session state variable initialized after login.
HTTP Header Variable Authentication is a powerful option when you need to delegate authentication to an external provider but still maintain control of user access and session behavior within Oracle APEX. It offers seamless user experience, central security control, and reduced password management inside your application, all while allowing the flexibility to tailor session setup through post-login PL/SQL logic.
Authenticate users externally by using an HTTP header variable set by the web server.
Overview:
The HTTP Header Variable authentication method allows Oracle APEX to
identify users based on a value stored in an HTTP header variable. This method
is useful when integrating with centralized web authentication solutions such
as Oracle Access Manager, which provides Single Sign-On (SSO).
These external authentication systems validate user credentials and pass the
authenticated username to APEX using an HTTP header variable (e.g.,
"REMOTE_USER", which is the default).
Setting Up HTTP Header Variable Authentication
To configure HTTP Header Variable authentication:
Access the Authentication Schemes Page:
- Open App Builder from the Workspace home page.
- Select an application.
- On the Application home page, go to Shared Components.
- Under Security, select Authentication Schemes.
- Create a New Authentication Scheme:
- Click Create.
- Select Based on a pre-configured scheme from the gallery and click Next.
- Configure Basic Authentication Settings:
- Name: Enter a reference name for the authentication scheme.
- Scheme Type: Select HTTP Header Variable.
- Specify HTTP Header Variable Settings:
- HTTP Header Variable Name:
- Enter the name of the HTTP header variable containing the username.
- If left blank, REMOTE_USER will be used as the default.
- Action if Username is Empty:
- Choose the action when the HTTP header variable is empty:
- Redirect to Built-In URL: Redirects to /apex/apex_authentication.callback, forcing authentication via the web server.
- Redirect to URL: Redirects to an external login page, which must then pass back the validated username.
- Display Error: Shows an error message without attempting a login.
- Verify Username:
- Defines how often APEX should verify the username in the HTTP header:
- Each Request (most secure): Ensures the session username matches the header value on every request. If different, the session is invalidated.
- After Login: Only verifies the username once, after the initial login callback.
- Logout URL of SSO Server:
- (Optional) If using Oracle Access Manager or a similar SSO solution, enter the Single Sign-Out (SSO) logout URL.
- Example for Oracle Access Manager:
/oamsso/logout.html?end_url=%POST_LOGOUT_URL%%POST_LOGOUT_URL% will be replaced with an encoded URL for the APEX login page.
4. Save the Authentication Scheme:
- Click Create Authentication Scheme.
This setup enables secure external authentication using an HTTP header variable, ensuring seamless integration with enterprise SSO solutions like Oracle Access Manager.
Conclusion
Implementing HTTP Header Variable Authentication in Oracle APEX allows seamless
integration with external authentication systems while maintaining strict
access control within the application. By trusting validated headers passed by
a secure intermediary, developers can reduce the need for repeated logins and
ensure consistency across multiple applications. This approach is ideal for organizations
looking to centralize authentication while keeping the APEX application
lightweight and secure.