Skip to content
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

*: authentication using tidb_auth_token plugin #38773

Merged
merged 47 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
50b3168
TODO
CbcWestwolf Oct 31, 2022
e4bf414
Merge branch 'tidb_auth_token_2' of github.com:CbcWestwolf/tidb into …
CbcWestwolf Oct 31, 2022
1a28093
Update
CbcWestwolf Oct 31, 2022
dfbda78
Update
CbcWestwolf Nov 1, 2022
020dc44
Merge branch 'master' of github.com:pingcap/tidb into tidb_auth_token_2
CbcWestwolf Nov 1, 2022
eb84d03
Update
CbcWestwolf Nov 1, 2022
678c112
Fix
CbcWestwolf Nov 1, 2022
0fdd7f3
Fix
CbcWestwolf Nov 1, 2022
ced61aa
Prepare for test
CbcWestwolf Nov 1, 2022
1442062
Fix
CbcWestwolf Nov 1, 2022
da192d7
Success to get the claim
CbcWestwolf Nov 1, 2022
d03b0ab
Update
CbcWestwolf Nov 1, 2022
cb6116b
Update
CbcWestwolf Nov 1, 2022
22ca1bd
Finish UT
CbcWestwolf Nov 1, 2022
87983b2
Fix
CbcWestwolf Nov 1, 2022
685525a
Fix
CbcWestwolf Nov 2, 2022
827c20f
Update
CbcWestwolf Nov 2, 2022
6b42cd8
update bazel dep
hawkingrei Nov 2, 2022
898d1eb
Merge branch 'master' into tidb_auth_token_2
hawkingrei Nov 2, 2022
4b23551
update bazel dep
hawkingrei Nov 2, 2022
a7bfa07
Fix goleak
CbcWestwolf Nov 2, 2022
b8bf279
Update
CbcWestwolf Nov 2, 2022
e970e67
Update config/config.go
CbcWestwolf Nov 2, 2022
ff115f7
Update
CbcWestwolf Nov 2, 2022
d1c5456
Merge branch 'master' of github.com:pingcap/tidb into tidb_auth_token_2
CbcWestwolf Nov 2, 2022
f4814b6
Merge branch 'tidb_auth_token_2' of github.com:CbcWestwolf/tidb into …
CbcWestwolf Nov 2, 2022
8c75204
use hack.String
CbcWestwolf Nov 2, 2022
3269b03
Merge branch 'master' of github.com:pingcap/tidb into tidb_auth_token_2
CbcWestwolf Nov 2, 2022
e0b8f63
Fix
CbcWestwolf Nov 2, 2022
f6f1577
Unfix TestANSISQLMode
CbcWestwolf Nov 2, 2022
a0111fd
Fix goleak
CbcWestwolf Nov 3, 2022
fcc648f
Fix
CbcWestwolf Nov 3, 2022
9ff49cc
Update privilege/privileges/tidb_auth_token.go
CbcWestwolf Nov 3, 2022
36e1141
Update
CbcWestwolf Nov 3, 2022
c12275e
Merge branch 'tidb_auth_token_2' of github.com:CbcWestwolf/tidb into …
CbcWestwolf Nov 3, 2022
635972c
Update
CbcWestwolf Nov 3, 2022
16bffbc
Fix goleak
CbcWestwolf Nov 3, 2022
6a62a58
Merge branch 'master' of github.com:pingcap/tidb into tidb_auth_token_2
CbcWestwolf Nov 3, 2022
3c223f4
Merge branch 'master' into tidb_auth_token_2
ti-chi-bot Nov 3, 2022
a36569e
fmt checkAuthTokenClaims
CbcWestwolf Nov 3, 2022
beb2ba9
Merge branch 'tidb_auth_token_2' of github.com:CbcWestwolf/tidb into …
CbcWestwolf Nov 3, 2022
ac72350
Add ctx and waitgroup
CbcWestwolf Nov 3, 2022
cd17213
Fix goleak
CbcWestwolf Nov 3, 2022
ba63c8c
Fix
CbcWestwolf Nov 3, 2022
ce5d9af
fmt
CbcWestwolf Nov 3, 2022
ef326ad
Merge branch 'master' into tidb_auth_token_2
ti-chi-bot Nov 3, 2022
06965b6
Merge branch 'master' into tidb_auth_token_2
ti-chi-bot Nov 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
155 changes: 76 additions & 79 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,21 @@ def go_deps():
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=",
version = "v1.1.1",
)
go_repository(
name = "com_github_decred_dcrd_crypto_blake256",
build_file_proto_mode = "disable",
importpath = "github.com/decred/dcrd/crypto/blake256",
sum = "h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=",
version = "v1.0.0",
)
go_repository(
name = "com_github_decred_dcrd_dcrec_secp256k1_v4",
build_file_proto_mode = "disable",
importpath = "github.com/decred/dcrd/dcrec/secp256k1/v4",
sum = "h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4=",
version = "v4.1.0",
)

go_repository(
name = "com_github_denis_tingaikin_go_header",
build_file_proto_mode = "disable",
Expand Down Expand Up @@ -1242,6 +1257,14 @@ def go_deps():
sum = "h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=",
version = "v1.0.2",
)
go_repository(
name = "com_github_goccy_go_json",
build_file_proto_mode = "disable",
importpath = "github.com/goccy/go-json",
sum = "h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=",
version = "v0.9.11",
)

go_repository(
name = "com_github_godbus_dbus_v5",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -1490,14 +1513,6 @@ def go_deps():
sum = "h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=",
version = "v1.3.0",
)
go_repository(
name = "com_github_googleapis_enterprise_certificate_proxy",
build_file_proto_mode = "disable",
importpath = "github.com/googleapis/enterprise-certificate-proxy",
sum = "h1:7MYGT2XEMam7Mtzv1yDUYXANedWvwk3HKkR3MyGowy8=",
version = "v0.0.0-20220520183353-fd19c99a87aa",
)

go_repository(
name = "com_github_googleapis_gax_go_v2",
build_file_proto_mode = "disable_global",
Expand All @@ -1512,14 +1527,6 @@ def go_deps():
sum = "h1:l6N3VoaVzTncYYW+9yOz2LJJammFZGBO13sqgEhpy9g=",
version = "v0.2.0",
)
go_repository(
name = "com_github_googleapis_go_type_adapters",
build_file_proto_mode = "disable",
importpath = "github.com/googleapis/go-type-adapters",
sum = "h1:9XdMn+d/G57qq1s8dNc5IesGCXHf6V2HZ2JwRxfA2tA=",
version = "v1.0.0",
)

go_repository(
name = "com_github_gophercloud_gophercloud",
build_file_proto_mode = "disable",
Expand Down Expand Up @@ -2262,6 +2269,49 @@ def go_deps():
sum = "h1:tC2y/ygPbMFSBOs3DcyaEMKnnwH7eYKzohOtRrf0SAg=",
version = "v1.1.0",
)
go_repository(
name = "com_github_lestrrat_go_blackmagic",
build_file_proto_mode = "disable",
importpath = "github.com/lestrrat-go/blackmagic",
sum = "h1:lS5Zts+5HIC/8og6cGHb0uCcNCa3OUt1ygh3Qz2Fe80=",
version = "v1.0.1",
)
go_repository(
name = "com_github_lestrrat_go_httpcc",
build_file_proto_mode = "disable",
importpath = "github.com/lestrrat-go/httpcc",
sum = "h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE=",
version = "v1.0.1",
)
go_repository(
name = "com_github_lestrrat_go_httprc",
build_file_proto_mode = "disable",
importpath = "github.com/lestrrat-go/httprc",
sum = "h1:bAZymwoZQb+Oq8MEbyipag7iSq6YIga8Wj6GOiJGdI8=",
version = "v1.0.4",
)
go_repository(
name = "com_github_lestrrat_go_iter",
build_file_proto_mode = "disable",
importpath = "github.com/lestrrat-go/iter",
sum = "h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI=",
version = "v1.0.2",
)
go_repository(
name = "com_github_lestrrat_go_jwx_v2",
build_file_proto_mode = "disable",
importpath = "github.com/lestrrat-go/jwx/v2",
sum = "h1:RlyYNLV892Ed7+FTfj1ROoF6x7WxL965PGTHso/60G0=",
version = "v2.0.6",
)
go_repository(
name = "com_github_lestrrat_go_option",
build_file_proto_mode = "disable",
importpath = "github.com/lestrrat-go/option",
sum = "h1:WqAWL8kh8VcSoD6xjSH34/1m8yxluXQbDeKNfvFeEO4=",
version = "v1.0.0",
)

go_repository(
name = "com_github_lib_pq",
build_file_proto_mode = "disable",
Expand Down Expand Up @@ -2795,14 +2845,6 @@ def go_deps():
sum = "h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=",
version = "v2.6.1+incompatible",
)
go_repository(
name = "com_github_pierrec_lz4_v4",
build_file_proto_mode = "disable",
importpath = "github.com/pierrec/lz4/v4",
sum = "h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0=",
version = "v4.1.15",
)

go_repository(
name = "com_github_pingcap_badger",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -2880,14 +2922,6 @@ def go_deps():
sum = "h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98=",
version = "v0.0.0-20180916011732-0a3d74bf9ce4",
)
go_repository(
name = "com_github_pkg_diff",
build_file_proto_mode = "disable",
importpath = "github.com/pkg/diff",
sum = "h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A=",
version = "v0.0.0-20210226163009-20ebb0f2a09e",
)

go_repository(
name = "com_github_pkg_errors",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -3211,14 +3245,6 @@ def go_deps():
sum = "h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=",
version = "v2.1.4+incompatible",
)
go_repository(
name = "com_github_shopify_toxiproxy_v2",
build_file_proto_mode = "disable",
importpath = "github.com/Shopify/toxiproxy/v2",
sum = "h1:O1e4Jfvr/hefNTNu+8VtdEG5lSeamJRo4aKhMOKNM64=",
version = "v2.4.0",
)

go_repository(
name = "com_github_shopspring_decimal",
build_file_proto_mode = "disable",
Expand Down Expand Up @@ -3579,13 +3605,6 @@ def go_deps():
sum = "h1:hh+/cpIcopyMYbZNVov9iSxvJU3OYQg78Sfaqzi/CzI=",
version = "v0.0.5",
)
go_repository(
name = "com_github_urfave_cli_v2",
build_file_proto_mode = "disable",
importpath = "github.com/urfave/cli/v2",
sum = "h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=",
version = "v2.3.0",
)

go_repository(
name = "com_github_urfave_negroni",
Expand Down Expand Up @@ -3660,28 +3679,6 @@ def go_deps():
sum = "h1:9DDCDwOyEy/gId+IEMrFHLuQ5R/WV0KNxWLler8X2OY=",
version = "v0.0.0-20161129230411-ed8402a42d5f",
)
go_repository(
name = "com_github_xdg_go_pbkdf2",
build_file_proto_mode = "disable",
importpath = "github.com/xdg-go/pbkdf2",
sum = "h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=",
version = "v1.0.0",
)
go_repository(
name = "com_github_xdg_go_scram",
build_file_proto_mode = "disable",
importpath = "github.com/xdg-go/scram",
sum = "h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=",
version = "v1.1.1",
)
go_repository(
name = "com_github_xdg_go_stringprep",
build_file_proto_mode = "disable",
importpath = "github.com/xdg-go/stringprep",
sum = "h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=",
version = "v1.0.3",
)

go_repository(
name = "com_github_xdg_scram",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -4334,8 +4331,8 @@ def go_deps():
name = "org_golang_x_crypto",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/crypto",
sum = "h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=",
version = "v0.0.0-20220411220226-7b82a4e95df4",
sum = "h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=",
version = "v0.1.0",
)
go_repository(
name = "org_golang_x_exp",
Expand Down Expand Up @@ -4384,8 +4381,8 @@ def go_deps():
name = "org_golang_x_net",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/net",
sum = "h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0=",
version = "v0.0.0-20220722155237-a158d28d115b",
sum = "h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=",
version = "v0.1.0",
)
go_repository(
name = "org_golang_x_oauth2",
Expand All @@ -4405,22 +4402,22 @@ def go_deps():
name = "org_golang_x_sys",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/sys",
sum = "h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=",
version = "v0.0.0-20220928140112-f11e5e49a4ec",
sum = "h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=",
version = "v0.1.0",
)
go_repository(
name = "org_golang_x_term",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/term",
sum = "h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=",
version = "v0.0.0-20210927222741-03fcf44c2211",
sum = "h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw=",
version = "v0.1.0",
)
go_repository(
name = "org_golang_x_text",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/text",
sum = "h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=",
version = "v0.3.7",
sum = "h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=",
version = "v0.4.0",
)
go_repository(
name = "org_golang_x_time",
Expand Down
4 changes: 3 additions & 1 deletion br/pkg/mock/mock_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ func TestSmoke(t *testing.T) {
goleak.IgnoreTopFunction("github.com/golang/glog.(*loggingT).flushDaemon"),
goleak.IgnoreTopFunction("github.com/klauspost/compress/zstd.(*blockDec).startDecoder"),
goleak.IgnoreTopFunction("go.etcd.io/etcd/client/pkg/v3/logutil.(*MergeLogger).outputLoop"),
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"))
goleak.IgnoreTopFunction("go.opencensus.io/stats/view.(*worker).start"),
goleak.IgnoreTopFunction("github.com/lestrrat-go/httprc.runFetchWorker"),
)
m, err := mock.NewCluster()
require.NoError(t, err)
require.NoError(t, m.Start())
Expand Down
8 changes: 8 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const (
DefMemoryUsageAlarmRatio = 0.8
// DefTempDir is the default temporary directory path for TiDB.
DefTempDir = "/tmp/tidb"
// DefAuthTokenRefreshInterval is the default time interval to refresh tidb auth token.
DefAuthTokenRefreshInterval = time.Hour
)

// Valid config maps
Expand Down Expand Up @@ -546,6 +548,10 @@ type Security struct {
MinTLSVersion string `toml:"tls-version" json:"tls-version"`
RSAKeySize int `toml:"rsa-key-size" json:"rsa-key-size"`
SecureBootstrap bool `toml:"secure-bootstrap" json:"secure-bootstrap"`
// The path of the JWKS for tidb_auth_token authentication
AuthTokenJWKS string `toml:"auth-token-jwks" json:"auth-token-jwks"`
// The refresh time interval of JWKS
AuthTokenRefreshInterval string `toml:"auth-token-refresh-interval" json:"auth-token-refresh-interval"`
}

// The ErrConfigValidationFailed error is used so that external callers can do a type assertion
Expand Down Expand Up @@ -959,6 +965,8 @@ var defaultConf = Config{
EnableSEM: false,
AutoTLS: false,
RSAKeySize: 4096,
AuthTokenJWKS: "",
AuthTokenRefreshInterval: DefAuthTokenRefreshInterval.String(),
},
DeprecateIntegerDisplayWidth: false,
EnableEnumLengthLimit: true,
Expand Down
18 changes: 13 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ require (
github.com/kisielk/errcheck v1.6.2
github.com/klauspost/compress v1.15.1
github.com/kyoh86/exportloopref v0.1.8
github.com/lestrrat-go/jwx/v2 v2.0.6
github.com/mgechev/revive v1.2.4
github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7
github.com/nishanths/predeclared v0.2.2
Expand Down Expand Up @@ -106,12 +107,12 @@ require (
go.uber.org/multierr v1.8.0
go.uber.org/zap v1.23.0
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e
golang.org/x/net v0.0.0-20220722155237-a158d28d115b
golang.org/x/net v0.1.0
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
golang.org/x/text v0.3.7
golang.org/x/sys v0.1.0
golang.org/x/term v0.1.0
golang.org/x/text v0.4.0
golang.org/x/time v0.0.0-20220224211638-0e9765cccd65
golang.org/x/tools v0.1.12
google.golang.org/api v0.74.0
Expand Down Expand Up @@ -147,6 +148,7 @@ require (
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
Expand All @@ -157,6 +159,7 @@ require (
github.com/go-kit/kit v0.9.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-cmp v0.5.8 // indirect
Expand All @@ -181,6 +184,11 @@ require (
github.com/klauspost/cpuid v1.3.1 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.4 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
Expand Down Expand Up @@ -228,7 +236,7 @@ require (
go.opentelemetry.io/otel/sdk/metric v0.20.0 // indirect
go.opentelemetry.io/otel/trace v0.20.0 // indirect
go.opentelemetry.io/proto/otlp v0.7.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20220613132600-b0d781184e0d // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
Expand Down
Loading