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

Issue with shared authorizers #107

Open
AdriaFret opened this issue Nov 24, 2022 · 4 comments
Open

Issue with shared authorizers #107

AdriaFret opened this issue Nov 24, 2022 · 4 comments

Comments

@AdriaFret
Copy link

Hello! We are having some troubles trying to implement the lambdaAuthorizer in the swagger endpoints. We have a microservices architechture, our authorizer is in a separated microservice and we can use this authorizer ( via output variable) in our lambdas. Here is a code snipet of how we use this authorizer in our lambdas:

image

The idea that we had is to reuse this authorizer for the lambdaAuthorizer section but we can't figure it out why it ain't working (maybe we are missunderstanding or doing something wrong).

Thank you for your time in advance.

@bfaulk96
Copy link
Collaborator

Could you please show your serverless-auto-swagger custom config in your Serverless file?

@AdriaFret
Copy link
Author

Yes for sure, thats how we tried to configure it but we couldn't figure it out a way to make it work:
image

@bfaulk96
Copy link
Collaborator

bfaulk96 commented Dec 19, 2022

Could you try making lambdaAuthorizer the same object that you're using in your http events, i.e.

custom:
  ...
  customAuthorizer:
    type: COGNITO_USER_POOLS
    authorizerId: !ImportValue authorizer
  autoswagger:
    ...
    lambdaAuthorizer: ${self:custom.customAuthorizer}

functions:
  ...
  test:
    ...
    events:
      - http:
          ...
          authorizer: ${self:custom.customAuthorizer}

This was my use-case when I added this feature. If this doesn't work, I honestly don't know a ton about authorizers, so I don't know if more complex scenarios are possible.

(also, careful with the indentation in my example – treat that as pseudo-code, as I simply typed it up in GitHub markdown code)

@arijitsarkar2k14
Copy link

I have tried the same. But after running sls offline start, it is generated swagger.js file with "securityDefinitions": {}, and hence my custom authorizer is not working in the swagger UI

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

3 participants