-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[TT-11908] add request signing to OAS upstream authentication #6850
Conversation
API Changes --- prev.txt 2025-02-07 09:25:34.061455287 +0000
+++ current.txt 2025-02-07 09:25:29.614445518 +0000
@@ -4330,15 +4330,17 @@
BasicAuth *UpstreamBasicAuth `bson:"basicAuth,omitempty" json:"basicAuth,omitempty"`
// OAuth contains the configuration for OAuth2 Client Credentials flow.
OAuth *UpstreamOAuth `bson:"oauth,omitempty" json:"oauth,omitempty"`
+ // RequestSigning holds the configuration for generating signed requests to an upstream API.
+ RequestSigning *UpstreamRequestSigning `bson:"requestSigning,omitempty" json:"requestSigning,omitempty"`
}
UpstreamAuth holds the configurations related to upstream API
authentication.
-func (u *UpstreamAuth) ExtractTo(api *apidef.UpstreamAuth)
- ExtractTo extracts *UpstreamAuth into *apidef.UpstreamAuth.
+func (u *UpstreamAuth) ExtractTo(api *apidef.APIDefinition)
+ ExtractTo extracts *UpstreamAuth into *apidef.APIDefinition.
-func (u *UpstreamAuth) Fill(api apidef.UpstreamAuth)
- Fill fills *UpstreamAuth from apidef.UpstreamAuth.
+func (u *UpstreamAuth) Fill(api apidef.APIDefinition)
+ Fill fills *UpstreamAuth from apidef.APIDefinition.
type UpstreamBasicAuth struct {
// Enabled enables upstream basic authentication.
@@ -4374,6 +4376,33 @@
func (u *UpstreamOAuth) Fill(api apidef.UpstreamOAuth)
+type UpstreamRequestSigning struct {
+ // Enabled determines if request signing is enabled or disabled.
+ Enabled bool `bson:"enabled" json:"enabled"` // required
+ // SignatureHeader specifies the HTTP header name for the signature.
+ SignatureHeader string `bson:"signatureHeader,omitempty" json:"signatureHeader,omitempty"`
+ // Algorithm represents the signing algorithm used (e.g., HMAC-SHA256).
+ Algorithm string `bson:"algorithm,omitempty" json:"algorithm,omitempty"`
+ // KeyID identifies the key used for signing purposes.
+ KeyID string `bson:"keyId,omitempty" json:"keyId,omitempty"`
+ // Headers contains a list of headers included in the signature calculation.
+ Headers []string `bson:"headers,omitempty" json:"headers,omitempty"`
+ // Secret holds the secret used for signing when applicable.
+ Secret string `bson:"secret,omitempty" json:"secret,omitempty"`
+ // CertificateID specifies the certificate ID used in signing operations.
+ CertificateID string `bson:"certificateId,omitempty" json:"certificateId,omitempty"`
+}
+ UpstreamRequestSigning represents configuration for generating signed
+ requests to an upstream API.
+
+func (l *UpstreamRequestSigning) ExtractTo(api *apidef.APIDefinition)
+ ExtractTo populates the given apidef.APIDefinition RequestSigning fields
+ with values from the UpstreamRequestSigning.
+
+func (l *UpstreamRequestSigning) Fill(api apidef.APIDefinition)
+ Fill populates the UpstreamRequestSigning fields from the given
+ apidef.APIDefinition configuration.
+
type ValidateRequest struct {
// Enabled is a boolean flag, if set to `true`, it enables request validation.
Enabled bool `bson:"enabled" json:"enabled"` |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
8ca39c9
to
35c23c3
Compare
|
User description
TT-11908
This PR adds request signing to OAS upstream authentication. It also refactors the validation of the request signing config in the request signing middleware.
Types of changes
PR Type
Enhancement, Tests
Description
Added HMAC request signing for OAS upstream authentication.
Introduced validation for request signing configuration.
Updated schema to include request signing properties.
Added comprehensive unit tests for request signing functionality.
Changes walkthrough 📝
oas_test.go
Updated test expectations for request signing fields
apidef/oas/oas_test.go
upstream_test.go
Added tests for upstream request signing functionality
apidef/oas/upstream_test.go
UpstreamRequestSigning
functionality.Fill
andExtractTo
methods with test cases.mw_request_signing_test.go
Added tests for request signing configuration validation
gateway/mw_request_signing_test.go
upstream.go
Added request signing support to upstream authentication
apidef/oas/upstream.go
RequestSigning
configuration toUpstreamAuth
.Fill
andExtractTo
methods for request signing.mw_request_signing.go
Refactored request signing validation logic
gateway/mw_request_signing.go
x-tyk-api-gateway.json
Updated schema to include request signing configuration
apidef/oas/schema/x-tyk-api-gateway.json
X-Tyk-UpstreamRequestSigning
schema definition.X-Tyk-UpstreamAuthentication
to include request signing.