I have recently taken over an existing Java REST API (written with Micronaut). The API is intended to be deployed on AWS, running "serverless" with Lambda and has Cognito for auth.
For dev, I obviously just want to just run the API locally and debug via Postman requests. As far as I understand it, Cognito is basically out of the picture here. However, the controllers are still using the name of the principal for some operations and I want to give it valid data.
Let's say my controller has a method like follows:
@Post
public HttpResponse<SomeResponse> createSomething(Principal principal, SomeRequest request) {
String username = principal.getName();
// ...
}
With the java.security.Principal
being a AwsProxySecurityContext
during runtime. How can I give a valid token/auth header in Postman so that getName
returns a string of my choice? I would be surprised if this cannot be done without going out to the real Cognito, as everything runs locally.