-
Notifications
You must be signed in to change notification settings - Fork 793
introduce UserWhiteListPlugin #2876
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
|
Testing setup: <user username="foo" password="bar" roles="tomcat,manager-script"/>
<user username="bar" password="foo" roles="tomcat,manager-script"/> and the indexer was run with: where the <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 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.UserWhiteListPlugin</string>
</void>
<void property="flag">
<string>REQUIRED</string>
</void>
<void property="setup">
<void method="put">
<string>file</string>
<string>/var/opengrok/etc/user-whitelist.txt</string>
</void>
</void>
</object>
</void>
</void>
</void>with and the following was inserted 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 -->
<url-pattern>/api/v1/search</url-pattern> <!-- protect search endpoint whitelisted above -->
<url-pattern>/api/v1/suggest/*</url-pattern> <!-- protect suggest endpoint whitelisted above -->
</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>This setup enforced the authentication in Tomcat and authorization in OpenGrok. Using the and then the Obviously this can be made more fine grained by uncommenting the |
|
Once this is merged in, I will update the Authorization wiki. |
This change introduces new simple authorization plugin that checks user against a whitelist. It complements/depends on the HTTP Basic Auth decoder (PR #2875).
The idea was spawned by the discussion in #2872. Basically, it allows to shift authorization decision from Tomcat to OpenGrok authorization framework for setup where authentication is done by Tomcat.