@@ -264,9 +264,9 @@ func processSpec(referenceSpec *APISpec,
264
264
// Create the response processors
265
265
creeateResponseMiddlewareChain (referenceSpec )
266
266
267
- tykMiddleware := & TykMiddleware {referenceSpec , proxy }
268
- CheckCBEnabled (tykMiddleware )
269
- CheckETEnabled (tykMiddleware )
267
+ baseMid := & BaseMiddleware {referenceSpec , proxy }
268
+ CheckCBEnabled (baseMid )
269
+ CheckETEnabled (baseMid )
270
270
271
271
keyPrefix := "cache-" + referenceSpec .APIID
272
272
cacheStore := & RedisClusterStorageManager {KeyPrefix : keyPrefix , IsCache : true }
@@ -286,19 +286,19 @@ func processSpec(referenceSpec *APISpec,
286
286
handleCORS (& chainArray , referenceSpec )
287
287
288
288
baseChainArray := []alice.Constructor {}
289
- AppendMiddleware (& baseChainArray , & RateCheckMW {TykMiddleware : tykMiddleware }, tykMiddleware )
290
- AppendMiddleware (& baseChainArray , & IPWhiteListMiddleware {TykMiddleware : tykMiddleware }, tykMiddleware )
291
- AppendMiddleware (& baseChainArray , & OrganizationMonitor {TykMiddleware : tykMiddleware }, tykMiddleware )
292
- AppendMiddleware (& baseChainArray , & MiddlewareContextVars {TykMiddleware : tykMiddleware }, tykMiddleware )
293
- AppendMiddleware (& baseChainArray , & VersionCheck {TykMiddleware : tykMiddleware }, tykMiddleware )
294
- AppendMiddleware (& baseChainArray , & RequestSizeLimitMiddleware {tykMiddleware }, tykMiddleware )
295
- AppendMiddleware (& baseChainArray , & TrackEndpointMiddleware {tykMiddleware }, tykMiddleware )
296
- AppendMiddleware (& baseChainArray , & TransformMiddleware {tykMiddleware }, tykMiddleware )
297
- AppendMiddleware (& baseChainArray , & TransformHeaders {TykMiddleware : tykMiddleware }, tykMiddleware )
298
- AppendMiddleware (& baseChainArray , & RedisCacheMiddleware {TykMiddleware : tykMiddleware , CacheStore : cacheStore }, tykMiddleware )
299
- AppendMiddleware (& baseChainArray , & VirtualEndpoint {TykMiddleware : tykMiddleware }, tykMiddleware )
300
- AppendMiddleware (& baseChainArray , & URLRewriteMiddleware {TykMiddleware : tykMiddleware }, tykMiddleware )
301
- AppendMiddleware (& baseChainArray , & TransformMethod {TykMiddleware : tykMiddleware }, tykMiddleware )
289
+ AppendMiddleware (& baseChainArray , & RateCheckMW {BaseMiddleware : baseMid }, baseMid )
290
+ AppendMiddleware (& baseChainArray , & IPWhiteListMiddleware {BaseMiddleware : baseMid }, baseMid )
291
+ AppendMiddleware (& baseChainArray , & OrganizationMonitor {BaseMiddleware : baseMid }, baseMid )
292
+ AppendMiddleware (& baseChainArray , & MiddlewareContextVars {BaseMiddleware : baseMid }, baseMid )
293
+ AppendMiddleware (& baseChainArray , & VersionCheck {BaseMiddleware : baseMid }, baseMid )
294
+ AppendMiddleware (& baseChainArray , & RequestSizeLimitMiddleware {baseMid }, baseMid )
295
+ AppendMiddleware (& baseChainArray , & TrackEndpointMiddleware {baseMid }, baseMid )
296
+ AppendMiddleware (& baseChainArray , & TransformMiddleware {baseMid }, baseMid )
297
+ AppendMiddleware (& baseChainArray , & TransformHeaders {BaseMiddleware : baseMid }, baseMid )
298
+ AppendMiddleware (& baseChainArray , & RedisCacheMiddleware {BaseMiddleware : baseMid , CacheStore : cacheStore }, baseMid )
299
+ AppendMiddleware (& baseChainArray , & VirtualEndpoint {BaseMiddleware : baseMid }, baseMid )
300
+ AppendMiddleware (& baseChainArray , & URLRewriteMiddleware {BaseMiddleware : baseMid }, baseMid )
301
+ AppendMiddleware (& baseChainArray , & TransformMethod {BaseMiddleware : baseMid }, baseMid )
302
302
303
303
log .Debug (referenceSpec .Name , " - CHAIN SIZE: " , len (baseChainArray ))
304
304
@@ -308,9 +308,9 @@ func processSpec(referenceSpec *APISpec,
308
308
"prefix" : "coprocess" ,
309
309
"api_name" : referenceSpec .Name ,
310
310
}).Debug ("Registering coprocess middleware, hook name: " , obj .Name , "hook type: Pre" , ", driver: " , mwDriver )
311
- AppendMiddleware (& chainArray , & CoProcessMiddleware {tykMiddleware , coprocess .HookType_Pre , obj .Name , mwDriver }, tykMiddleware )
311
+ AppendMiddleware (& chainArray , & CoProcessMiddleware {baseMid , coprocess .HookType_Pre , obj .Name , mwDriver }, baseMid )
312
312
} else {
313
- chainArray = append (chainArray , CreateDynamicMiddleware (obj .Name , true , obj .RequireSession , tykMiddleware ))
313
+ chainArray = append (chainArray , CreateDynamicMiddleware (obj .Name , true , obj .RequireSession , baseMid ))
314
314
}
315
315
}
316
316
@@ -322,14 +322,14 @@ func processSpec(referenceSpec *APISpec,
322
322
"prefix" : "coprocess" ,
323
323
"api_name" : referenceSpec .Name ,
324
324
}).Debug ("Registering coprocess middleware, hook name: " , obj .Name , "hook type: Post" , ", driver: " , mwDriver )
325
- AppendMiddleware (& chainArray , & CoProcessMiddleware {tykMiddleware , coprocess .HookType_Post , obj .Name , mwDriver }, tykMiddleware )
325
+ AppendMiddleware (& chainArray , & CoProcessMiddleware {baseMid , coprocess .HookType_Post , obj .Name , mwDriver }, baseMid )
326
326
} else {
327
- chainArray = append (chainArray , CreateDynamicMiddleware (obj .Name , false , obj .RequireSession , tykMiddleware ))
327
+ chainArray = append (chainArray , CreateDynamicMiddleware (obj .Name , false , obj .RequireSession , baseMid ))
328
328
}
329
329
}
330
330
331
331
// for KeyLessAccess we can't support rate limiting, versioning or access rules
332
- chain = alice .New (chainArray ... ).Then (& DummyProxyHandler {SH : SuccessHandler {tykMiddleware }})
332
+ chain = alice .New (chainArray ... ).Then (& DummyProxyHandler {SH : SuccessHandler {baseMid }})
333
333
334
334
} else {
335
335
@@ -338,13 +338,13 @@ func processSpec(referenceSpec *APISpec,
338
338
handleCORS (& chainArray , referenceSpec )
339
339
340
340
var baseChainArray_PreAuth []alice.Constructor
341
- AppendMiddleware (& baseChainArray_PreAuth , & RateCheckMW {TykMiddleware : tykMiddleware }, tykMiddleware )
342
- AppendMiddleware (& baseChainArray_PreAuth , & IPWhiteListMiddleware {TykMiddleware : tykMiddleware }, tykMiddleware )
343
- AppendMiddleware (& baseChainArray_PreAuth , & OrganizationMonitor {TykMiddleware : tykMiddleware }, tykMiddleware )
344
- AppendMiddleware (& baseChainArray_PreAuth , & VersionCheck {TykMiddleware : tykMiddleware }, tykMiddleware )
345
- AppendMiddleware (& baseChainArray_PreAuth , & RequestSizeLimitMiddleware {tykMiddleware }, tykMiddleware )
346
- AppendMiddleware (& baseChainArray_PreAuth , & MiddlewareContextVars {TykMiddleware : tykMiddleware }, tykMiddleware )
347
- AppendMiddleware (& baseChainArray_PreAuth , & TrackEndpointMiddleware {tykMiddleware }, tykMiddleware )
341
+ AppendMiddleware (& baseChainArray_PreAuth , & RateCheckMW {BaseMiddleware : baseMid }, baseMid )
342
+ AppendMiddleware (& baseChainArray_PreAuth , & IPWhiteListMiddleware {BaseMiddleware : baseMid }, baseMid )
343
+ AppendMiddleware (& baseChainArray_PreAuth , & OrganizationMonitor {BaseMiddleware : baseMid }, baseMid )
344
+ AppendMiddleware (& baseChainArray_PreAuth , & VersionCheck {BaseMiddleware : baseMid }, baseMid )
345
+ AppendMiddleware (& baseChainArray_PreAuth , & RequestSizeLimitMiddleware {baseMid }, baseMid )
346
+ AppendMiddleware (& baseChainArray_PreAuth , & MiddlewareContextVars {BaseMiddleware : baseMid }, baseMid )
347
+ AppendMiddleware (& baseChainArray_PreAuth , & TrackEndpointMiddleware {baseMid }, baseMid )
348
348
349
349
// Add pre-process MW
350
350
for _ , obj := range mwPreFuncs {
@@ -353,9 +353,9 @@ func processSpec(referenceSpec *APISpec,
353
353
"prefix" : "coprocess" ,
354
354
"api_name" : referenceSpec .Name ,
355
355
}).Debug ("Registering coprocess middleware, hook name: " , obj .Name , "hook type: Pre" , ", driver: " , mwDriver )
356
- AppendMiddleware (& chainArray , & CoProcessMiddleware {tykMiddleware , coprocess .HookType_Pre , obj .Name , mwDriver }, tykMiddleware )
356
+ AppendMiddleware (& chainArray , & CoProcessMiddleware {baseMid , coprocess .HookType_Pre , obj .Name , mwDriver }, baseMid )
357
357
} else {
358
- chainArray = append (chainArray , CreateDynamicMiddleware (obj .Name , true , obj .RequireSession , tykMiddleware ))
358
+ chainArray = append (chainArray , CreateDynamicMiddleware (obj .Name , true , obj .RequireSession , baseMid ))
359
359
}
360
360
}
361
361
@@ -369,7 +369,7 @@ func processSpec(referenceSpec *APISpec,
369
369
"prefix" : "main" ,
370
370
"api_name" : referenceSpec .Name ,
371
371
}).Info ("Checking security policy: OAuth" )
372
- authArray = append (authArray , CreateMiddleware (& Oauth2KeyExists {tykMiddleware }, tykMiddleware ))
372
+ authArray = append (authArray , CreateMiddleware (& Oauth2KeyExists {baseMid }, baseMid ))
373
373
374
374
}
375
375
@@ -386,7 +386,7 @@ func processSpec(referenceSpec *APISpec,
386
386
"prefix" : "main" ,
387
387
"api_name" : referenceSpec .Name ,
388
388
}).Info ("Checking security policy: Basic" )
389
- authArray = append (authArray , CreateMiddleware (& BasicAuthKeyIsValid {tykMiddleware }, tykMiddleware ))
389
+ authArray = append (authArray , CreateMiddleware (& BasicAuthKeyIsValid {baseMid }, baseMid ))
390
390
}
391
391
392
392
if referenceSpec .EnableSignatureChecking {
@@ -395,7 +395,7 @@ func processSpec(referenceSpec *APISpec,
395
395
"prefix" : "main" ,
396
396
"api_name" : referenceSpec .Name ,
397
397
}).Info ("Checking security policy: HMAC" )
398
- authArray = append (authArray , CreateMiddleware (& HMACMiddleware {TykMiddleware : tykMiddleware }, tykMiddleware ))
398
+ authArray = append (authArray , CreateMiddleware (& HMACMiddleware {BaseMiddleware : baseMid }, baseMid ))
399
399
}
400
400
401
401
if referenceSpec .EnableJWT {
@@ -404,7 +404,7 @@ func processSpec(referenceSpec *APISpec,
404
404
"prefix" : "main" ,
405
405
"api_name" : referenceSpec .Name ,
406
406
}).Info ("Checking security policy: JWT" )
407
- authArray = append (authArray , CreateMiddleware (& JWTMiddleware {tykMiddleware }, tykMiddleware ))
407
+ authArray = append (authArray , CreateMiddleware (& JWTMiddleware {baseMid }, baseMid ))
408
408
}
409
409
410
410
if referenceSpec .UseOpenID {
@@ -415,7 +415,7 @@ func processSpec(referenceSpec *APISpec,
415
415
}).Info ("Checking security policy: OpenID" )
416
416
417
417
// initialise the OID configuration on this reference Spec
418
- authArray = append (authArray , CreateMiddleware (& OpenIDMW {TykMiddleware : tykMiddleware }, tykMiddleware ))
418
+ authArray = append (authArray , CreateMiddleware (& OpenIDMW {BaseMiddleware : baseMid }, baseMid ))
419
419
}
420
420
421
421
if useCoProcessAuth {
@@ -431,8 +431,8 @@ func processSpec(referenceSpec *APISpec,
431
431
}).Debug ("Registering coprocess middleware, hook name: " , mwAuthCheckFunc .Name , "hook type: CustomKeyCheck" , ", driver: " , mwDriver )
432
432
433
433
if useCoProcessAuth {
434
- newExtractor (referenceSpec , tykMiddleware )
435
- AppendMiddleware (& authArray , & CoProcessMiddleware {tykMiddleware , coprocess .HookType_CustomKeyCheck , mwAuthCheckFunc .Name , mwDriver }, tykMiddleware )
434
+ newExtractor (referenceSpec , baseMid )
435
+ AppendMiddleware (& authArray , & CoProcessMiddleware {baseMid , coprocess .HookType_CustomKeyCheck , mwAuthCheckFunc .Name , mwDriver }, baseMid )
436
436
}
437
437
}
438
438
@@ -441,7 +441,7 @@ func processSpec(referenceSpec *APISpec,
441
441
"prefix" : "main" ,
442
442
}).Info ("----> Checking security policy: JS Plugin" )
443
443
444
- authArray = append (authArray , CreateDynamicAuthMiddleware (mwAuthCheckFunc .Name , tykMiddleware ))
444
+ authArray = append (authArray , CreateDynamicAuthMiddleware (mwAuthCheckFunc .Name , baseMid ))
445
445
}
446
446
447
447
if referenceSpec .UseStandardAuth || (! referenceSpec .UseOpenID && ! referenceSpec .EnableJWT && ! referenceSpec .EnableSignatureChecking && ! referenceSpec .UseBasicAuth && ! referenceSpec .UseOauth2 && ! useCoProcessAuth && ! useOttoAuth ) {
@@ -450,7 +450,7 @@ func processSpec(referenceSpec *APISpec,
450
450
"prefix" : "main" ,
451
451
"api_name" : referenceSpec .Name ,
452
452
}).Info ("Checking security policy: Token" )
453
- authArray = append (authArray , CreateMiddleware (& AuthKey {tykMiddleware }, tykMiddleware ))
453
+ authArray = append (authArray , CreateMiddleware (& AuthKey {baseMid }, baseMid ))
454
454
}
455
455
456
456
chainArray = append (chainArray , authArray ... )
@@ -460,20 +460,20 @@ func processSpec(referenceSpec *APISpec,
460
460
"prefix" : "coprocess" ,
461
461
"api_name" : referenceSpec .Name ,
462
462
}).Debug ("Registering coprocess middleware, hook name: " , obj .Name , "hook type: Pre" , ", driver: " , mwDriver )
463
- AppendMiddleware (& chainArray , & CoProcessMiddleware {tykMiddleware , coprocess .HookType_PostKeyAuth , obj .Name , mwDriver }, tykMiddleware )
463
+ AppendMiddleware (& chainArray , & CoProcessMiddleware {baseMid , coprocess .HookType_PostKeyAuth , obj .Name , mwDriver }, baseMid )
464
464
}
465
465
466
466
var baseChainArray_PostAuth []alice.Constructor
467
- AppendMiddleware (& baseChainArray_PostAuth , & KeyExpired {tykMiddleware }, tykMiddleware )
468
- AppendMiddleware (& baseChainArray_PostAuth , & AccessRightsCheck {tykMiddleware }, tykMiddleware )
469
- AppendMiddleware (& baseChainArray_PostAuth , & RateLimitAndQuotaCheck {tykMiddleware }, tykMiddleware )
470
- AppendMiddleware (& baseChainArray_PostAuth , & GranularAccessMiddleware {tykMiddleware }, tykMiddleware )
471
- AppendMiddleware (& baseChainArray_PostAuth , & TransformMiddleware {tykMiddleware }, tykMiddleware )
472
- AppendMiddleware (& baseChainArray_PostAuth , & TransformHeaders {TykMiddleware : tykMiddleware }, tykMiddleware )
473
- AppendMiddleware (& baseChainArray_PostAuth , & URLRewriteMiddleware {TykMiddleware : tykMiddleware }, tykMiddleware )
474
- AppendMiddleware (& baseChainArray_PostAuth , & RedisCacheMiddleware {TykMiddleware : tykMiddleware , CacheStore : cacheStore }, tykMiddleware )
475
- AppendMiddleware (& baseChainArray_PostAuth , & TransformMethod {TykMiddleware : tykMiddleware }, tykMiddleware )
476
- AppendMiddleware (& baseChainArray_PostAuth , & VirtualEndpoint {TykMiddleware : tykMiddleware }, tykMiddleware )
467
+ AppendMiddleware (& baseChainArray_PostAuth , & KeyExpired {baseMid }, baseMid )
468
+ AppendMiddleware (& baseChainArray_PostAuth , & AccessRightsCheck {baseMid }, baseMid )
469
+ AppendMiddleware (& baseChainArray_PostAuth , & RateLimitAndQuotaCheck {baseMid }, baseMid )
470
+ AppendMiddleware (& baseChainArray_PostAuth , & GranularAccessMiddleware {baseMid }, baseMid )
471
+ AppendMiddleware (& baseChainArray_PostAuth , & TransformMiddleware {baseMid }, baseMid )
472
+ AppendMiddleware (& baseChainArray_PostAuth , & TransformHeaders {BaseMiddleware : baseMid }, baseMid )
473
+ AppendMiddleware (& baseChainArray_PostAuth , & URLRewriteMiddleware {BaseMiddleware : baseMid }, baseMid )
474
+ AppendMiddleware (& baseChainArray_PostAuth , & RedisCacheMiddleware {BaseMiddleware : baseMid , CacheStore : cacheStore }, baseMid )
475
+ AppendMiddleware (& baseChainArray_PostAuth , & TransformMethod {BaseMiddleware : baseMid }, baseMid )
476
+ AppendMiddleware (& baseChainArray_PostAuth , & VirtualEndpoint {BaseMiddleware : baseMid }, baseMid )
477
477
478
478
chainArray = append (chainArray , baseChainArray_PostAuth ... )
479
479
@@ -483,9 +483,9 @@ func processSpec(referenceSpec *APISpec,
483
483
"prefix" : "coprocess" ,
484
484
"api_name" : referenceSpec .Name ,
485
485
}).Debug ("Registering coprocess middleware, hook name: " , obj .Name , "hook type: Post" , ", driver: " , mwDriver )
486
- AppendMiddleware (& chainArray , & CoProcessMiddleware {tykMiddleware , coprocess .HookType_Post , obj .Name , mwDriver }, tykMiddleware )
486
+ AppendMiddleware (& chainArray , & CoProcessMiddleware {baseMid , coprocess .HookType_Post , obj .Name , mwDriver }, baseMid )
487
487
} else {
488
- chainArray = append (chainArray , CreateDynamicMiddleware (obj .Name , false , obj .RequireSession , tykMiddleware ))
488
+ chainArray = append (chainArray , CreateDynamicMiddleware (obj .Name , false , obj .RequireSession , baseMid ))
489
489
}
490
490
}
491
491
@@ -494,20 +494,20 @@ func processSpec(referenceSpec *APISpec,
494
494
"api_name" : referenceSpec .Name ,
495
495
}).Debug ("Custom middleware completed processing" )
496
496
497
- // Use CreateMiddleware(&ModifiedMiddleware{tykMiddleware }, tykMiddleware ) to run custom middleware
498
- chain = alice .New (chainArray ... ).Then (& DummyProxyHandler {SH : SuccessHandler {tykMiddleware }})
497
+ // Use CreateMiddleware(&ModifiedMiddleware{baseMid }, baseMid ) to run custom middleware
498
+ chain = alice .New (chainArray ... ).Then (& DummyProxyHandler {SH : SuccessHandler {baseMid }})
499
499
500
500
log .Debug ("Chain completed" )
501
501
502
502
userCheckHandler := UserRatesCheck ()
503
503
simpleChain_PreAuth := []alice.Constructor {
504
- CreateMiddleware (& IPWhiteListMiddleware {tykMiddleware }, tykMiddleware ),
505
- CreateMiddleware (& OrganizationMonitor {TykMiddleware : tykMiddleware }, tykMiddleware ),
506
- CreateMiddleware (& VersionCheck {TykMiddleware : tykMiddleware }, tykMiddleware )}
504
+ CreateMiddleware (& IPWhiteListMiddleware {baseMid }, baseMid ),
505
+ CreateMiddleware (& OrganizationMonitor {BaseMiddleware : baseMid }, baseMid ),
506
+ CreateMiddleware (& VersionCheck {BaseMiddleware : baseMid }, baseMid )}
507
507
508
508
simpleChain_PostAuth := []alice.Constructor {
509
- CreateMiddleware (& KeyExpired {tykMiddleware }, tykMiddleware ),
510
- CreateMiddleware (& AccessRightsCheck {tykMiddleware }, tykMiddleware )}
509
+ CreateMiddleware (& KeyExpired {baseMid }, baseMid ),
510
+ CreateMiddleware (& AccessRightsCheck {baseMid }, baseMid )}
511
511
512
512
var fullSimpleChain []alice.Constructor
513
513
fullSimpleChain = append (fullSimpleChain , simpleChain_PreAuth ... )
0 commit comments