Comments (3)
Sorry, looks like this is supported, just not documented? https://github.com/alma-cdk/openapix/blob/347ff3ae8f3b81645a923d2fcb4e2a72d682fe9a/src/x-amazon-apigateway/auth.ts
from openapix.
Hi!
Yes, IAM Authentication (Signature v4 or SigV4
for short) is something we definitely want to support as we're using it internally as well.
The way we intent to support SigV4
is that you should define it mostly as part of the OpenAPI definition as that is also an API client concern:
components:
securitySchemes:
sigv4:
type: "apiKey"
name: "Authorization"
in: "header"
But this still means there should be a way to inject the x-amazon-apigateway-authtype: "awsSigv4"
field into the components.securitySchemes.sigv4
object.
Currently this could be solved by using injections.
Then once the Sigv4
security scheme has been defined, all the methods using it must have the security object in them:
security:
- sigv4: []
And additionally as you pointed out the x-amazon-apigateway-auth
object should be injected into the method. Unfortunately this has not yet been fully implemented.
Also the whole setup (as described above) with Sigv4 is a bit of an mess currently.
We'll need do plan/design it a bit more and implement it.
from openapix.
Currently this could be solved by using injections.
Your comment and this article helped me to confirm that IAM authentication can be set up with the following implementation.
I hope this information will be of help to this lib authors and/or those who wish to have this feature.
import type { Paths } from '@alma-cdk/openapix';
import { Api, LambdaIntegration } from '@alma-cdk/openapix';
const paths = {
'/some/api/path1': {
get: new LambdaIntegration(stack, lambdaGetFunc1),
post: new LambdaIntegration(stack, lambdaPostFunc1),
},
'/some/api/path2': {
delete: new LambdaIntegration(stack, lambdaDeleteFunc2),
get: new LambdaIntegration(stack, lambdaGetFunc2),
put: new LambdaIntegration(stack, lambdaPutFunc2),
},
...
} satisfies Paths;
const api = new Api(stack, `${stack.stackName}-API`, {
source: '/path/to/schema.yml',
injections: {
'components.securitySchemes.sigv4': {
in: 'header',
name: 'Authorization',
type: 'apiKey',
'x-amazon-apigateway-authtype': 'awsSigv4',
},
...Object.entries(paths).reduce((obj, [path, integrations]) => {
for (const method of Object.keys(integrations)) {
obj[`paths.${path}.${method}.security[0].sigv4`] = [];
}
return obj;
}, {} as Record<string, object>),
},
restApiProps: {
...
},
}
from openapix.
Related Issues (20)
- Additional Language Support
- Lambda PrincipalWithConditions error when using CDK 2.30.0 HOT 2
- Cannot define x-amazon-apigateway-endpoint-configuration using openapix directly
- defaultCors is written to root of the document and set with key xAmazonApigatwayIntegration
- 0.0.38 cannot be installed using npm 8 HOT 1
- Top level descriptors on path HOT 2
- Is Lambda Authorizer supported? HOT 4
- Support scopes with Lambda Authorizer HOT 1
- OPTIONS method with CorsIntegration returns HTTP 500 "Internal server error" HOT 1
- CorsIntegration does not return Access-Control-Allow-Origin="*" HOT 1
- Resources defined outside of OpenApi spec disappears from API Gateway HOT 2
- Are API keys still not supported? HOT 1
- Allow for support of multiple sources HOT 1
- Write tests for all scenarios of Definition class HOT 1
- Fix issues with defaultCors
- Reporting a vulnerability HOT 1
- Paths not properly implemented in python module. HOT 1
- Stages HOT 1
- [Feature Request] Support API Definition from S3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapix.