1

My question is, what is the good practice of choosing the right mapping types for login, logout and register endpoints, in my situation (described below).

I am writing project with the following technology stack

  • MySql (Hibernate ORM)
  • Spring Boot (with rest controllers: Restful api)
  • AngularJS (view technology)
  • Spring security with JWT tokens

my authentication controller has the following endpoints:

  • register - if user with the given username doesn't exist, then register user with given credentials, set authentication to the authentication manager, return JWT authentication token in the header of http response, return http status OK, otherwise (user already exist) 409 Conflict
  • login - if login credentials are correct, then set authentication to the authentication manager, return JWT authentication token in the header of http response, return http status OK, otherwise 401 Unauthorized
  • logout - if user with given credentials is registered in the authentication manager, then remove it from there, return http status OK, otherwise 205 No content

for register endpoint I know that I should use POST mapping, but for login and logout I believe that I should not use GET mapping, as they are making changes in the authentication manager.

aydinugur
  • 1,208
  • 2
  • 14
  • 21
haykart
  • 957
  • 5
  • 14
  • 34

1 Answers1

0

A little late to the party, but in case someone gets here...

For login and logout you should use POST

GET was the way to go years ago, but nowadays the covention is to use POST

See this answer and read the comments

Matías Cánepa
  • 5,770
  • 4
  • 57
  • 97