Class AuthController
java.lang.Object
com.fredriksonsound.iot_backoffice_auth.endpoint.AuthController
@RestController
public class AuthController
extends java.lang.Object
Authentication api
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAuthController.AuthCredentials -
Constructor Summary
Constructors Constructor Description AuthController() -
Method Summary
Modifier and Type Method Description org.springframework.http.ResponseEntity<com.google.gson.JsonObject>loginWithCredentials(AuthController.AuthCredentials credentials)Logs a user using email and password combination.org.springframework.http.ResponseEntity<com.google.gson.JsonObject>logoutToken(java.lang.String refresh)logs a specified user out, deletes the corresponding refresh token responds 200 whether the token exists or not
API doc:
Description: logs a specified user out, deletes the corresponding refresh token responds 200 whether the token exists or not
Method: POST
Location: /auth/logout
Headers:
Refresh-Token: the refresh token to use
Success response: {status: "ok", message: "no such token"|"token deleted"}, CODE: 200
Error response: {status: "error", message: [error_message]}, 400 or 401org.springframework.http.ResponseEntity<com.google.gson.JsonObject>refreshAccessToken(java.lang.String refresh, java.lang.String access)Refreshes an access token using specified refresh token
API doc:
Description: Refreshes an access token using specified refresh token
Method: POST
Location: /users
Headers:
Refresh-Token: the refresh token to use
Auth-Token: the expired auth token
Success response: {status: "success", token: [token]}, CODE: 200
Error response: {status: "error", message: [error_message]}, 400 or 401
-
Constructor Details
-
AuthController
public AuthController()
-
-
Method Details
-
refreshAccessToken
@CrossOrigin(origins="*", allowedHeaders="*") @RequestMapping(value="/auth/refresh", method=POST) public org.springframework.http.ResponseEntity<com.google.gson.JsonObject> refreshAccessToken(@RequestHeader(value="Refresh-Token",required=false) java.lang.String refresh, @RequestHeader(value="Auth-Token",required=false) java.lang.String access)Refreshes an access token using specified refresh token
API doc:
Description: Refreshes an access token using specified refresh token
Method: POST
Location: /users
Headers:
Refresh-Token: the refresh token to use
Auth-Token: the expired auth token
Success response: {status: "success", token: [token]}, CODE: 200
Error response: {status: "error", message: [error_message]}, 400 or 401- Parameters:
refresh- the refresh token idaccess- the JWT access token- Returns:
- Json with token
-
loginWithCredentials
@CrossOrigin(origins="*", allowedHeaders="*") @RequestMapping(value="/auth/login", method=POST) public org.springframework.http.ResponseEntity<com.google.gson.JsonObject> loginWithCredentials(@RequestBody(required=false) AuthController.AuthCredentials credentials)Logs a user using email and password combination. Responds with a short lived access-token and id of long lived refresh-token
API doc:
Description: Logs a user using email and password combination
Method: POST
Location: /auth/login
Body:
{
email: [email],
password: [password],
}
Success response: {status: "success", data: {token, [token], refreshtoken: [refresh_token_id]}}, CODE: 201
Error response: {status: "error", message: [error_message]}, 400 or 401- Parameters:
credentials- the credentials to log in with- Returns:
- an access token and refresh token id on success, error on fail.
-
logoutToken
@CrossOrigin(origins="*", allowedHeaders="*") @RequestMapping(value="/auth/logout", method=POST) public org.springframework.http.ResponseEntity<com.google.gson.JsonObject> logoutToken(@RequestHeader(value="Refresh-Token",required=false) java.lang.String refresh)logs a specified user out, deletes the corresponding refresh token responds 200 whether the token exists or not
API doc:
Description: logs a specified user out, deletes the corresponding refresh token responds 200 whether the token exists or not
Method: POST
Location: /auth/logout
Headers:
Refresh-Token: the refresh token to use
Success response: {status: "ok", message: "no such token"|"token deleted"}, CODE: 200
Error response: {status: "error", message: [error_message]}, 400 or 401- Parameters:
refresh- the refresh token id associated with the session- Returns:
- OK or Bad request
-