2

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.

Roper
  • 109
  • 5

1 Answers1

1

There is a offline emulator for Cognito

https://github.com/jagregory/cognito-local

Have no experience with it, but i recommend to give em a shot

IEE1394
  • 1,181
  • 13
  • 33
  • 1
    Thanks for the info. As far as I understand the emulator, it helps with calls of my application to cognito. My problem is more like, logging into cognito from postman to get valid requests. I am also ok with logging into my cloud cognito, I don't necessarily have to develop offline. – Roper Jan 30 '22 at 19:19