Add logout endpoint

master
esensar 2017-06-01 21:52:09 +02:00
parent 281930e3a0
commit 41339cf26a
2 changed files with 9 additions and 0 deletions

View File

@ -61,6 +61,14 @@ public class AuthenticationController {
}
}
@RequestMapping(path = "/accesstoken/{token}", method = RequestMethod.DELETE)
public ResponseEntity<?> removeToken(@PathVariable String token) {
tokenStore.removeToken(token);
return ResponseEntity
.noContent()
.build();
}
@RequestMapping(path = "/accesstoken/{token}", method = RequestMethod.GET)
public ResponseEntity<?> validateToken(@PathVariable String token) {
if (tokenStore.isValidToken(token)) {

View File

@ -36,6 +36,7 @@ public class BasicTokenStore implements TokenStore {
// Token is invalid, it has expired
if(basicToken.saveTime + ttl < CalendarUtils.getUTCCalendar().getTimeInMillis()) {
tokenStore.remove(token);
return false;
}