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

Serverless config with IP whitelist and fallback to basic auth #6795

Open
0is1 opened this issue Oct 7, 2019 · 2 comments

Comments

@0is1
Copy link

commented Oct 7, 2019

Hello! I've been struggling with the following problem: how to configure serverless with IP whitelist authorizing and fallback to BasicAuth (to root path) if IP doesn't match to whitelist?

It's quite easy to add IP whitelist authorizing (https://github.com/0is1/nextjs-serverless-test/blob/master/serverless.yml#L23-L34). And it's also quite easy to add BasicAuth (or any Authorizer in general) to all other paths than your app root (like https://serverless.com/framework/docs/providers/aws/events/apigateway#http-endpoints-with-custom-authorizers). But how to combine those two with serverless + AWS Cloud​Formation configs?

It's also possible to add Authorizer manually to any resource method in Amazon API Gateway dashboard but I want to do that via serverless config (if it's possible?)

I've created test repo about the progress so far https://github.com/0is1/nextjs-serverless-test

There's next.js app "on the background" because that's the case with my actual project as well but it's not relevant in this context.

Thanks in advance for your help.

Edit: should I actually post this question to stackoverflow? Or what's the policy with questions in issues here?

@neverendingqs

This comment has been minimized.

Copy link
Contributor

commented Oct 12, 2019

@0is1 - have you already considered using an custom authorizer lambda function? https://serverless.com/framework/docs/providers/aws/events/apigateway#http-endpoints-with-custom-authorizers

@0is1

This comment has been minimized.

Copy link
Author

commented Oct 14, 2019

@0is1 - have you already considered using an custom authorizer lambda function? https://serverless.com/framework/docs/providers/aws/events/apigateway#http-endpoints-with-custom-authorizers

@neverendingqs yes, but you can't configure your app root path with that logic. One of my questions is that is it possible to add authorizer for root path.

I mean this is not possible

events:
      - http:
          path: /
          method: get
          authorizer: authorizerFunc

EDIT: actually it seems that config above is possible but serverless-nextjs-plugin just does something that break it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.