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 class  AuthController.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 401
    org.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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • 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 id
      access - 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