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

Add support for an authorizer property to the rest-api component #204

Closed
brianneisler opened this issue May 14, 2018 · 1 comment
Closed
Assignees
Labels
good first issue Good for newcomers kind/feature New feature stage/accepted This is ready to be worked on

Comments

@brianneisler
Copy link
Contributor

brianneisler commented May 14, 2018

Description

It would be great to have support for authorizers in the rest-api component. Our rest-api component dynamically creates either an aws-apigateway under the hood or an event-gateway depending upon the gateway input.

https://github.com/serverless/components/blob/master/registry/rest-api/index.js#L162-L166

For now, we can only add support for this authorizer property to the api-gateway portion until we add support for authorizers to the event-gateway.

The aws-apigateway component is built using the importRestApi method in the sdk which uses swagger to define the api.

https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#importRestApi-property

The component takes in the inputs and converts them into a swagger definition.

https://github.com/serverless/components/blob/master/registry/aws-apigateway/index.js#L24-L27

The implementation would use the api gateway swagger extensions for adding authorizers to an api.

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions-authorizer.html

An example of what the final implementation would look like to use.

type: my-api
version: 0.0.1

components:
  createData:
    type: aws-lambda
    inputs:
      handler: index.create
      root: ${self.path}/code
  myAuthorizer:
    type: aws-lambda
    inputs:
      handler: index.authorizer
      root: ${self.path}/code

  myApi:
    type: rest-api
    inputs:
      gateway: aws-apigateway
      routes:
        /create:
          post:
            function: ${createFakerData}
            authorizer: ${myAuthorizer}  # this can also be an arn or another type of authorizer
            cors: true
@brianneisler brianneisler added good first issue Good for newcomers kind/feature New feature stage/accepted This is ready to be worked on labels May 14, 2018
@eahefnawy
Copy link
Member

closing this as we've made a complete rewrite of the core and this issue is no longer applicable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers kind/feature New feature stage/accepted This is ready to be worked on
Projects
None yet
Development

No branches or pull requests

3 participants