-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- The JWT authentication token will now expire at a given date. After that date, if a resource is accessed by suppling an expired token, a 401 Unauthorized response code will be returned, and a new token will have to be created with the 'dni' and 'password' credentials. The current expiration date for the token is 1 DAY from its creation. - A unique JWT authentication token will be returned every time a POST is commited to /api/v1/login with the same credentials. This occurs because it is using the expiration date/time as a part of the token. It is not assured that the token will be unique every time, but it is unlikely to happen.
- Loading branch information
Showing
3 changed files
with
73 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 12 additions & 3 deletions
15
webapp/src/main/java/ar/edu/itba/paw/webapp/auth/TokenHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
package ar.edu.itba.paw.webapp.auth; | ||
|
||
import org.springframework.security.core.userdetails.UserDetails; | ||
|
||
interface TokenHandler { | ||
String createToken(UserDetails user); | ||
/** | ||
* Returns a new token used for further authentication and authorization | ||
* @param username the username that may be used to create the token | ||
* @return the token | ||
*/ | ||
String createToken(String username); | ||
|
||
/** | ||
* Returns the username | ||
* @param token | ||
* @return the username contained in the token; | ||
* null if there was an error when trying to get the username from the token | ||
*/ | ||
String getUsername(String token); | ||
} |