How can I delete Authentication parameter from swagger in spring boot?

Viewed 341

I had a spring boot project that uses both spring security and swagger UI.

The Main problem is when i use Authentication in parameter of controller method like this

    @PutMapping("/")
    public UserRestDTo update(Authentication auth, @RequestBody UserRestDTo user) {
        ...
    }

I got the Authentication object in the request parameter of swagger-UI like this swagger result

  • first: Is this a bug in swagger?
  • second: is there any security problem that can affect my project?
  • third: how to remove the Authentication object from the request?

finally: thanks for the help:D.

1 Answers

I got a solution :

@PutMapping("/")
    public UserRestDTo update(@RequestBody UserRestDTo user) throws AbstractWebException {
        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
        ...
    }

but i steel need to know if is the old method can effect badly on the security of my project or it's just a swagger bug.

Related