jwt-token.uml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. @startuml
  2. /'Living Model of JSON Web Token (JWT)'/
  3. title "Living Model of JSON Web Token (JWT)"
  4. boundary User_Page as userpage
  5. participant Frontend_Server as frontend
  6. participant Backend_Server as backend
  7. database user_table
  8. entity pki_key_pair
  9. autonumber
  10. note over pki_key_pair #03c2fc
  11. <b>Public Key Infrastructure</b>
  12. public-key, secret_key, key_pair
  13. use libsodium or ECDSA or RSA
  14. libsodium recommended
  15. (prepare keys first)
  16. end note
  17. userpage->frontend: input user id & password
  18. frontend->backend: provide info when db created\njwt-get:{"UserId":"aa", "Passwd":"bb"}
  19. backend->user_table: get user id & password
  20. note over backend #fcdb03
  21. check user_id & passwd matches
  22. end note
  23. backend->pki_key_pair: get public_key
  24. note over backend #fcdb03
  25. encrypt user_id and expiration time
  26. with public_key into JWT
  27. end note
  28. backend->frontend: OK with JWT\n{"JwtToken": "zz" }
  29. note over frontend #fcdb03
  30. JWT being kept in Session until
  31. backend expiration period(24hours)
  32. end note
  33. note over frontend #bafc03
  34. [BEGINNIG OF Normal API REQUEST]
  35. end note
  36. /'6'/
  37. userpage->frontend: Normal Request
  38. note over frontend #fcdb03
  39. 1. Add HTML Request header
  40. req.Header.Add("P2u-Token", "zz")
  41. 2. send request with "P2u-Token" includes
  42. end note
  43. frontend->backend: normal request
  44. note over backend #fcdb03
  45. get P2u-Token from HTML header first
  46. end note
  47. backend-->pki_key_pair: get secret_key
  48. note over backend #fcdb03
  49. 1. decrypt JWT with secret_key to
  50. get user_id and expiration time
  51. 2. check if JWT expired
  52. end note
  53. backend-->frontend: return error msg with 505 status\nif decryption fails or JWT expired
  54. note over backend #fcdb03
  55. Proceed Normal Process
  56. end note
  57. /'10'/
  58. backend-->frontend: return normal Result
  59. note over frontend #bafc03
  60. [END OF Normal API REQUEST]
  61. end note
  62. frontend-->userpage: rendered views
  63. @enduml