Skip to content

Commit b1a6a42

Browse files
authored
Documentation for AWS Credentials Providers support (#6908)
1 parent 8ff04c5 commit b1a6a42

File tree

1 file changed

+34
-10
lines changed
  • packages/web/docs/src/content/gateway/other-features/security

1 file changed

+34
-10
lines changed

packages/web/docs/src/content/gateway/other-features/security/aws-sigv4.mdx

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
searchable: false
33
---
44

5+
import { Callout } from '@theguild/components'
6+
57
# AWS Signature Version 4 (SigV4)
68

79
Hive Gateway allows you to sign subgraph requests with
@@ -26,14 +28,14 @@ flowchart TD
2628

2729
### How to use?
2830

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
3032
configuration.
3133

3234
```ts filename="gateway.config.ts"
3335
import { defineConfig } from '@graphql-hive/gateway'
3436

3537
export const gatewayConfig = defineConfig({
36-
awsSigV4: {
38+
awsSigv4: {
3739
outgoing: true
3840
}
3941
})
@@ -48,7 +50,7 @@ you can also provide the credentials directly in the configuration.
4850
import { defineConfig } from '@graphql-hive/gateway'
4951

5052
export const gatewayConfig = defineConfig({
51-
awsSigV4: {
53+
awsSigv4: {
5254
outgoing: {
5355
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
5456
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
6668
import { defineConfig } from '@graphql-hive/gateway'
6769

6870
export const gatewayConfig = defineConfig({
69-
awsSigV4: {
71+
awsSigv4: {
7072
outgoing: {
7173
region: process.env.AWS_REGION,
7274
// By default it takes the credentials from the environment variables
@@ -77,6 +79,28 @@ export const gatewayConfig = defineConfig({
7779
})
7880
```
7981

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+
80104
### Service and region configuration
81105

82106
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.
86110
import { defineConfig } from '@graphql-hive/gateway'
87111

88112
export const gatewayConfig = defineConfig({
89-
awsSigV4: {
113+
awsSigv4: {
90114
outgoing: {
91115
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
92116
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
@@ -100,14 +124,14 @@ export const gatewayConfig = defineConfig({
100124

101125
### Subgraph-specific configuration
102126

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
104128
the subgraph configuration.
105129

106130
```ts filename="gateway.config.ts"
107131
import { defineConfig } from '@graphql-hive/gateway'
108132

109133
export const gatewayConfig = defineConfig({
110-
awsSigV4: {
134+
awsSigv4: {
111135
// Allowing SigV4 signing for only the 'products' subgraph
112136
outgoing: subgraph => subgraph === 'products'
113137
}
@@ -120,7 +144,7 @@ or you can provide the credentials directly per subgraph.
120144
import { defineConfig } from '@graphql-hive/gateway'
121145

122146
export const gatewayConfig = defineConfig({
123-
awsSigV4: {
147+
awsSigv4: {
124148
// Providing AWS SigV4 credentials for the 'products' and 'users' subgraphs separately
125149
// And do not allow SigV4 signing for any other subgraph
126150
outgoing(subgraph) {
@@ -159,7 +183,7 @@ configuration.
159183
import { defineConfig } from '@graphql-hive/gateway'
160184

161185
export const gatewayConfig = defineConfig({
162-
awsSigV4: {
186+
awsSigv4: {
163187
incoming: {
164188
// Hard-coded secret
165189
secretAccessKey: () => process.env.AWS_SECRET_ACCESS_KEY,
@@ -187,7 +211,7 @@ authentication, otherwise, the request will be validated with AWS SigV4.
187211
import { defineConfig } from '@graphql-hive/gateway'
188212

189213
export const gatewayConfig = defineConfig({
190-
awsSigV4: {
214+
awsSigv4: {
191215
incoming: {
192216
enabled: (request, context) =>
193217
!('jwt' in context) && !request.headers.get('authorization')?.startsWith('Bearer')

0 commit comments

Comments
 (0)