Add support for pre-authorization via HTTP header (to be used with pre-authentication)
Description
Acceptance / Success Criteria
Role(s) correctly passed through from the header named in the
credentialsHeader
property for users that do not exist inusers.xml
Docs updated to reflect that
credentialsHeader
must have a value configured – probably should add a default one in both the docs and the shipping config file.Docs specify how to pass multiple roles in the
credentialsHeader
header – does comma-separated work?
Lucidchart Diagrams
Activity

Alex May April 21, 2023 at 3:54 PM
Any thoughts on the comment above? Default behavior and what kind of pre-auth we support seems like more of a product question.

Alex May April 5, 2023 at 4:38 PM
While looking into I ran into a few discrepancies with how pre-authentication is implemented and configured versus how it is described here.
Roles aren’t configured via the
credentialsHeader
, it all seems to be done through theauthenticationHeader
. I can’t seem to find any use for thecredentialsHeader
beyond it needing to be set to something if it is configured.The default configuration only allows for authentication against users in
users.xml
, and existing roles cannot be overridden with eitherauthenticationHeader
orcredentialsHeader
.With the configuration given in the documentation, all roles need to be specified in the
authenticationHeader
.userHeader
is never compared againstusers.xml
.
In the linked issue, Chris suggested changing the default config to match what is given in the documentation. I’m fine with doing that, but then we’d kind of ‘lose’ the ability to authenticate against existing users unless we put the current default somewhere in the docs. I don’t know if this would be a problem.
A few questions:
Is the behavior I’m seeing intended?
Does
credentialsHeader
have any use? I can’t figure out what Spring expects this method to return, or how it is used.Should the default configuration be changed to what’s in the documentation?

Alberto June 8, 2022 at 2:49 PM
merged to foundation-2020

Alberto June 6, 2022 at 12:31 PMEdited
Backporting to foundation-2020 PR: https://github.com/OpenNMS/opennms/pull/4826

Jeff Gehlbach June 2, 2022 at 8:01 PM
Reopening since we've had a support customer inquire about back-porting this work to Meridian.
I'm naming Meridian 2022, but if it's just as easy to go back to 2020, we should do that.
Details
Assignee
AlbertoAlbertoReporter
Jeff GehlbachJeff GehlbachDocs Needed
YesStory Points
2Components
Sprint
NoneAffects versions
Priority
Minor
Details
Details
Assignee

Reporter

Docs Needed
Story Points
Components
Sprint
Affects versions
Priority
PagerDuty
PagerDuty Incident
PagerDuty
PagerDuty Incident
PagerDuty

Background
When the OpenNMS web UI is set up behind a reverse proxy such as Apache HTTPD or NGINX, the authentication and authorization of users can be farmed out to some AAA module. In these scenarios, the OpenNMS webapp trusts the username and role(s) conveyed in a pair of custom HTTP headers. Docs exist for configuring this functionality, but they are pretty bare-bones.
Problem
The header configured for
userHeader
is honored, but the header configured forcredentialsHeader
is ignored.The docs do not mention that, if the user enables this feature, a value must be provided for
credentialsHeader
.Steps to Reproduce
Start with a fresh install
Edit
$OPENNMS_HOME/jetty-webapps/opennms/WEB-INF/spring-security.d/header-preauth.xml
as follows:Change the value of the
enabled
property totrue
Set the value of the
credentialsHeader
property toX-Remote-Roles
Restart OpenNMS
Run
curl -H 'X-Remote-User: admin' -H 'X-Remote-Roles: ROLE_ADMIN' http://127.0.0.1:8980/opennms/rest/info
and see that theinfo
endpoint's output appears – pre-authentication workedRun
curl -H 'X-Remote-User: ulf' -H 'X-Remote-Roles: ROLE_ADMIN' http://127.0.0.1:8980/opennms/rest/info
Expected Result
Output of the
info
endpoint appears as it did for theadmin
userActual Result
Request is rejected with code
401 Full authentication is required
Further Notes
The
admin
user works just fine because theROLE_ADMIN
assignment for that built-in user is coming fromusers.xml
.Jesse thought the filter code might be returning a principal rather than a role assignment. I might be off the mark in recollecting his exact words here, my Spring Security knowledge is lacking.