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

randomly generated API key is not displayed if no API key is defined #832

Closed
christophgysin opened this issue Nov 5, 2019 · 4 comments
Closed
Labels

Comments

@christophgysin
Copy link
Contributor

Currently, serverless-offline checks if there is a apiKeys: section to decide if the randomly generated API key should be logged.

If we have a service that defines http events as private: true, but not define apiKeys, the generated API key is not logged.

frameworkVersion: '>=1.55.1 <2.0.0'
service: private
plugins:
  - serverless-offline
provider:
  name: aws
  runtime: nodejs10.x
functions:
  private:
    handler: private.handler
    events:
      - http:
          path: /private
          method: get
          private: true
$ npx sls offline
Serverless: Starting Offline: dev/us-east-1.

Serverless: Routes for private:

One workaround is to define an empty list of apiKeys:

provider:
  apiKeys: []
$ npx sls offline
Serverless: Starting Offline: dev/us-east-1.
Serverless: Key with token: sad8hj23f08werjf09sdfjv923v
Serverless: Remember to use x-api-key on the request headers

A better solution would be to check if there are any http events with private: true.

christophgysin added a commit to christophgysin/serverless-offline that referenced this issue Nov 5, 2019
@dnalborczyk
Copy link
Collaborator

hey @christophgysin thanks for opening this issue. I'm unfamiliar with private endpoints, nonetheless, it seems that private endpoints don't require api keys.

@christophgysin
Copy link
Contributor Author

Setting private: true is the serverless way of configuring an endpoint to require an API key. See:
https://serverless.com/framework/docs/providers/aws/events/apigateway/#setting-api-keys-for-your-rest-api

@dnalborczyk
Copy link
Collaborator

thank you for the link @christophgysin ! I'll have a look into your issue and the PR soon.

dnalborczyk pushed a commit that referenced this issue Nov 30, 2019
@dnalborczyk
Copy link
Collaborator

PR merged. closing.

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

No branches or pull requests

2 participants