-
Notifications
You must be signed in to change notification settings - Fork 792
add decoder for HTTP Basic auth #2875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Tested by adding this to <security-constraint>
<web-resource-collection>
<web-resource-name>API endpoints are checked separately by the web app</web-resource-name>
<url-pattern>/api/*</url-pattern>
</web-resource-collection>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>In general everything needs to be authenticated</web-resource-name>
<url-pattern>/*</url-pattern> <!-- protect the whole application -->
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-role>
<role-name>*</role-name>
</security-role>
<login-config>
<auth-method>BASIC</auth-method>
</login-config>and creating <?xml version='1.0' encoding='utf-8'?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
version="1.0">
<user username="foo" password="bar" roles="tomcat,manager-script"/>
</tomcat-users>and adding this to read-only configuration: <void property="pluginStack">
<void property="stack">
<!-- get user cred from HTTP headers -->
<void method="add">
<object class="org.opengrok.indexer.authorization.AuthorizationPlugin">
<void property="name">
<string>opengrok.auth.plugin.UserPlugin</string>
</void>
<void property="flag">
<string>REQUISITE</string>
</void>
<void property="setup">
<void method="put">
<string>decoder</string>
<string>opengrok.auth.plugin.decoders.HttpBasicAuthHeaderDecoder</string>
</void>
</void>
</object>
</void>
</void>
</void>Running the indexer with: works fine. |
|
To make sure this covers <void property="pluginStack">
<void property="stack">
<!-- get user cred from HTTP headers -->
<void method="add">
<object class="org.opengrok.indexer.authorization.AuthorizationPlugin">
<void property="forGroups">
<void method="add">
<string>Solaris</string>
</void>
</void>
<void property="forProjects">
<void method="add">
<string>solaris-userland</string>
</void>
</void>
<void property="name">
<string>opengrok.auth.plugin.UserPlugin</string>
</void>
<void property="flag">
<string>REQUISITE</string>
</void>
<void property="setup">
<void method="put">
<string>decoder</string>
<string>opengrok.auth.plugin.decoders.HttpBasicAuthHeaderDecoder</string>
</void>
</void>
</object>
</void>
</void>
</void> and did a non-localhost request ( Also, to add some detail about the testing, the read-only configuration had this: <void property="pluginDirectory">
<string>/var/opengrok/share/auth/plugins</string>
<!-- <string>/usr/opengrok/share/plugins</string> -->
</void>The directory contained |
As discussed in #2872, the current documentation on https://github.com/oracle/opengrok/wiki/Authorization gives dangerous advice in terms of enabling HTTP Basic authentication for the web application.
This decoder addition forms a basis for subsequent work (e.g. adding an authorization plugin that checks the user against a whitelist, similarly to what the pre-existing Ldap plugins do).
I will update the above mentioned documentation once this is merged in.