diff --git a/agent/acl_endpoint.go b/agent/acl_endpoint.go index 59a51f4de..d3d4e2a51 100644 --- a/agent/acl_endpoint.go +++ b/agent/acl_endpoint.go @@ -105,55 +105,6 @@ func (s *HTTPHandlers) ACLRulesTranslate(resp http.ResponseWriter, req *http.Req return nil, nil } -func (s *HTTPHandlers) ACLRulesTranslateLegacyToken(resp http.ResponseWriter, req *http.Request) (interface{}, error) { - if s.checkACLDisabled(resp, req) { - return nil, nil - } - - tokenID := strings.TrimPrefix(req.URL.Path, "/v1/acl/rules/translate/") - if tokenID == "" { - return nil, BadRequestError{Reason: "Missing token ID"} - } - - args := structs.ACLTokenGetRequest{ - Datacenter: s.agent.config.Datacenter, - TokenID: tokenID, - TokenIDType: structs.ACLTokenAccessor, - } - if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done { - return nil, nil - } - - if args.Datacenter == "" { - args.Datacenter = s.agent.config.Datacenter - } - - // Do not allow blocking - args.QueryOptions.MinQueryIndex = 0 - - var out structs.ACLTokenResponse - defer setMeta(resp, &out.QueryMeta) - if err := s.agent.RPC("ACL.TokenRead", &args, &out); err != nil { - return nil, err - } - - if out.Token == nil { - return nil, acl.ErrNotFound - } - - if out.Token.Rules == "" { - return nil, fmt.Errorf("The specified token does not have any rules set") - } - - translated, err := acl.TranslateLegacyRules([]byte(out.Token.Rules)) - if err != nil { - return nil, fmt.Errorf("Failed to parse legacy rules: %v", err) - } - - resp.Write(translated) - return nil, nil -} - func (s *HTTPHandlers) ACLPolicyList(resp http.ResponseWriter, req *http.Request) (interface{}, error) { if s.checkACLDisabled(resp, req) { return nil, nil diff --git a/agent/acl_endpoint_test.go b/agent/acl_endpoint_test.go index 2bf5ecadd..15d8ce4a0 100644 --- a/agent/acl_endpoint_test.go +++ b/agent/acl_endpoint_test.go @@ -46,7 +46,6 @@ func TestACL_Disabled_Response(t *testing.T) { {"ACLReplicationStatus", a.srv.ACLReplicationStatus}, {"AgentToken", a.srv.AgentToken}, // See TestAgent_Token {"ACLRulesTranslate", a.srv.ACLRulesTranslate}, - {"ACLRulesTranslateLegacyToken", a.srv.ACLRulesTranslateLegacyToken}, {"ACLPolicyList", a.srv.ACLPolicyList}, {"ACLPolicyCRUD", a.srv.ACLPolicyCRUD}, {"ACLPolicyCreate", a.srv.ACLPolicyCreate}, diff --git a/agent/http_register.go b/agent/http_register.go index e6329971e..7a7e75082 100644 --- a/agent/http_register.go +++ b/agent/http_register.go @@ -20,7 +20,7 @@ func init() { registerEndpoint("/v1/acl/auth-method", []string{"PUT"}, (*HTTPHandlers).ACLAuthMethodCreate) registerEndpoint("/v1/acl/auth-method/", []string{"GET", "PUT", "DELETE"}, (*HTTPHandlers).ACLAuthMethodCRUD) registerEndpoint("/v1/acl/rules/translate", []string{"POST"}, (*HTTPHandlers).ACLRulesTranslate) - registerEndpoint("/v1/acl/rules/translate/", []string{"GET"}, (*HTTPHandlers).ACLRulesTranslateLegacyToken) + registerEndpoint("/v1/acl/rules/translate/", []string{"GET"}, (*HTTPHandlers).ACLLegacy) registerEndpoint("/v1/acl/tokens", []string{"GET"}, (*HTTPHandlers).ACLTokenList) registerEndpoint("/v1/acl/token", []string{"PUT"}, (*HTTPHandlers).ACLTokenCreate) registerEndpoint("/v1/acl/token/self", []string{"GET"}, (*HTTPHandlers).ACLTokenSelf)