Support /a/ for plugin REST APIs
Without the /a/, users are unable to script REST API calls using tools such as curl, as the CurrentUser wasn't being provided. Also fix a minor bug when anonymous users tried to access /a/ URLs. We were throwing an exception when building up our error message. Change-Id: I5ce870960aa107001c4014fefcf914adc366cd8a Signed-off-by: Brad Larson <bklarson@gmail.com>
This commit is contained in:
committed by
Shawn O. Pearce
parent
86d22c2276
commit
bfef420aef
@@ -102,10 +102,13 @@ public abstract class RestApiServlet extends HttpServlet {
|
||||
CapabilityControl ctl = user.getCapabilities();
|
||||
if (!ctl.canPerform(rc.value()) && !ctl.canAdministrateServer()) {
|
||||
String msg = String.format(
|
||||
"fatal: %s does not have \"%s\" capability.",
|
||||
Objects.firstNonNull(user.getUserName(),
|
||||
((IdentifiedUser)user).getNameEmail()),
|
||||
rc.value());
|
||||
"fatal: %s does not have \"%s\" capability.",
|
||||
Objects.firstNonNull(
|
||||
user.getUserName(),
|
||||
user instanceof IdentifiedUser
|
||||
? ((IdentifiedUser) user).getNameEmail()
|
||||
: user.toString()),
|
||||
rc.value());
|
||||
throw new RequireCapabilityException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ public class HttpPluginModule extends ServletModule {
|
||||
protected void configureServlets() {
|
||||
bind(HttpPluginServlet.class);
|
||||
serve("/plugins/*").with(HttpPluginServlet.class);
|
||||
serveRegex("^/(?:a/)?plugins/(.*)?$").with(HttpPluginServlet.class);
|
||||
|
||||
bind(StartPluginListener.class)
|
||||
.annotatedWith(UniqueAnnotations.create())
|
||||
|
||||
Reference in New Issue
Block a user