2
2
searchable : false
3
3
---
4
4
5
+ import { Callout } from ' @theguild/components'
6
+
5
7
# AWS Signature Version 4 (SigV4)
6
8
7
9
Hive Gateway allows you to sign subgraph requests with
@@ -26,14 +28,14 @@ flowchart TD
26
28
27
29
### How to use?
28
30
29
- You can enable AWS SigV4 signing by setting the ` awsSigV4 .outgoing` option to ` true ` in the Gateway
31
+ You can enable AWS SigV4 signing by setting the ` awsSigv4 .outgoing` option to ` true ` in the Gateway
30
32
configuration.
31
33
32
34
``` ts filename="gateway.config.ts"
33
35
import { defineConfig } from ' @graphql-hive/gateway'
34
36
35
37
export const gatewayConfig = defineConfig ({
36
- awsSigV4 : {
38
+ awsSigv4 : {
37
39
outgoing: true
38
40
}
39
41
})
@@ -48,7 +50,7 @@ you can also provide the credentials directly in the configuration.
48
50
import { defineConfig } from ' @graphql-hive/gateway'
49
51
50
52
export const gatewayConfig = defineConfig ({
51
- awsSigV4 : {
53
+ awsSigv4 : {
52
54
outgoing: {
53
55
accessKeyId: process .env .AWS_ACCESS_KEY_ID ,
54
56
secretAccessKey: process .env .AWS_SECRET_ACCESS_KEY ,
@@ -66,7 +68,7 @@ You can provide the `roleArn` and `roleSessionName` to assume a role using the p
66
68
import { defineConfig } from ' @graphql-hive/gateway'
67
69
68
70
export const gatewayConfig = defineConfig ({
69
- awsSigV4 : {
71
+ awsSigv4 : {
70
72
outgoing: {
71
73
region: process .env .AWS_REGION ,
72
74
// By default it takes the credentials from the environment variables
@@ -77,6 +79,28 @@ export const gatewayConfig = defineConfig({
77
79
})
78
80
```
79
81
82
+ #### Other credential providers
83
+
84
+ You can use AWS SDK's credential providers from
85
+ [ ` @aws-sdk/credential-providers ` ] ( https://www.npmjs.com/package/@aws-sdk/credential-providers ) such
86
+ as SSO support etc.
87
+
88
+ ``` ts filename="gateway.config.ts"
89
+ import { fromNodeProviderChain } from ' @aws-sdk/credential-providers'
90
+ import { defineConfig } from ' @graphql-hive/gateway'
91
+
92
+ export const gatewayConfig = defineConfig ({
93
+ awsSigv4: {
94
+ outgoing: fromNodeProviderChain ()
95
+ }
96
+ })
97
+ ```
98
+
99
+ <Callout >
100
+ Learn more about the available credential providers in the [ AWS SDK for JavaScript v3
101
+ documentation] ( https://www.npmjs.com/package/@aws-sdk/credential-providers ) .
102
+ </Callout >
103
+
80
104
### Service and region configuration
81
105
82
106
By default, the plugin extracts the service and region from the URL of the subgraph. But you can
@@ -86,7 +110,7 @@ also provide the service and region directly in the configuration.
86
110
import { defineConfig } from ' @graphql-hive/gateway'
87
111
88
112
export const gatewayConfig = defineConfig ({
89
- awsSigV4 : {
113
+ awsSigv4 : {
90
114
outgoing: {
91
115
accessKeyId: process .env .AWS_ACCESS_KEY_ID ,
92
116
secretAccessKey: process .env .AWS_SECRET_ACCESS_KEY ,
@@ -100,14 +124,14 @@ export const gatewayConfig = defineConfig({
100
124
101
125
### Subgraph-specific configuration
102
126
103
- You can also configure the SigV4 signing for specific subgraphs by setting the ` awsSigV4 ` option in
127
+ You can also configure the SigV4 signing for specific subgraphs by setting the ` awsSigv4 ` option in
104
128
the subgraph configuration.
105
129
106
130
``` ts filename="gateway.config.ts"
107
131
import { defineConfig } from ' @graphql-hive/gateway'
108
132
109
133
export const gatewayConfig = defineConfig ({
110
- awsSigV4 : {
134
+ awsSigv4 : {
111
135
// Allowing SigV4 signing for only the 'products' subgraph
112
136
outgoing : subgraph => subgraph === ' products'
113
137
}
@@ -120,7 +144,7 @@ or you can provide the credentials directly per subgraph.
120
144
import { defineConfig } from ' @graphql-hive/gateway'
121
145
122
146
export const gatewayConfig = defineConfig ({
123
- awsSigV4 : {
147
+ awsSigv4 : {
124
148
// Providing AWS SigV4 credentials for the 'products' and 'users' subgraphs separately
125
149
// And do not allow SigV4 signing for any other subgraph
126
150
outgoing(subgraph ) {
@@ -159,7 +183,7 @@ configuration.
159
183
import { defineConfig } from ' @graphql-hive/gateway'
160
184
161
185
export const gatewayConfig = defineConfig ({
162
- awsSigV4 : {
186
+ awsSigv4 : {
163
187
incoming: {
164
188
// Hard-coded secret
165
189
secretAccessKey : () => process .env .AWS_SECRET_ACCESS_KEY ,
@@ -187,7 +211,7 @@ authentication, otherwise, the request will be validated with AWS SigV4.
187
211
import { defineConfig } from ' @graphql-hive/gateway'
188
212
189
213
export const gatewayConfig = defineConfig ({
190
- awsSigV4 : {
214
+ awsSigv4 : {
191
215
incoming: {
192
216
enabled : (request , context ) =>
193
217
! (' jwt' in context ) && ! request .headers .get (' authorization' )?.startsWith (' Bearer' )
0 commit comments