benwilcock / spring-cloud-gateway-demo

Code and articles to help folks get started with Spring Cloud Gateway.
https://benwilcock.github.io/spring-cloud-gateway-demo/
Apache License 2.0
185 stars 123 forks source link

Method "@Postmapping" is giving 403 forbidden #5

Open grajuu opened 4 years ago

grajuu commented 4 years ago

Hi

GetMapping is working fine but Postmapping having issue 403 forbidden

// This working fine 
@GetMapping("/resource")
  public String resource(@AuthenticationPrincipal Jwt jwt) {
    LOG.trace("***** JWT Headers: {}", jwt.getHeaders());
    LOG.trace("***** JWT Claims: {}", jwt.getClaims().toString());
    LOG.trace("***** JWT Token: {}", jwt.getTokenValue());
    return String.format("Resource accessed by: %s (with subjectId: %s)" ,
            jwt.getClaims().get("user_name"),
            jwt.getSubject());
  }
// 403 forbidden 
@PostMapping("/message")
    public String createMessage(@RequestBody String message) {
        return String.format("Message was created. Content: %s", message);
    }

Please help me if am missing some thing . Thanks in advance.