Comments (6)
I've implemented these changes. You can now cast the Principal field to CognitoUserPoolPrincipal
and call the getClaims()
method to extract all of the claims in the token. I have also added support for custom claims in the object. You can get custom claims using the getClaim(String key)
method of the CognitoAuthorizerClaims
object.
Resolving the issue.
from aws-serverless-java-container.
This is possible today by creating a custom SecurityContextWriter
and passing it to the library.
We could solve this easily by giving you an easy way to inject the security context writer without having to manually create the full object constructor, perhaps just add it as a parameter to the static getAwsProxyHandler
?
from aws-serverless-java-container.
We discussed this offline. We see two option:
- Create a new
HandlerMethodArgumentResolver
for Spring and aContextResolver
in Jersey. All you'd have to do then is:
@RequestMapping(path = "/pets", method = RequestMethod.POST)
public Pet createPet(@RequestBody Pet newPet, ApiGatewayAuthorizerContext context) {
...
}
- Extend the Principal interface with a few methods to access the additional properties of the authorization context from API Gateway:
public Pet createPet(@RequestBody Pet newPet, Principal principal) {
((CognitoUserPoolPrincipal)principal).getClaims();
}
Would love to hear from the community what the preferred option is.
from aws-serverless-java-container.
Since there is no feedback and this is not a high priority fix I'm pulling it out of 0.7. The data is still accessible through the request attributes.
from aws-serverless-java-container.
I'm not a user of Spring or Jersey, so I see a lot of benefit in option 2
from aws-serverless-java-container.
I think option 2, as much as I hate casting or doing instanceof, is the most consistent with Spring Security. this also seems to be backward compatible.
from aws-serverless-java-container.
Related Issues (20)
- Reinitialization of Spring context when using SnapStart HOT 3
- Spring Cloud Gateway throwing "hostname can't be null" based on my request only having headers and not multi-value headers HOT 4
- ServletContext: Servlet.getServletConfig() is null HOT 1
- Cannot invoke "org.springframework.web.servlet.DispatcherServlet.getServletContext()" because "servlet" is null HOT 4
- org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: No content to map due to end-of-input HOT 1
- org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: No content to map due to end-of-input HOT 8
- Cannot deserialize value of type `java.lang.String` from Object value HOT 3
- SpringDelegatingLambdaContainerHandler unable to respond with rendered templates HOT 10
- SpringDelegatingLambdaContainerHandler does not handle Headers correctly for FunctionUrls HOT 7
- Cookies not able to be deleted by setting max-age to 0 HOT 3
- com.amazonaws.serverless.exceptions.InvalidRequestEventException: The incoming event is not a valid request from Amazon API Gateway or an Application Load Balancer HOT 2
- 2.x release HOT 1
- AwsProxyResponse class is generating response JSON which is rejected by API gateway with Malformed error HOT 3
- Moved AwsProxyRequestBuilder into test package HOT 4
- How to handle spring security with springboot serverless HOT 2
- Null Pointer While Setting Filter Post Startup Lambda Handler HOT 2
- Spring boot 3 context initialization issue when using with a servlet application having webflux dependency for web client HOT 3
- Error with version 2.0.2 when multi-value header is active in alb HOT 6
- Springboot 2 Lambda Layer Support HOT 2
- Query parameter values not URL decoded when using HTTP API V2 Gateway with a RequestStreamHandler implementation HOT 2
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 aws-serverless-java-container.