-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdex_test.go
367 lines (341 loc) · 14.8 KB
/
dex_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
package security
import (
"context"
"crypto/rsa"
"encoding/base64"
"math/big"
"strings"
"testing"
"github.com/lestrrat-go/jwx/v2/jwk"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net/http"
"net/http/httptest"
"encoding/json"
"time"
"github.com/golang-jwt/jwt/v5"
)
var (
//nolint:gosec
authtokenAlgRS256 = "eyJhbGciOiJSUzI1NiIsImtpZCI6IjAxYzAyZDVkLWNhYT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QQXYpwP-6hNEZJAXcBtXUnoqMbOdqOjKjNc8ZIBwINe8WVuCZhH2bZc0RK8kh6EgZupMrxAPmmvzfr8RgfU8LKOkQ6Y41UhE7qCkLWARLgQpaRu5HmE_YrZvodqSmY3fU",
"e": "AQAB",
}
dk2 = map[string]any{
"use": "sig",
"kty": "RSA",
"kid": "0f3abdf4e05337b02fa0e36291b9147379dbb686",
"alg": "RS256",
"n": "sUGZtErd2hymWcdHcjkm5bNqVlvMEkVxIabEgWUwWW0mWc2g5QHKysXDS6Oi1Oyzumjx-dmbZ6nz3C_bJMqEbIwRSyxGnUDziraUIs8WAp0bGv440llxhmT26UifOF9TL8iUvRAVKDzCv3YttyxmLojls3c-L9P-71Uc2NmskeBe9lwE5E-1SX2lx01fjhVRrp2TeujqeY7VR4sdKPXyECn7-W7nuOUAQt4ziiGX-gNrt--SX2oG_2TLw_Urv8O9epw8VjB9zWXKsmjkCUVxPAdSHdnlyRQf7TAhiygcK11Fl2ABIv_DwP0Ei5sd-E6FPqfzrNVA81L16mFHaZLciQ",
"e": "AQAB",
}
dk3 = map[string]any{
"use": "sig",
"kty": "RSA",
"kid": "d3519837ce558fa66192a82f925c1169de358d63",
"alg": "RS256",
"n": "qMu9ak2GZVy7mgSG2nqDJAlYBqXCTTbtSTEtAVpYKcCZKRkDY7kWkPrE8rdhuZV0sVN1-5SQivaDtfXSMBBaLpZFbhA0l98fH3ExOpVbdlHNNWd3mSJEcEFc1QGhc755shyFIliOW59JMNzETIF8eq-MXMt8dKxtnUVZWJk8EYOQSxYK7E9cl4HtACIoGHchRrUctIUJBFgSRbKx1u-_Qnf9cnJeSNdXKL8l7bvLtm5UZWPQrUo229pQ687jUKZu-k2Xag3bAsRGJ6ScbWuLBIJdOxNbvnA3XyARxvqIeZAoEFxDn3q6rhyG024MeRhn4Rd_RzeEq2Y0hsa68M7pkw",
"e": "AQAB",
}
dk123 = map[string]any{
"use": "sig",
"kty": "RSA",
"kid": "123",
"alg": "RS256",
"n": "zFSDsEpZ-EegnJpYFTmaUVz2OvtCQty1gYFxLECICU2lrFCxoAFnkARjbyuvT68sIbhdSZ981YoY_oVohhLOMZjNV3KUhRPlMaSZsEDfnZLOGjfRzjOLNGwtcfu7uLvSVOhaF1bqNUtQHN1ljEmcHWJbJzPFLOBD5uK5tZ-zT0q8NyDRnIB3yNPppk1OpMgmAvxpXaIjsTUfOaOz4vbG6opWg4wz-cLgtyvA1YMSQ24EVnHPC4b2fJOJf9DXf1qkVNjiY9BqO19afv8pM1cliYu66wN4D_eAXQnhA_8j6AQyNkHusaOG1TCzxyPQDtcQYjNZfhQBxXLZE_JM_XdCSAdtwPcQTsySHQHIxsFG3M90DiuukCc7iusAcmCupY5jXTH70_ZykvvaTqxgjavj5zsSndiCwSicrJSoh4YwhqUsZMKivphhyZIb0VpzWRhTYhlN1snC184caa_kPgyRRZux40RxCjluo9Taftm2MUji4BZ_TovUG2IBsOJdp9OdmKT9zuw_feNUL5o3ImCmP4ifI03I3kCATS-KnvNnILQQXYpwP-6hNEZJAXcBtXUnoqMbOdqOjKjNc8ZIBwINe8WVuCZhH2bZc0RK8kh6EgZupMrxAPmmvzfr8RgfU8LKOkQ6Y41UhE7qCkLWARLgQpaRu5HmE_YrZvodqSmY3fU",
"e": "AQAB",
}
firstkeys = []map[string]any{
dk1,
dk2,
}
firstkeydata = map[string]any{
"keys": firstkeys,
}
secondkeys = []map[string]any{
dk1,
dk2,
dk3,
dk123,
}
secondkeydata = map[string]any{
"keys": secondkeys,
}
)
func TestDex_keyfetcher(t *testing.T) {
keysfetched := false
second := false
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, rq *http.Request) {
w.Header().Add("content-type", "application/json")
if second {
err := json.NewEncoder(w).Encode(secondkeydata)
if err != nil {
t.Error(err)
}
} else {
err := json.NewEncoder(w).Encode(firstkeydata)
if err != nil {
t.Error(err)
}
}
keysfetched = true
second = !second
}))
dx, err := NewDex(srv.URL)
if err != nil {
t.Errorf("NewDex() error = %v", err)
return
}
if keysfetched == false {
t.Errorf("the keys were not fetched")
return
}
data := [][]map[string]any{firstkeys, secondkeys}
searchkey := dk3["kid"].(string)
// the server will return first "firstkeys" and on the secondcall "secondkeys"
// only the secondkeys contains "dk3", so the following tests if the dex
// will be refreshed with new keys if a key is not found in the current cached
// keyset
for _, d := range data {
keys, err := dx.fetchKeys()
if err != nil {
t.Errorf("no keys returned: %v", err)
return
}
// now check if the current cached key is identical to our mocked keysets
// so we can be sure there was a fetch-request
if keys.Len() != len(d) {
t.Errorf("the fetched keys are not expected, did you update dex?")
return
}
for it := keys.Keys(context.Background()); it.Next(context.Background()); {
pair := it.Pair()
key := pair.Value.(jwk.Key)
keyID := key.KeyID()
require.NotEmpty(t, keyID)
}
k, err := dx.searchKey(searchkey)
if err != nil {
t.Errorf("the key %q could not be retrieved: %v", searchkey, err)
return
}
assert.IsType(t, &rsa.PublicKey{}, k)
pub := k.(*rsa.PublicKey)
e, err := base64.RawURLEncoding.DecodeString(dk3["e"].(string))
require.NoError(t, err)
ei := new(big.Int).SetBytes(e)
assert.EqualValues(t, ei.Int64(), pub.E)
n, err := base64.RawURLEncoding.DecodeString(dk3["n"].(string))
ni := new(big.Int).SetBytes(n)
require.NoError(t, err)
assert.Equal(t, ni.String(), pub.N.String())
}
}
func TestDex_User(t *testing.T) {
test := []struct {
name string
opt Option
token string
t time.Time
err string
}{
{
name: "correct bearer",
token: authtokenAlgRS256,
t: time.Date(2019, time.May, 9, 6, 7, 0, 0, time.UTC),
},
{
name: "correct bearer - explicit whitelist",
opt: AlgorithmsWhitelist([]string{"RS256"}),
token: authtokenAlgRS256,
t: time.Date(2019, time.May, 9, 6, 7, 0, 0, time.UTC),
},
{
name: "token used before issued",
token: authtokenAlgRS256,
t: time.Date(2019, time.May, 9, 6, 6, 0, 0, time.UTC),
err: "token used before issued",
},
{
name: "token is expired",
token: authtokenAlgRS256,
t: time.Date(2019, time.May, 10, 6, 6, 0, 0, time.UTC),
err: "token has invalid claims: token is expired",
},
{
name: "token invalid default whitelist - signature algorithm 'none' no kid",
token: authtokenAlgNone,
t: time.Date(2019, time.May, 10, 6, 6, 0, 0, time.UTC),
err: "token is unverifiable: error while executing keyfunc: invalid token",
},
{
name: "token invalid default whitelist - signature algorithm 'none' with kid",
token: authtokenAlgNoneKid,
t: time.Date(2019, time.May, 10, 6, 6, 0, 0, time.UTC),
err: "token is unverifiable: error while executing keyfunc: invalid token",
},
{
name: "token invalid default whitelist - signature algorithm 'HS256' no kid",
token: authtokenAlgHS256,
t: time.Date(2019, time.May, 10, 6, 6, 0, 0, time.UTC),
err: "token is unverifiable: error while executing keyfunc: invalid token",
},
{
name: "token invalid default whitelist - signature algorithm 'HS256' with kid",
token: authtokenAlgHS256Kid,
t: time.Date(2019, time.May, 10, 6, 6, 0, 0, time.UTC),
err: "token is unverifiable: error while executing keyfunc: invalid token",
},
{
name: "algorithm not in whitelist 'RS256' - signature algorithm 'HS256' with kid",
token: authtokenAlgHS256Kid,
opt: AlgorithmsWhitelist([]string{"RS256"}),
t: time.Date(2019, time.May, 10, 6, 6, 0, 0, time.UTC),
err: "token is unverifiable: error while executing keyfunc: invalid token",
},
{
name: "algorithm not in whitelist - empty whitelist",
token: authtokenAlgRS256,
opt: AlgorithmsWhitelist([]string{}),
t: time.Date(2019, time.May, 10, 6, 6, 0, 0, time.UTC),
err: "token is unverifiable: error while executing keyfunc: invalid token",
},
}
for _, tt := range test {
tt := tt
t.Run(tt.name, func(t *testing.T) {
jwtParserOpt := JWTParserOptions(jwt.WithTimeFunc(func() time.Time {
return tt.t
}))
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, rq *http.Request) {
err := json.NewEncoder(w).Encode(secondkeydata)
if err != nil {
t.Error(err)
}
}))
dx, err := NewDex(srv.URL)
if err != nil {
t.Errorf("NewDex() error = %v", err)
return
}
if tt.opt != nil {
tt.opt(dx)
}
jwtParserOpt(dx)
rq := httptest.NewRequest(http.MethodGet, srv.URL, nil)
rq.Header.Add("Authorization", "Bearer "+tt.token)
usr, err := dx.User(rq)
if err != nil {
if tt.err != "" && tt.err == err.Error() {
return
}
t.Errorf("got error '%v' but expected %q", err, tt.err)
return
}
if usr.Name != "achim" {
t.Errorf("username is %q, but should be 'achim'", usr.Name)
}
if usr.Tenant != "tenant" {
t.Errorf("tenant is %q, but should be 'tenant'", usr.Tenant)
}
})
}
}
func TestDex_UserWithOptions(t *testing.T) {
test := []struct {
name string
t time.Time
err string
}{
{
name: "correct bearer",
t: time.Date(2019, time.May, 9, 6, 7, 0, 0, time.UTC),
},
{
name: "token used before issued",
t: time.Date(2019, time.May, 9, 6, 6, 0, 0, time.UTC),
err: "token used before issued",
},
{
name: "token is expired",
t: time.Date(2019, time.May, 10, 6, 6, 0, 0, time.UTC),
err: "token has invalid claims: token is expired",
},
}
for _, tt := range test {
tt := tt
t.Run(tt.name, func(t *testing.T) {
jwtParserOpt := JWTParserOptions(jwt.WithTimeFunc(func() time.Time {
return tt.t
}))
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, rq *http.Request) {
err := json.NewEncoder(w).Encode(secondkeydata)
if err != nil {
t.Error(err)
}
}))
dx, err := NewDex(srv.URL)
if err != nil {
t.Errorf("NewDex() error = %v", err)
return
}
jwtParserOpt(dx)
// change Name to akim and de-prefix groups - just for this test
dx.With(UserExtractor(func(claims *Claims) (user *User, e error) {
var grps []ResourceAccess
for _, g := range claims.Groups {
grps = append(grps, ResourceAccess(strings.TrimPrefix(g, "k8s_")))
}
tenant := ""
if claims.FederatedClaims != nil {
cid := claims.FederatedClaims["connector_id"]
if cid != "" {
tenant = strings.Split(cid, "_")[0]
}
}
usr := User{
Issuer: claims.Issuer,
Subject: claims.Subject,
Name: "akim",
EMail: claims.EMail,
Groups: grps,
Tenant: tenant,
}
return &usr, nil
}))
rq := httptest.NewRequest(http.MethodGet, srv.URL, nil)
rq.Header.Add("Authorization", "Bearer "+authtokenAlgRS256)
usr, err := dx.User(rq)
if err != nil {
if tt.err != "" && tt.err == err.Error() {
return
}
t.Errorf("got error '%v' but expected %q", err, tt.err)
return
}
if usr.Name != "akim" {
t.Errorf("username is %q, but should be 'akim'", usr.Name)
}
if usr.Tenant != "tenant" {
t.Errorf("tenant is %q, but should be 'tenant'", usr.Tenant)
}
require.Contains(t, usr.Groups, ResourceAccess("kaas-view"))
require.Contains(t, usr.Groups, ResourceAccess("development__cluster-admin"))
require.Contains(t, usr.Groups, ResourceAccess("production__cluster-admin"))
require.Contains(t, usr.Groups, ResourceAccess("staging__cluster-admin"))
})
}
}