How to verify JWT from AWS Cognito in the API backend?

后端 未结 10 554
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-12 11:17

I\'m building a system consisting of an Angular2 single page app and a REST API running on ECS. The API runs on .Net/Nancy, but that might well change.

I would like

10条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 11:33

    Turns out I didn't read the docs right. It's explained here (scroll down to "Using ID Tokens and Access Tokens in your Web APIs").

    The API service can download Cognito's secrets and use them to verify received JWT's. Perfect.

    Edit

    @Groady's comment is on point: but how do you validate the tokens? I'd say use a battle-tested library like jose4j or nimbus (both Java) for that and don't implement the verification from scratch yourself.

    Here's an example implementation for Spring Boot using nimbus that got me started when I recently had to implement this in java/dropwizard service.

提交回复
热议问题