Comments (2)
Hi @spinscale ,
There are multiple ways to accomplish this:
- if you just don't want to mange users, Cognito User Pool might be interesting for you. You can protect API endpoints with a Cognito User Pool Authorizer. In case of JRestless >=0.5.0 CognitoUserPoolAuthorizerPrincipal will be set as principal. See the example aws-gateway-security-cognito-authorizer. You, however, cannot integrate any other providers.
- what you most likely want to do is to set up a custom authorizer function, like in the example: aws-gateway-security-custom-authorizer. In contrast to the example, however, your authorizer function would verify the twitter/github/amazon token. In case you want to make your life a little easier, use auth0 which integrates with the major providers. You can find an example for such a custom auth0 authorizer here: https://github.com/serverless/examples/blob/master/aws-node-auth0-custom-authorizers-api/handler.js but even without using auth0 it boils down to verifying the JWT token's signature which can be a little tricky: https://developers.google.com/identity/protocols/OpenIDConnect#validatinganidtoken but there are libraries for this, too, I guess. In case of JRestless >=0.5.0 CustomAuthorizerPrincipal will be set as principal.
- if and only if you invoke your endpoints through the API Gateway SDK you might want to take a look at Cognito Federated Identites which integrates with all major providers. In case of JRestless >= 0.5.1 CognitoIdentityPrincipal will be set as principal. I am working on an example for this but it's a little tricky and uncommon on Web, and I am very short on time right now.
And last but not least the way AWS implemented those authorizers there is some issue with CORS:
You cannot setup any CORS headers which is an issue if the authorizer fails: https://forum.serverless.com/t/how-to-enable-cors-for-custom-authorizers-aws-api-gateways/1660
In case this is an issue for you, you might want to pull in the authorization into some ContainerRequestFilter (JAX-RS) within your application.
Hope this helps.
from jrestless.
closing since inactive (please re-open if required)
from jrestless.
Related Issues (20)
- Problem serializing Response when deployed to AWS Lambda HOT 7
- Question - Run dropwizard applications with jrestless on aws lambda HOT 1
- Use RequestAndBaseUri in SNS and Service Functions
- Add CORS Filter
- Contribute HOT 3
- DefaultGatewayRequest declared as final does not work with CDI HOT 1
- Weld integration HOT 11
- onRequestFailure is never called HOT 3
- CHANGELOG not updated for 0.5.0 HOT 2
- Add IAM Security Filter and Principal
- clarify logging support HOT 2
- Can I use both SNS trigger and API Gateway in same application? HOT 2
- exceptions' stacktraces do not include the first line HOT 5
- Add support for Azure HOT 3
- jrestless incompatible with jersey 2.26 HOT 3
- Add support for Project Fn HOT 2
- Upgrade To JUnit 5
- Progress on dropwizard applications with jrestless on aws lambda? HOT 1
- Running locally HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jrestless.