Skip to content

Commit

Permalink
Option to use endpoints starting with _security (#36379)
Browse files Browse the repository at this point in the history
#36293 deprecates the /_xpack/security/* endpoints in favor of
the /_security/* ones. This commit adds support for the new
endpoints in 6.x to facilitate tests and normal operations in a
mixed 6.x/7.x cluster
  • Loading branch information
jkakavas authored Dec 9, 2018
1 parent 666170a commit 086055b
Show file tree
Hide file tree
Showing 26 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class RestGetCertificateInfoAction extends BaseRestHandler {
public RestGetCertificateInfoAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(GET, "/_xpack/ssl/certificates", this);
controller.registerHandler(GET, "/_ssl/certificates", this);
}

@Override
Expand All @@ -48,4 +49,4 @@ public RestResponse buildResponse(Response response, XContentBuilder builder) th
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public RestAuthenticateAction(Settings settings, RestController controller, Secu
super(settings, licenseState);
this.securityContext = securityContext;
controller.registerHandler(GET, "/_xpack/security/_authenticate", this);
controller.registerHandler(GET, "/_security/_authenticate", this);

// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(GET, "/_shield/authenticate", this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public final class RestGetTokenAction extends SecurityBaseRestHandler {
public RestGetTokenAction(Settings settings, RestController controller, XPackLicenseState xPackLicenseState) {
super(settings, xPackLicenseState);
controller.registerHandler(POST, "/_xpack/security/oauth2/token", this);
controller.registerHandler(POST, "/_/security/oauth2/token", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public final class RestInvalidateTokenAction extends SecurityBaseRestHandler {
public RestInvalidateTokenAction(Settings settings, RestController controller, XPackLicenseState xPackLicenseState) {
super(settings, xPackLicenseState);
controller.registerHandler(DELETE, "/_xpack/security/oauth2/token", this);
controller.registerHandler(DELETE, "/_security/oauth2/token", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class RestDeletePrivilegesAction extends SecurityBaseRestHandler {
public RestDeletePrivilegesAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(DELETE, "/_xpack/security/privilege/{application}/{privilege}", this);
controller.registerHandler(DELETE, "/_security/privilege/{application}/{privilege}", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ public class RestGetPrivilegesAction extends SecurityBaseRestHandler {
public RestGetPrivilegesAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(GET, "/_xpack/security/privilege/", this);
controller.registerHandler(GET, "/_security/privilege/", this);
controller.registerHandler(GET, "/_xpack/security/privilege/{application}", this);
controller.registerHandler(GET, "/_security/privilege/{application}", this);
controller.registerHandler(GET, "/_xpack/security/privilege/{application}/{privilege}", this);
controller.registerHandler(GET, "/_security/privilege/{application}/{privilege}", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public class RestPutPrivilegesAction extends SecurityBaseRestHandler {
public RestPutPrivilegesAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(PUT, "/_xpack/security/privilege/", this);
controller.registerHandler(PUT, "/_security/privilege/", this);
controller.registerHandler(POST, "/_xpack/security/privilege/", this);
controller.registerHandler(POST, "/_security/privilege/", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public final class RestClearRealmCacheAction extends SecurityBaseRestHandler {
public RestClearRealmCacheAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/realm/{realms}/_clear_cache", this);
controller.registerHandler(POST, "/_security/realm/{realms}/_clear_cache", this);

// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(POST, "/_shield/realm/{realms}/_cache/clear", this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public final class RestClearRolesCacheAction extends SecurityBaseRestHandler {
public RestClearRolesCacheAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/role/{name}/_clear_cache", this);
controller.registerHandler(POST, "/_security/role/{name}/_clear_cache", this);

// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(POST, "/_shield/role/{name}/_clear_cache", this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class RestDeleteRoleAction extends SecurityBaseRestHandler {
public RestDeleteRoleAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(DELETE, "/_xpack/security/role/{name}", this);
controller.registerHandler(DELETE, "/_security/role/{name}", this);

// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(DELETE, "/_shield/role/{name}", this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class RestGetRolesAction extends SecurityBaseRestHandler {
public RestGetRolesAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(GET, "/_xpack/security/role/", this);
controller.registerHandler(GET, "/_security/role/", this);
controller.registerHandler(GET, "/_xpack/security/role/{name}", this);
controller.registerHandler(GET, "/_security/role/{name}", this);

// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(GET, "/_shield/role", this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class RestPutRoleAction extends SecurityBaseRestHandler {
public RestPutRoleAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/role/{name}", this);
controller.registerHandler(POST, "/_security/role/{name}", this);
controller.registerHandler(PUT, "/_xpack/security/role/{name}", this);
controller.registerHandler(PUT, "/_security/role/{name}", this);

// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(POST, "/_shield/role/{name}", this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class RestDeleteRoleMappingAction extends SecurityBaseRestHandler {
public RestDeleteRoleMappingAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(DELETE, "/_xpack/security/role_mapping/{name}", this);
controller.registerHandler(DELETE, "/_security/role_mapping/{name}", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public class RestGetRoleMappingsAction extends SecurityBaseRestHandler {
public RestGetRoleMappingsAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(GET, "/_xpack/security/role_mapping/", this);
controller.registerHandler(GET, "/_security/role_mapping/", this);
controller.registerHandler(GET, "/_xpack/security/role_mapping/{name}", this);
controller.registerHandler(GET, "/_security/role_mapping/{name}", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public class RestPutRoleMappingAction extends SecurityBaseRestHandler {
public RestPutRoleMappingAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/role_mapping/{name}", this);
controller.registerHandler(POST, "/_security/role_mapping/{name}", this);
controller.registerHandler(PUT, "/_xpack/security/role_mapping/{name}", this);
controller.registerHandler(PUT, "/_security/role_mapping/{name}", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public RestSamlAuthenticateAction(Settings settings, RestController controller,
XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/saml/authenticate", this);
controller.registerHandler(POST, "/_security/saml/authenticate", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class RestSamlInvalidateSessionAction extends SamlBaseRestHandler {
public RestSamlInvalidateSessionAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/saml/invalidate", this);
controller.registerHandler(POST, "/_security/saml/invalidate", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class RestSamlLogoutAction extends SamlBaseRestHandler {
public RestSamlLogoutAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/saml/logout", this);
controller.registerHandler(POST, "/_security/saml/logout", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class RestSamlPrepareAuthenticationAction extends SamlBaseRestHandler {
public RestSamlPrepareAuthenticationAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/saml/prepare", this);
controller.registerHandler(POST, "/_security/saml/prepare", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ public RestChangePasswordAction(Settings settings, RestController controller, Se
this.securityContext = securityContext;
passwordHasher = Hasher.resolve(XPackSettings.PASSWORD_HASHING_ALGORITHM.get(settings));
controller.registerHandler(POST, "/_xpack/security/user/{username}/_password", this);
controller.registerHandler(POST, "/_security/user/{username}/_password", this);
controller.registerHandler(PUT, "/_xpack/security/user/{username}/_password", this);
controller.registerHandler(PUT, "/_security/user/{username}/_password", this);
controller.registerHandler(POST, "/_xpack/security/user/_password", this);
controller.registerHandler(POST, "/_security/user/_password", this);
controller.registerHandler(PUT, "/_xpack/security/user/_password", this);
controller.registerHandler(PUT, "/_security/user/_password", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class RestDeleteUserAction extends SecurityBaseRestHandler {
public RestDeleteUserAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(DELETE, "/_xpack/security/user/{username}", this);
controller.registerHandler(DELETE, "/_security/user/{username}", this);

// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(DELETE, "/_shield/user/{username}", this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public RestGetUserPrivilegesAction(Settings settings, RestController controller,
super(settings, licenseState);
this.securityContext = securityContext;
controller.registerHandler(GET, "/_xpack/security/user/_privileges", this);
controller.registerHandler(GET, "/_security/user/_privileges", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public class RestGetUsersAction extends SecurityBaseRestHandler {
public RestGetUsersAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(GET, "/_xpack/security/user/", this);
controller.registerHandler(GET, "/_security/user/", this);
controller.registerHandler(GET, "/_xpack/security/user/{username}", this);
controller.registerHandler(GET, "/_security/user/{username}", this);

// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(GET, "/_shield/user", this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ public RestHasPrivilegesAction(Settings settings, RestController controller, Sec
super(settings, licenseState);
this.securityContext = securityContext;
controller.registerHandler(GET, "/_xpack/security/user/{username}/_has_privileges", this);
controller.registerHandler(GET, "/_security/user/{username}/_has_privileges", this);
controller.registerHandler(POST, "/_xpack/security/user/{username}/_has_privileges", this);
controller.registerHandler(POST, "/_security/user/{username}/_has_privileges", this);
controller.registerHandler(GET, "/_xpack/security/user/_has_privileges", this);
controller.registerHandler(GET, "/_security/user/_has_privileges", this);
controller.registerHandler(POST, "/_xpack/security/user/_has_privileges", this);
controller.registerHandler(POST, "/_security/user/_has_privileges", this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public RestPutUserAction(Settings settings, RestController controller, XPackLice
super(settings, licenseState);
passwordHasher = Hasher.resolve(XPackSettings.PASSWORD_HASHING_ALGORITHM.get(settings));
controller.registerHandler(POST, "/_xpack/security/user/{username}", this);
controller.registerHandler(POST, "/_security/user/{username}", this);
controller.registerHandler(PUT, "/_xpack/security/user/{username}", this);
controller.registerHandler(PUT, "/_security/user/{username}", this);

// @deprecated: Remove in 6.0
controller.registerAsDeprecatedHandler(POST, "/_shield/user/{username}", this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ public class RestSetEnabledAction extends SecurityBaseRestHandler {
public RestSetEnabledAction(Settings settings, RestController controller, XPackLicenseState licenseState) {
super(settings, licenseState);
controller.registerHandler(POST, "/_xpack/security/user/{username}/_enable", this);
controller.registerHandler(POST, "/_security/user/{username}/_enable", this);
controller.registerHandler(PUT, "/_xpack/security/user/{username}/_enable", this);
controller.registerHandler(PUT, "/_security/user/{username}/_enable", this);
controller.registerHandler(POST, "/_xpack/security/user/{username}/_disable", this);
controller.registerHandler(POST, "/_security/user/{username}/_disable", this);
controller.registerHandler(PUT, "/_xpack/security/user/{username}/_disable", this);
controller.registerHandler(PUT, "/_security/user/{username}/_disable", this);
}

@Override
Expand Down

0 comments on commit 086055b

Please sign in to comment.