From 1c6316c1c94f3ad5676827f758bd812670b62845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Oliveirinha?= Date: Mon, 14 Nov 2022 14:50:17 +0000 Subject: [PATCH] TUN-6935: Cloudflared should use APIToken instead of serviceKey This commit makes cloudflared use the API token provided during login instead of service key. In addition, it eliminates some of the old formats since those are legacy and we only support cloudflared versions newer than 6 months. --- certutil/certutil.go | 62 +++----------- certutil/certutil_test.go | 40 +++------ certutil/test-cert-no-key.pem | 33 ------- ...l-cert-json.pem => test-cert-no-token.pem} | 5 +- certutil/test-cert-two-certificates.pem | 85 ------------------- certutil/test-cert-unknown-block.pem | 4 +- certutil/test-cert.pem | 61 ------------- ...m => test-cloudflare-tunnel-cert-json.pem} | 5 +- cfapi/base_client.go | 2 +- cmd/cloudflared/tunnel/subcommand_context.go | 2 +- 10 files changed, 34 insertions(+), 265 deletions(-) delete mode 100644 certutil/test-cert-no-key.pem rename certutil/{test-argo-tunnel-cert-json.pem => test-cert-no-token.pem} (96%) delete mode 100644 certutil/test-cert-two-certificates.pem delete mode 100644 certutil/test-cert.pem rename certutil/{test-argo-tunnel-cert.pem => test-cloudflare-tunnel-cert-json.pem} (94%) diff --git a/certutil/certutil.go b/certutil/certutil.go index 0e90ed4b..951926bb 100644 --- a/certutil/certutil.go +++ b/certutil/certutil.go @@ -1,25 +1,21 @@ package certutil import ( - "crypto/x509" "encoding/json" "encoding/pem" "fmt" - "strings" ) type namedTunnelToken struct { - ZoneID string `json:"zoneID"` - AccountID string `json:"accountID"` - ServiceKey string `json:"serviceKey"` + ZoneID string `json:"zoneID"` + AccountID string `json:"accountID"` + APIToken string `json:"apiToken"` } type OriginCert struct { - PrivateKey interface{} - Cert *x509.Certificate - ZoneID string - ServiceKey string - AccountID string + ZoneID string + APIToken string + AccountID string } func DecodeOriginCert(blocks []byte) (*OriginCert, error) { @@ -33,29 +29,11 @@ func DecodeOriginCert(blocks []byte) (*OriginCert, error) { break } switch block.Type { - case "PRIVATE KEY": - if originCert.PrivateKey != nil { - return nil, fmt.Errorf("Found multiple private key in the certificate") - } - // RSA private key - privateKey, err := x509.ParsePKCS8PrivateKey(block.Bytes) - if err != nil { - return nil, fmt.Errorf("Cannot parse private key") - } - originCert.PrivateKey = privateKey - case "CERTIFICATE": - if originCert.Cert != nil { - return nil, fmt.Errorf("Found multiple certificates in the certificate") - } - cert, err := x509.ParseCertificates(block.Bytes) - if err != nil { - return nil, fmt.Errorf("Cannot parse certificate") - } else if len(cert) > 1 { - return nil, fmt.Errorf("Found multiple certificates in the certificate") - } - originCert.Cert = cert[0] - case "WARP TOKEN", "ARGO TUNNEL TOKEN": - if originCert.ZoneID != "" || originCert.ServiceKey != "" { + case "PRIVATE KEY", "CERTIFICATE": + // this is for legacy purposes. + break + case "ARGO TUNNEL TOKEN": + if originCert.ZoneID != "" || originCert.APIToken != "" { return nil, fmt.Errorf("Found multiple tokens in the certificate") } // The token is a string, @@ -63,18 +41,8 @@ func DecodeOriginCert(blocks []byte) (*OriginCert, error) { ntt := namedTunnelToken{} if err := json.Unmarshal(block.Bytes, &ntt); err == nil { originCert.ZoneID = ntt.ZoneID - originCert.ServiceKey = ntt.ServiceKey + originCert.APIToken = ntt.APIToken originCert.AccountID = ntt.AccountID - } else { - // Try the older format, where the zoneID and service key are separated by - // a new line character - token := string(block.Bytes) - s := strings.Split(token, "\n") - if len(s) != 2 { - return nil, fmt.Errorf("Cannot parse token") - } - originCert.ZoneID = s[0] - originCert.ServiceKey = s[1] } default: return nil, fmt.Errorf("Unknown block %s in the certificate", block.Type) @@ -82,11 +50,7 @@ func DecodeOriginCert(blocks []byte) (*OriginCert, error) { block, rest = pem.Decode(rest) } - if originCert.PrivateKey == nil { - return nil, fmt.Errorf("Missing private key in the certificate") - } else if originCert.Cert == nil { - return nil, fmt.Errorf("Missing certificate in the certificate") - } else if originCert.ZoneID == "" || originCert.ServiceKey == "" { + if originCert.ZoneID == "" || originCert.APIToken == "" { return nil, fmt.Errorf("Missing token in the certificate") } diff --git a/certutil/certutil_test.go b/certutil/certutil_test.go index 26b13f5d..e48ffcf3 100644 --- a/certutil/certutil_test.go +++ b/certutil/certutil_test.go @@ -13,49 +13,33 @@ func TestLoadOriginCert(t *testing.T) { assert.Equal(t, fmt.Errorf("Cannot decode empty certificate"), err) assert.Nil(t, cert) - blocks, err := ioutil.ReadFile("test-cert-no-key.pem") - assert.Nil(t, err) - cert, err = DecodeOriginCert(blocks) - assert.Equal(t, fmt.Errorf("Missing private key in the certificate"), err) - assert.Nil(t, cert) - - blocks, err = ioutil.ReadFile("test-cert-two-certificates.pem") - assert.Nil(t, err) - cert, err = DecodeOriginCert(blocks) - assert.Equal(t, fmt.Errorf("Found multiple certificates in the certificate"), err) - assert.Nil(t, cert) - - blocks, err = ioutil.ReadFile("test-cert-unknown-block.pem") + blocks, err := ioutil.ReadFile("test-cert-unknown-block.pem") assert.Nil(t, err) cert, err = DecodeOriginCert(blocks) assert.Equal(t, fmt.Errorf("Unknown block RSA PRIVATE KEY in the certificate"), err) assert.Nil(t, cert) - - blocks, err = ioutil.ReadFile("test-cert.pem") - assert.Nil(t, err) - cert, err = DecodeOriginCert(blocks) - assert.Nil(t, err) - assert.NotNil(t, cert) - assert.Equal(t, "7b0a4d77dfb881c1a3b7d61ea9443e19", cert.ZoneID) - key := "v1.0-58bd4f9e28f7b3c28e05a35ff3e80ab4fd9644ef3fece537eb0d12e2e9258217-183442fbb0bbdb3e571558fec9b5589ebd77aafc87498ee3f09f64a4ad79ffe8791edbae08b36c1d8f1d70a8670de56922dff92b15d214a524f4ebfa1958859e-7ce80f79921312a6022c5d25e2d380f82ceaefe3fbdc43dd13b080e3ef1e26f7" - assert.Equal(t, key, cert.ServiceKey) } -func TestNewlineArgoTunnelToken(t *testing.T) { - ArgoTunnelTokenTest(t, "test-argo-tunnel-cert.pem") +func TestJSONArgoTunnelTokenEmpty(t *testing.T) { + cert, err := DecodeOriginCert([]byte{}) + blocks, err := ioutil.ReadFile("test-cert-no-token.pem") + assert.Nil(t, err) + cert, err = DecodeOriginCert(blocks) + assert.Equal(t, fmt.Errorf("Missing token in the certificate"), err) + assert.Nil(t, cert) } func TestJSONArgoTunnelToken(t *testing.T) { // The given cert's Argo Tunnel Token was generated by base64 encoding this JSON: // { // "zoneID": "7b0a4d77dfb881c1a3b7d61ea9443e19", - // "serviceKey": "test-service-key", + // "apiToken": "test-service-key", // "accountID": "abcdabcdabcdabcd1234567890abcdef" // } - ArgoTunnelTokenTest(t, "test-argo-tunnel-cert-json.pem") + CloudflareTunnelTokenTest(t, "test-cloudflare-tunnel-cert-json.pem") } -func ArgoTunnelTokenTest(t *testing.T, path string) { +func CloudflareTunnelTokenTest(t *testing.T, path string) { blocks, err := ioutil.ReadFile(path) assert.Nil(t, err) cert, err := DecodeOriginCert(blocks) @@ -63,5 +47,5 @@ func ArgoTunnelTokenTest(t *testing.T, path string) { assert.NotNil(t, cert) assert.Equal(t, "7b0a4d77dfb881c1a3b7d61ea9443e19", cert.ZoneID) key := "test-service-key" - assert.Equal(t, key, cert.ServiceKey) + assert.Equal(t, key, cert.APIToken) } diff --git a/certutil/test-cert-no-key.pem b/certutil/test-cert-no-key.pem deleted file mode 100644 index aae69fc9..00000000 --- a/certutil/test-cert-no-key.pem +++ /dev/null @@ -1,33 +0,0 @@ ------BEGIN CERTIFICATE----- -MIID+jCCA6CgAwIBAgIUJhFxUKEGvTRc3CjCok6dbPGH/P4wCgYIKoZIzj0EAwIw -gagxCzAJBgNVBAYTAlVTMRkwFwYDVQQKExBDbG91ZEZsYXJlLCBJbmMuMTgwNgYD -VQQLEy9DbG91ZEZsYXJlIE9yaWdpbiBTU0wgRUNDIENlcnRpZmljYXRlIEF1dGhv -cml0eTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzETMBEGA1UECBMKQ2FsaWZvcm5p -YTEXMBUGA1UEAxMOKGRldiB1c2Ugb25seSkwHhcNMTcxMDEzMTM1OTAwWhcNMzIx -MDA5MTM1OTAwWjBiMRk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ICATE----- ------BEGIN WARP TOKEN----- -N2IwYTRkNzdkZmI4ODFjMWEzYjdkNjFlYTk0NDNlMTkKdjEuMC01OGJkNGY5ZTI4 -ZjdiM2MyOGUwNWEzNWZmM2U4MGFiNGZkOTY0NGVmM2ZlY2U1MzdlYjBkMTJlMmU5 -MjU4MjE3LTE4MzQ0MmZiYjBiYmRiM2U1NzE1NThmZWM5YjU1ODllYmQ3N2FhZmM4 -NzQ5OGVlM2YwOWY2NGE0YWQ3OWZmZTg3OTFlZGJhZTA4YjM2YzFkOGYxZDcwYTg2 -NzBkZTU2OTIyZGZmOTJiMTVkMjE0YTUyNGY0ZWJmYTE5NTg4NTllLTdjZTgwZjc5 -OTIxMzEyYTYwMjJjNWQyNWUyZDM4MGY4MmNlYWVmZTNmYmRjNDNkZDEzYjA4MGUz -ZWYxZTI2Zjc= ------END WARP TOKEN----- diff --git a/certutil/test-argo-tunnel-cert-json.pem b/certutil/test-cert-no-token.pem similarity index 96% rename from certutil/test-argo-tunnel-cert-json.pem rename to certutil/test-cert-no-token.pem index 6755cff4..f77b3a2d 100644 --- a/certutil/test-argo-tunnel-cert-json.pem +++ b/certutil/test-cert-no-token.pem @@ -51,7 +51,6 @@ K5rShE/l+90YAOzHC89OH/wUz3I5KYOFuehoAiEA8e92aIf9XBkr0K6EvFCiSsD+ x+Yo/cL8fGfVpPt4UM8= -----END CERTIFICATE----- -----BEGIN ARGO TUNNEL TOKEN----- -eyJ6b25lSUQiOiAiN2IwYTRkNzdkZmI4ODFjMWEzYjdkNjFlYTk0NDNlMTkiLCAi -c2VydmljZUtleSI6ICJ0ZXN0LXNlcnZpY2Uta2V5IiwgImFjY291bnRJRCI6ICJh -YmNkYWJjZGFiY2RhYmNkMTIzNDU2Nzg5MGFiY2RlZiJ9 +eyJ6b25lSUQiOiAiN2IwYTRkNzdkZmI4ODFjMWEzYjdkNjFlYTk0NDNlMTkiLCAiYWNjb3VudElE +IjogImFiY2RhYmNkYWJjZGFiY2QxMjM0NTY3ODkwYWJjZGVmIn0= -----END ARGO TUNNEL TOKEN----- diff --git a/certutil/test-cert-two-certificates.pem b/certutil/test-cert-two-certificates.pem deleted file mode 100644 index 214e2f8e..00000000 --- a/certutil/test-cert-two-certificates.pem +++ /dev/null @@ -1,85 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCfGswL16Fz9Ei3 -sAg5AmBizoN2nZdyXHP8T57UxUMcrlJXEEXCVS5RR4m9l+EmK0ng6yHR1H5oX1Lg -1WKyXgWwr0whwmdTD+qWFJW2M8HyefyBKLrsGPuxw4CVYT0h72bxtG0uyrXYh7Mt -z0lHjGV90qrFpq5o0jx0sLbDlDvpFPbIO58uYzKG4Sn2VTC4rOyXPE6SuDvMHIeX -6Ekw4wSVQ9eTbksLQqTyxSqM3zp2ygc56SjGjy1nGQT8ZBGFzSbZAzNOxVKrUsyS -x7LzZVl+zCGCPlQwaYLKObKXadZJmrqSFmErC5jcbVgBz7oJQOglHJ2n0sMcZ+Ja -1Y649mPVAgMBAAECggEAEbPF0ah9fH0IzTU/CPbIeh3flyY8GDuMpR1HvwUurSWB -IFI9bLyVAXKb8vYP1TMaTnXi5qmFof+/JShgyZc3+1tZtWTfoaiC8Y1bRfE2yk+D -xmwddhDmijYGG7i8uEaeddSdFEh2GKAqkbV/QgBvN2Nl4EVmIOAJXXNe9l5LFyjy -sR10aNVJRYV1FahrCTwZ3SovHP4d4AUvHh/3FFZDukHc37CFA0+CcR4uehp5yedi -2UdqaszXqunFo/3h+Tn9dW2C7gTTZx4+mfyaws3p3YOmdYArXvpejxHIc0FGwLBm -sb9K7wGVUiF0Bt0ch+C1mdYrCaFNHnPuDswjmm3FwQKBgQDYtxOwwSLA6ZyppozX -Doyx9a7PhiMHCFKSdVB4l8rpK545a+AmpG6LRScTtBsMTHBhT3IQ3QPWlVm1AhjF -AvXMa1rOeaGbCbDn1xqEoEVPtj4tys8eTfyWmtU73jWT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/BAIwADAdBgNVHQ4EFgQUzA6f2Ajq -zhX67c6piY2a1uTiUkwwHwYDVR0jBBgwFoAU2qfBlqxKMZnf0QeTeYiMelfqJfgw -RAYIKwYBBQUHAQEEODA2MDQGCCsGAQUFBzABhihodHRwOi8vb2NzcC5jbG91ZGZs -YXJlLmNvbS9vcmlnaW5fZWNjX2NhMCMGA1UdEQQcMBqCDCouYXJub2xkLmNvbYIK -YXJub2xkLmNvbTA8BgNVHR8ENTAzMDGgL6AthitodHRwOi8vY3JsLmNsb3VkZmxh -cmUuY29tL29yaWdpbl9lY2NfY2EuY3JsMAoGCCqGSM49BAMCA0gAMEUCIDV7HoMj -K5rShE/l+90YAOzHC89OH/wUz3I5KYOFuehoAiEA8e92aIf9XBkr0K6EvFCiSsD+ -x+Yo/cL8fGfVpPt4UM8= ------END CERTIFICATE----- ------BEGIN WARP TOKEN----- -N2IwYTRkNzdkZmI4ODFjMWEzYjdkNjFlYTk0NDNlMTkKdjEuMC01OGJkNGY5ZTI4 -ZjdiM2MyOGUwNWEzNWZmM2U4MGFiNGZkOTY0NGVmM2ZlY2U1MzdlYjBkMTJlMmU5 -MjU4MjE3LTE4MzQ0MmZiYjBiYmRiM2U1NzE1NThmZWM5YjU1ODllYmQ3N2FhZmM4 -NzQ5OGVlM2YwOWY2NGE0YWQ3OWZmZTg3OTFlZGJhZTA4YjM2YzFkOGYxZDcwYTg2 -NzBkZTU2OTIyZGZmOTJiMTVkMjE0YTUyNGY0ZWJmYTE5NTg4NTllLTdjZTgwZjc5 -OTIxMzEyYTYwMjJjNWQyNWUyZDM4MGY4MmNlYWVmZTNmYmRjNDNkZDEzYjA4MGUz -ZWYxZTI2Zjc= ------END WARP TOKEN----- diff --git a/certutil/test-cert-unknown-block.pem b/certutil/test-cert-unknown-block.pem index f7180851..4a847eb0 100644 --- a/certutil/test-cert-unknown-block.pem +++ b/certutil/test-cert-unknown-block.pem @@ -50,7 +50,7 @@ cmUuY29tL29yaWdpbl9lY2NfY2EuY3JsMAoGCCqGSM49BAMCA0gAMEUCIDV7HoMj K5rShE/l+90YAOzHC89OH/wUz3I5KYOFuehoAiEA8e92aIf9XBkr0K6EvFCiSsD+ x+Yo/cL8fGfVpPt4UM8= -----END CERTIFICATE----- ------BEGIN WARP TOKEN----- +-----BEGIN ARGO TUNNEL TOKEN----- N2IwYTRkNzdkZmI4ODFjMWEzYjdkNjFlYTk0NDNlMTkKdjEuMC01OGJkNGY5ZTI4 ZjdiM2MyOGUwNWEzNWZmM2U4MGFiNGZkOTY0NGVmM2ZlY2U1MzdlYjBkMTJlMmU5 MjU4MjE3LTE4MzQ0MmZiYjBiYmRiM2U1NzE1NThmZWM5YjU1ODllYmQ3N2FhZmM4 @@ -58,7 +58,7 @@ NzQ5OGVlM2YwOWY2NGE0YWQ3OWZmZTg3OTFlZGJhZTA4YjM2YzFkOGYxZDcwYTg2 NzBkZTU2OTIyZGZmOTJiMTVkMjE0YTUyNGY0ZWJmYTE5NTg4NTllLTdjZTgwZjc5 OTIxMzEyYTYwMjJjNWQyNWUyZDM4MGY4MmNlYWVmZTNmYmRjNDNkZDEzYjA4MGUz ZWYxZTI2Zjc= ------END WARP TOKEN----- +-----END ARGO TUNNEL TOKEN----- -----BEGIN RSA PRIVATE KEY----- MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCfGswL16Fz9Ei3 sAg5AmBizoN2nZdyXHP8T57UxUMcrlJXEEXCVS5RR4m9l+EmK0ng6yHR1H5oX1Lg diff --git a/certutil/test-cert.pem b/certutil/test-cert.pem deleted file mode 100644 index 4d1c9f89..00000000 --- a/certutil/test-cert.pem +++ /dev/null @@ -1,61 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCfGswL16Fz9Ei3 -sAg5AmBizoN2nZdyXHP8T57UxUMcrlJXEEXCVS5RR4m9l+EmK0ng6yHR1H5oX1Lg -1WKyXgWwr0whwmdT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2YwOWY2NGE0YWQ3OWZmZTg3OTFlZGJhZTA4YjM2YzFkOGYxZDcwYTg2 -NzBkZTU2OTIyZGZmOTJiMTVkMjE0YTUyNGY0ZWJmYTE5NTg4NTllLTdjZTgwZjc5 -OTIxMzEyYTYwMjJjNWQyNWUyZDM4MGY4MmNlYWVmZTNmYmRjNDNkZDEzYjA4MGUz -ZWYxZTI2Zjc= ------END WARP TOKEN----- diff --git a/certutil/test-argo-tunnel-cert.pem b/certutil/test-cloudflare-tunnel-cert-json.pem similarity index 94% rename from certutil/test-argo-tunnel-cert.pem rename to certutil/test-cloudflare-tunnel-cert-json.pem index 1a3397ac..cbbaa334 100644 --- a/certutil/test-argo-tunnel-cert.pem +++ b/certutil/test-cloudflare-tunnel-cert-json.pem @@ -51,6 +51,7 @@ K5rShE/l+90YAOzHC89OH/wUz3I5KYOFuehoAiEA8e92aIf9XBkr0K6EvFCiSsD+ x+Yo/cL8fGfVpPt4UM8= -----END CERTIFICATE----- -----BEGIN ARGO TUNNEL TOKEN----- -N2IwYTRkNzdkZmI4ODFjMWEzYjdkNjFlYTk0NDNlMTkKdGVzdC1zZXJ2aWNlLWtl -eQ== +eyJ6b25lSUQiOiAiN2IwYTRkNzdkZmI4ODFjMWEzYjdkNjFlYTk0NDNlMTkiLCAiYXBpVG9rZW4i +OiAidGVzdC1zZXJ2aWNlLWtleSIsICJhY2NvdW50SUQiOiAiYWJjZGFiY2RhYmNkYWJjZDEyMzQ1 +Njc4OTBhYmNkZWYifQ== -----END ARGO TUNNEL TOKEN----- diff --git a/cfapi/base_client.go b/cfapi/base_client.go index 48b349c3..92544071 100644 --- a/cfapi/base_client.go +++ b/cfapi/base_client.go @@ -104,7 +104,7 @@ func (r *RESTClient) sendRequest(method string, url url.URL, body interface{}) ( if bodyReader != nil { req.Header.Set("Content-Type", jsonContentType) } - req.Header.Add("X-Auth-User-Service-Key", r.authToken) + req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", r.authToken)) req.Header.Add("Accept", "application/json;version=1") return r.client.Do(req) } diff --git a/cmd/cloudflared/tunnel/subcommand_context.go b/cmd/cloudflared/tunnel/subcommand_context.go index 650781e8..bc65aced 100644 --- a/cmd/cloudflared/tunnel/subcommand_context.go +++ b/cmd/cloudflared/tunnel/subcommand_context.go @@ -74,7 +74,7 @@ func (sc *subcommandContext) client() (cfapi.Client, error) { sc.c.String("api-url"), credential.cert.AccountID, credential.cert.ZoneID, - credential.cert.ServiceKey, + credential.cert.APIToken, userAgent, sc.log, )