Skip to content
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

Are API keys still not supported? #44

Open
jkatagi opened this issue Jan 18, 2023 · 1 comment
Open

Are API keys still not supported? #44

jkatagi opened this issue Jan 18, 2023 · 1 comment

Comments

@jkatagi
Copy link

jkatagi commented Jan 18, 2023

Hi, I know that when we want to add an API key to an API Gateway method, we can do so by passing apiKeyRequired: true to addMethod in @aws-cdk/aws-apigateway.

declare const integration: apigateway.LambdaIntegration;

const api = new apigateway.RestApi(this, 'hello-api');

const v1 = api.root.addResource('v1');
const echo = v1.addResource('echo');
const echoMethod = echo.addMethod('GET', integration, { apiKeyRequired: true });

const plan = api.addUsagePlan('UsagePlan', {
  name: 'Easy',
  throttle: {
    rateLimit: 10,
    burstLimit: 2
  }
});

const key = api.addApiKey('ApiKey');
plan.addApiKey(key);

But I couldn't find the same way in this library.
Are API keys still not supported?
It would be wonderful if we could do the following.

new openapix.Api(scope, 'SomeApi', {
  source: 'path/to/yaml',
  paths: {
    '/some': {
       get: new openapix.LambdaIntegration(scope, lambdaFn, {
          apiKeyRequired: true
      }),
    },
  },
....

Here is the sample from the Open API document, however, this was not enough to set the API key.

openapi: 3.0.0
    paths:
      /something:
        get:
          # Operation-specific security:
          security:
            - ApiKeyAuth: []
          responses:
            '200':
              description: OK (successfully authenticated)
# 1) Define the key name and location
components:
  securitySchemes:
    ApiKeyAuth:        # arbitrary name for the security scheme
      type: apiKey
      in: header       # can be "header", "query" or "cookie"
      name: X-API-KEY  # name of the header, query parameter or cookie
# 2) Apply the API key globally to all operations
security:
  - ApiKeyAuth: []     # use the same name as under securitySchemes
@Hassaan68
Copy link

hi @jkatagi , are you able to solve this issue ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants