An ebook/comic library service and web client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

160 lines
4.5 KiB

  1. Authentication API
  2. ==================
  3. .. http:post:: /auth/login
  4. Authenticate with the server and receive a userToken for requests.
  5. **Example request**:
  6. .. sourcecode:: http
  7. POST /auth/login HTTP/1.1
  8. Host: example.tld
  9. Accept: application/json
  10. Authorization: Basic <Base64 Encoded Basic Auth>
  11. **Example response**:
  12. .. sourcecode:: http
  13. HTTP/1.1 200 OK
  14. Vary: Accept
  15. Content-Type: application/json
  16. {
  17. "creationTime": "2018-07-29T11:59:29-05:00",
  18. "enabled": true,
  19. "token": "b94cf5c7-cddc-4610-9d4c-6b8e04088ae8",
  20. "version": 0
  21. }
  22. **Example request with note and expirationTime**
  23. .. sourcecode:: http
  24. POST /auth/login HTTP/1.1
  25. Host: example.tld
  26. Accept: application/json
  27. Authorization: Basic <Base64 Encoded Basic Auth>
  28. Content-Type: application/json
  29. {
  30. "note": "Client API Access",
  31. "expirationTime": "2019-07-29T23:59:59-05:00"
  32. }
  33. **Example response**:
  34. .. sourcecode:: http
  35. HTTP/1.1 200 OK
  36. Vary: Accept
  37. Content-Type: application/json
  38. {
  39. "note": "Client API Access",
  40. "expirationTime": "2019-07-29T23:59:59-05:00",
  41. "creationTime": "2018-07-29T11:59:29-05:00",
  42. "enabled": true,
  43. "token": "b94cf5c7-cddc-4610-9d4c-6b8e04088ae8",
  44. "version": 0
  45. }
  46. :<header Accept: Response content type depends on :mailheader:`Accept` header
  47. :<header Authorization: Encoded basic authorization
  48. :>header Content-Type: Depends on :mailheader:`Accept` header of request
  49. :>json datetime creationTime: Creation time for the userToken
  50. :>json datetime expirationTime: Expiration time for the userToken
  51. :>json boolean enabled: Whether the userToken is enabled
  52. :>json string token: UserToken to use for further authentication
  53. :>json int version: Version for the object
  54. :statuscode 200: User successfully logged in
  55. :statuscode 401: Authorization failed
  56. .. http:post:: /auth/bump
  57. Bump user login information.
  58. **Example request**:
  59. .. sourcecode:: http
  60. POST /auth/bump HTTP/1.1
  61. Host: example.tld
  62. Accept: application/json
  63. Authorization: Bearer <Base64(user:userToken)>
  64. **Example response**:
  65. .. sourcecode:: http
  66. HTTP/1.1 200 OK
  67. Vary: Accept
  68. Content-Type: application/json
  69. {
  70. "lastLoginTime": "2018-07-29T12:15:51-05:00"
  71. }
  72. :<header Accept: Response content type depends on :mailheader:`Accept` header
  73. :<header Authorization: Encoded token authorization
  74. :>header Content-Type: Depends on :mailheader:`Accept` header of request
  75. :>json datetime lastLoginTime: Updated lastLoginTime for the user
  76. :statuscode 200: User last_login_time successfully bumped
  77. :statuscode 401: Authorization failed
  78. .. http:post:: /auth/logout
  79. Logout a user and remove the provided userToken from valid tokens.
  80. **Example request**:
  81. .. sourcecode:: http
  82. POST /auth/logout HTTP/1.1
  83. Host: example.tld
  84. Accept: application/json
  85. Authorization: Bearer <Base64(user:userToken)>
  86. **Example response**:
  87. .. sourcecode:: http
  88. HTTP/1.1 200 OK
  89. Vary: Accept
  90. Content-Type: application/json
  91. {
  92. "success": true
  93. }
  94. :<header Accept: Response content type depends on :mailheader:`Accept` header
  95. :<header Authorization: Rncoded token authorization
  96. :>header Content-Type: Depends on :mailheader:`Accept` header of request
  97. :>json boolean success: Whether the logout was successful
  98. :statuscode 200: User successfully logged out
  99. :statuscode 401: Authorization failed
  100. Authentication Object Models
  101. ============================
  102. .. json:object:: UserToken
  103. :showexample:
  104. UserToken definition
  105. :property token: The token value, used for authentication
  106. :proptype token: string
  107. :property note: Additional information about the token
  108. :proptype note: string
  109. :property enabled: Determine if a token will be accepted
  110. :proptype enabled: boolean
  111. :property expirationTime: The time that the token becomes invalid, regardless of enabled state
  112. :proptype expirationTime: iso8601
  113. :property creationTime: The time that the token was created
  114. :proptype creationTime: iso8601
  115. :property lastUsageTime: The time that the token was last used
  116. :proptype lastUsageTime: iso8601
  117. :property version: An identifier for the token version
  118. :proptype version: integer