{"id":387151,"date":"2024-06-29T07:09:28","date_gmt":"2024-06-29T07:09:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=387151"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=387151","title":{"rendered":"<span>\u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c Private Routes \u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 JWT token<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>1. \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 JWT token<\/h2>\n<p>JWT token (\u043e\u043d \u0436\u0435 <em>JSON Web Token<\/em>) &#8212; \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438\u0437 \u0442\u0440\u0435\u0445 \u0447\u0430\u0441\u0442\u0435\u0439: \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044c.<\/p>\n<p>\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u0441\u0430\u0439\u0442\u0430 \u0445\u043e\u0447\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0443. \u041e\u043d \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0434\u0438\u0430\u043b\u043e\u0433\u0430\u043c\u0438, \u0438 \u0441\u0430\u0439\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 (\u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439), \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 &#8212; JWT \u0442\u043e\u043a\u0435\u043d.  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0438 \u0440\u0435\u0448\u0430\u0435\u0442, \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043b\u0438 \u0435\u043c\u0443 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0441\u0430\u0439\u0442\u0430 (\u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439).  <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/45a\/0f6\/44b\/45a0f644bb842529959221cea62b46cc.jpg\" alt=\"https:\/\/jwt.io\/ - \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 2 \u0447\u0430\u0441\u0442\u0438 \u0442\u043e\u043a\u0435\u043d\u0430\" title=\"https:\/\/jwt.io\/ - \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 2 \u0447\u0430\u0441\u0442\u0438 \u0442\u043e\u043a\u0435\u043d\u0430\" width=\"1522\" height=\"657\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/45a\/0f6\/44b\/45a0f644bb842529959221cea62b46cc.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption><a href=\"https:\/\/jwt.io\/\" rel=\"noopener noreferrer nofollow\">https:\/\/jwt.io\/<\/a> &#8212; \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 2 \u0447\u0430\u0441\u0442\u0438 \u0442\u043e\u043a\u0435\u043d\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 JWT-\u0442\u043e\u043a\u0435\u043d\u043e\u0432: access-token \u0438 refresh-token, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0430\u0440\u0435. \u042d\u0442\u0443 \u043f\u0430\u0440\u0443 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0432\u044b\u0434\u0430\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f &#171;\u0441\u0440\u043e\u043a \u0436\u0438\u0437\u043d\u0438&#187; &#8212; \u043f\u0435\u0440\u0438\u043e\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u043a\u0435\u043d\u0434\u043e\u043c \u043a\u0430\u043a \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442  \u0432\u044b\u0434\u0430\u043d\u043d\u0443\u044e  \u043f\u0430\u0440\u0443 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043f\u0440\u0438 \u043d\u043e\u0432\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0443 \u0441\u0435\u0431\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043a\u0435\u043d\u0430\u0445 \u0438 \u0438\u0445 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<h4>1.1. Access-\u0442\u043e\u043a\u0435\u043d<\/h4>\n<p>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e access-\u0442\u043e\u043a\u0435\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u043d\u0430 frontend-\u0447\u0430\u0441\u0442\u0438 \u0441\u0430\u0439\u0442\u0430 \u0432 localStorage, \u0438 \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0431\u0435\u043a\u0435\u043d\u0434. <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e access-\u0442\u043e\u043a\u0435\u043d\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0441\u0430\u0439\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0431\u0435\u043a\u0435\u043d\u0434\u0430 (\u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442 \u0431\u0435\u043a\u0435\u043d\u0434\u0430). \u042d\u0442\u043e, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445   \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c (  \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439, \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u043e\u0441\u0442). <\/p>\n<p>\u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 &#171;\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439&#187;. \u0421\u0430\u0439\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 GET-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0431\u0435\u043a\u0435\u043d\u0434, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 headers \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0435  Access-\u0442\u043e\u043a\u0435\u043d\u0430. \u0411\u0435\u043a\u0435\u043d\u0434, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u0430 \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u0442\u0432\u0435\u0442 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c. <\/p>\n<h4>1.2. Refresh-\u0442\u043e\u043a\u0435\u043d<\/h4>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0443 access-\u0442\u043e\u043a\u0435\u043d\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 refresh-\u0442\u043e\u043a\u0435\u043d. <\/p>\n<p>\u042d\u0442\u043e\u0442 \u0442\u043e\u043a\u0435\u043d \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 cookies, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435\u0433\u0434\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u0446\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043d\u0430 \u0431\u0435\u043a\u0435\u043d\u0434. <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e refresh-\u0442\u043e\u043a\u0435\u043d\u0430 \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0439 (&#171;\u043f\u0440\u043e\u0442\u0443\u0445\u0448\u0438\u0439&#187;) access-\u0442\u043e\u043a\u0435\u043d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 endpoint \u0431\u0435\u043a\u0435\u043d\u0434\u0430 (\u043e\u0431\u044b\u0447\u043d\u043e &#171;\/api\/refresh&#187;), \u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u0440\u0443 access token + refresh token.  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0446\u0438\u043a\u043b \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f: \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u043e\u0432\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0435 access-token + refresh-token,  \u0430 \u0441\u0430\u0439\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 access-token  \u043a \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/1d8\/570\/392\/1d8570392a1e863523d4c6a11d581093.jpg\" alt=\"\" title=\"\" width=\"1224\" height=\"701\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1d8\/570\/392\/1d8570392a1e863523d4c6a11d581093.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 <a href=\"https:\/\/www.youtube.com\/watch?v=fN25fMQZ2v0\" rel=\"noopener noreferrer nofollow\">\u0440\u043e\u043b\u0438\u043a \u043d\u0430 \u044e\u0442\u0443\u0431?<\/a>. <\/p>\n<h2>2. \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 JWT token (\u0442\u0435\u043e\u0440\u0438\u044f)<\/h2>\n<p>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c JWT token \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0432\u0443\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432:<\/p>\n<ul>\n<li>\n<p> \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f (\u0442.\u0435. \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0437\u0430\u0448\u0435\u043b \u043d\u0430 \u0441\u0430\u0439\u0442, \u043b\u0438\u0431\u043e \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0430\u0437 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0434\u0430\u0432\u043d\u043e, \u0438 \u043f\u0430\u0440\u0430 JWT-\u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0430)<\/p>\n<\/li>\n<li>\n<p>\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 (\u0442.\u0435. \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u043b \u0432\u043a\u043b\u0430\u0434\u043a\u0443, \u0441\u0431\u0440\u043e\u0441\u0438\u0432 \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0435\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 isAuth, \u0438 \u0434\u0430\u043b\u0435\u0435 \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0442\u043a\u0440\u044b\u043b \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u0441 \u0441\u0430\u0439\u0442\u043e\u043c; \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0430\u0440\u0430 JWT-\u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043b\u0438\u0431\u043e refresh-\u0442\u043e\u043a\u0435\u043d \u043d\u0435 \u0443\u0441\u043f\u0435\u043b\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0442\u044c)<\/p>\n<\/li>\n<\/ul>\n<h4>2.1. \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u043d\u0443\u043b\u044f (\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f )<\/h4>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 http:\/\/my_awesome_web_app.com<strong>\/login.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u0432\u0432\u043e\u0434\u0438\u0442 \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0432 \u0444\u043e\u0440\u043c\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 &#171;\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f&#187; (&#171;Login&#187;).<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0430\u043d\u0435\u0435 \u043b\u043e\u0433\u0438\u043d\u043e\u043c \u0438 \u043f\u0430\u0440\u043e\u043b\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u0430\u044f \u043f\u0430\u0440\u0430 \u043b\u043e\u0433\u0438\u043d + \u043f\u0430\u0440\u043e\u043b\u044c \u0432 \u0435\u0433\u043e \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0432\u0432\u0435\u0434\u0435\u043d\u044b \u0432\u0435\u0440\u043d\u043e, \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0430\u0440\u0443 \u0442\u043e\u043a\u0435\u043d\u043e\u0432  access token + refresh token, \u0438 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 refresh \u0442\u043e\u043a\u0435\u043d \u0432 httpOnly cookie. <\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 body \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 access token. \u041e\u0442\u0432\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u0439\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 access token \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u0441\u0432\u043e\u0439 localStorage. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0446\u0435\u043b\u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0430\u043c \u0441\u0430\u0439\u0442 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e isAuth = true.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043a\u043e \u0432\u0441\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f access token, \u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0437 accessToken id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u0441\u043f\u0438\u0441\u043e\u043a \u0435\u0433\u043e \u0434\u0440\u0443\u0437\u0435\u0439 \u0438\u043b\u0438 \u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439).<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/2e3\/20d\/210\/2e320d21026092023f29daa86a6b36c2.jpg\" alt=\"\u041f\u0435\u0440\u0432\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435\" title=\"\u041f\u0435\u0440\u0432\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435\" width=\"1297\" height=\"770\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2e3\/20d\/210\/2e320d21026092023f29daa86a6b36c2.jpg\" data-blurred=\"true\"\/><\/p>\n<div><figcaption>\u041f\u0435\u0440\u0432\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435<\/figcaption><\/div>\n<\/figure>\n<h4> 2.2. \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430<\/h4>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043b\u044e\u0431\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0430\u0439\u0442\u0430 http:\/\/my_awesome_web_app.com<strong>\/news.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b http:\/\/my_awesome_web_app.com<strong>\/news <\/strong>\u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0441\u0430\u0439\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b http:\/\/my_awesome_web_app.com<strong>\/my_messages <\/strong> \u043d\u0443\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0441\u0430\u0439\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043c &#171;\u043a\u0440\u0443\u0442\u0438\u043b\u043a\u0443&#187;, \u0438 \u0432 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u0439\u0442 \u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c access \u0442\u043e\u043a\u0435\u043d \u0438\u0437 localStorage, \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0438, \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0442.\u043f.). <\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 access token \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c, \u0442\u043e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0434\u0443\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438 \u0441\u0430\u0439\u0442 \u043c\u043e\u0436\u0435\u0442  \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c  \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e isAuth = true. \u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 access token \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c,  \u0442\u043e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430. \u042d\u0442\u0443 \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0447\u0435\u0440\u0435\u0437 refresh token. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0448\u0435\u043b \u043e\u0442\u0432\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441 &#171;\/api\/refresh&#187;. \u041a \u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u0446\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f cookies \u0441 refresh-\u0442\u043e\u043a\u0435\u043d\u043e\u043c. <\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u044b\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u0440\u0443 access token + refresh token, \u0438 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0442\u0430\u0442\u0443\u0441\u0430 isAuth = true \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f isAuth = false, \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u043b\u0438\u0431\u043e \u043d\u0430 \u0434\u043e\u043c\u0430\u0448\u043d\u044e\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0430\u0439\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443, \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.  <\/p>\n<\/li>\n<\/ul>\n<h2>3. \u0427\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f JWT \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 frontend<\/h2>\n<h4>3.1. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442<\/h4>\n<p><strong> <\/strong>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>npx create-react-app jwt-auth-app<\/code><\/p>\n<details class=\"spoiler\">\n<summary>\u0415\u0441\u043b\u0438 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 React:<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/create-react-app.dev\/\" rel=\"noopener noreferrer nofollow\">https:\/\/create-react-app.dev\/<\/a><\/p>\n<\/div>\n<\/details>\n<h4>3.2. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c axios<\/h4>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>npm install axios<\/code> <\/p>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 <code>src\/<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>api.config.js<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0434\u043b\u044f axios \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 accessToken \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043f\u0440\u0438 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u043e\u043c accessToken.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u043e\u0432 \u043a axios-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">import axios from \"axios\";  export const instance = axios.create({   \/\/ \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0443\u0435\u043f\u043b\u044f\u0442\u044c\u0441\u044f cookies \u00a0 withCredentials: true, \u00a0 baseURL: \"https:\/\/jsonplaceholder.typicode.com\/\", });   \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \/\/ \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 accessToken \u0438\u0437 localStorage instance.interceptors.request.use(   (config) => {     config.headers.Authorization = `Bearer ${localStorage.getItem(\"token\")}`     return config   } )   \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \/\/ \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e accessToken \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \/\/ \u0438 \u043f\u0435\u0440\u0435\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c accessToken instance.interceptors.response.use(   \/\/ \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e accessToken \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c:   (config) => {     return config;   },   \/\/ \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e accessToken \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c:   async (error) => {    \/\/ \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e _isRetry     const originalRequest = {...error.config};    originalRequest._isRetry = true;      if (       \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0437-\u0437\u0430 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e accessToken       error.response.status === 401 &amp;&amp;        \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439       error.config &amp;&amp;       !error.config._isRetry     ) {       try {         \/\/ \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u043e\u0432         const resp = await instance.get(\"\/api\/refresh\");         \/\/ \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 accessToken \u0432 localStorage         localStorage.setItem(\"token\", resp.data.accessToken);         \/\/ \u043f\u0435\u0440\u0435\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c accessToken         return instance.request(originalRequest);       } catch (error) {         console.log(\"AUTH ERROR\");       }     }     \/\/ \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 (\u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439)     \/\/ \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u043c \u044d\u0442\u0443 \u043e\u0448\u0438\u0431\u043a\u0443      throw error;   } );<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<ul>\n<li>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438:  <code>npm install axios<\/code>  <\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 <code>src\/<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>api.auth.js<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 backend: <\/p>\n<pre><code class=\"javascript\">import { instance } from \".\/api.config.js\";  export default const AuthService {      login (email, password) {         return instance.post(\"\/api\/login\", {email, password})     }          refreshToken() {         return instance.get(\"\/api\/refresh\");     }          logout() {         return instance.post(\"\/api\/logout\")     } }<\/code><\/pre>\n<h3>4. \u0421\u043e\u0437\u0434\u0430\u0435\u043c Private Routes<\/h3>\n<p>\u041d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0430\u0439\u0442\u0430\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446: \u0441 \u043e\u0431\u0449\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u0438 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435. <\/p>\n<blockquote>\n<p>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u043e\u0431\u0449\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u0441\u0430\u0439\u0442\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u043e\u0432\u043e\u0441\u0442\u0438, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438). <\/p>\n<p>\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c, \u0438\u043d\u0430\u0447\u0435 \u043e\u043d\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u0435\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u0439\u0442 \u0437\u043d\u0430\u043b, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0434\u0432\u0443\u0445 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445: <code>isAuth<\/code>, <code>isAuthInProgress<\/code>. <\/p>\n<\/blockquote>\n<h4>4.1. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c React Router<\/h4>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>npm install react-router react-router-dom<\/code><\/p>\n<h4>4.2. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 isAuth, isAuthInProgress<\/h4>\n<p>\u042d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 state-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0435 (redux, mobX), \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 AuthContext, \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 useState, \u043b\u0438\u0431\u043e <a href=\"https:\/\/levelup.gitconnected.com\/react-template-for-jwt-authentication-with-private-routes-and-redirects-f77c488bfb85\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0445\u0443\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438<\/a>.  <\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 mobX.<\/p>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>npm install mobx mobx-react-lite<\/code><\/p>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 <code>src\/<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>store.js<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430 store.js: <\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">import { makeAutoObservable } from \"mobx\"; import AuthService from \".\/api.auth.js\";  class AuthStore {      isAuth = false;   isAuthInProgress = false;      constructor() {     makeAutoObservable(this, {}, { autoBind: true });   }    async login(email, password) {     this.isAuthInProgress = true;     try {       const resp = await AuthService.login(email, password);       localStorage.setItem(\"token\", resp.data.accessToken);       this.isAuth = true;       } catch (err) {       console.log(\"login error\");      } finally {       this.isAuthInProgress = false;     }    }    async checkAuth() {     this.isAuthInProgress = true;     try {       const resp = await AuthService.refresh();       localStorage.setItem(\"token\", resp.data.accessToken);       this.isAuth = true;       } catch (err) {       console.log(\"login error\");      } finally {       this.isAuthInProgress = false;     }    }    async logout() {     this.isAuthInProgress = true;     try {       await AuthService.logout();       this.isAuth = false;       localStorage.removeItem(\"token\");     } catch (err) {       console.log(\"logout error\");     } finally {       this.isAuthInProgress = false;     }    }    }  export default new AuthStore();<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h4>4.3. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c HOC PrivateRoute<\/h4>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 <code>src\/<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>privateRoute.jsx<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u043b\u043e\u0433\u0438\u043a\u0443 privateRoute: <\/p>\n<ul>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d, \u0442\u043e \u0436\u0434\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u0438\u0448\u043b\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u043e\u0431 \u0443\u0434\u0430\u0447\u043d\u043e\u0439\/\u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0448\u0435\u043b \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u0430, \u0442\u043e\u0433\u0434\u0430 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0437\u0430\u043f\u0440\u043e\u0448\u0435\u043d\u043d\u0443\u044e \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0448\u0435\u043b \u043e\u0442\u0432\u0435\u0442 \u043e\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430, \u043d\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435\u0443\u0441\u043f\u0435\u0448\u043d\u0430, \u0442\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430 privateRoute.jsx:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">import { Navigate, Outlet, Route } from \"react-router-dom\"; import authStore from \".\/store.js\"; import { observer } from \"mobx-react-lite\";  const PrivateRoute = (props) => {    if (authStore.isLoadingAuth) {     return &lt;div>Checking auth...&lt;\/div>;   }   if (authStore.isAuth) {      return &lt;Outlet\/>   } else {     return &lt;Navigate to=\"\/login\" \/>;   } };    export default observer(PrivateRoute); <\/code><\/pre>\n<p>&lt;Outlet\/> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f  \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f children (\u0432\u043c\u0435\u0441\u0442\u043e props.children)<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 <code>src\/<\/code> \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b <code>App.jsx<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0440\u043e\u0443\u0442\u044b. <\/p>\n<details class=\"spoiler\">\n<summary>App.jsx:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">import React, { useEffect } from \"react\"; import { Route, Routes, BrowserRouter } from \"react-router-dom\"; import { observer } from \"mobx-react-lite\"; import AuthStore from \".\/store.js\"; import PrivateRoute from \".\/privateRoute.js\";   import LoginPage from \".\/pages\/loginPage\"; import UsersPage from \".\/pages\/usersPage\";  const App = observer(() => {      useEffect(() => {      AuthStore.checkAuth();   }, []);     return (     &lt;BrowserRouter>         &lt;Routes>     \/\/\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430, \u0434\u043b\u044f \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f             &lt;Route path=\"\/login\" element={&lt;LoginPage \/>} \/>      \/\/\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0434\u043b\u044f \u043f\u043e\u0441\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f             &lt;Route path=\"\/users\" element={&lt;PrivateRoute  \/>}>                 &lt;Route path=\"\" element={&lt;UsersPage \/>} \/>                 &lt;Route path=\":id\" element={&lt;UserPage \/>} \/>             &lt;\/Route>              &lt;Route path=\"*\" element={&lt;div>404... not found &lt;\/div>} \/>         &lt;\/Routes>     &lt;\/BrowserRouter>    ); });  export default App;<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h2>\u0423\u0441\u043f\u0435\u0445!<\/h2>\n<p>\u0412\u043e\u0442 \u0438 \u0433\u043e\u0442\u043e\u0432\u0430 \u043f\u0435\u0440\u0432\u0430\u044f JWT-\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0444\u0440\u043e\u043d\u0442\u0435\u043d\u0434\u0435. \u0412\u0441\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430, \u0434\u0430\u0436\u0435 \u043a\u043e\u0433\u0434\u0430 \u0443 \u0442\u0435\u0431\u044f \u043b\u0430\u043f\u043a\u0438 ?<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/03e\/cc7\/518\/03ecc7518996e83d278536ffcde0dc70.png\" width=\"498\" height=\"498\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/03e\/cc7\/518\/03ecc7518996e83d278536ffcde0dc70.png\"\/><\/figure>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/732432\/\"> https:\/\/habr.com\/ru\/articles\/732432\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>1. \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 JWT token<\/h2>\n<p>JWT token (\u043e\u043d \u0436\u0435 <em>JSON Web Token<\/em>) &#8212; \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0430, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438\u0437 \u0442\u0440\u0435\u0445 \u0447\u0430\u0441\u0442\u0435\u0439: \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a, \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u044c.<\/p>\n<p>\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u0441\u0430\u0439\u0442\u0430 \u0445\u043e\u0447\u0435\u0442 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u043a\u0443. \u041e\u043d \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u0434\u0438\u0430\u043b\u043e\u0433\u0430\u043c\u0438, \u0438 \u0441\u0430\u0439\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 (\u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439), \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 &#8212; JWT \u0442\u043e\u043a\u0435\u043d.  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u0438 \u0440\u0435\u0448\u0430\u0435\u0442, \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043b\u0438 \u0435\u043c\u0443 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u043d\u0442 \u0441\u0430\u0439\u0442\u0430 (\u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439).  <\/p>\n<figure class=\"full-width\">\n<div><figcaption><a href=\"https:\/\/jwt.io\/\" rel=\"noopener noreferrer nofollow\">https:\/\/jwt.io\/<\/a> &#8212; \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0439\u0442, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 2 \u0447\u0430\u0441\u0442\u0438 \u0442\u043e\u043a\u0435\u043d\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 JWT-\u0442\u043e\u043a\u0435\u043d\u043e\u0432: access-token \u0438 refresh-token, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043f\u0430\u0440\u0435. \u042d\u0442\u0443 \u043f\u0430\u0440\u0443 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 \u0438 \u0432\u044b\u0434\u0430\u0435\u0442 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0432 \u043e\u0442\u0432\u0435\u0442 \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0435\u0442\u0441\u044f &#171;\u0441\u0440\u043e\u043a \u0436\u0438\u0437\u043d\u0438&#187; &#8212; \u043f\u0435\u0440\u0438\u043e\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u0437\u043d\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0435\u043a\u0435\u043d\u0434\u043e\u043c \u043a\u0430\u043a \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442  \u0432\u044b\u0434\u0430\u043d\u043d\u0443\u044e  \u043f\u0430\u0440\u0443 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0432 \u0441\u0432\u043e\u0435\u0439 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043f\u0440\u0438 \u043d\u043e\u0432\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442 \u0443 \u0441\u0435\u0431\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0442\u043e\u043a\u0435\u043d\u0430\u0445 \u0438 \u0438\u0445 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<h4>1.1. Access-\u0442\u043e\u043a\u0435\u043d<\/h4>\n<p>\u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e access-\u0442\u043e\u043a\u0435\u043d\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u043d\u0430 frontend-\u0447\u0430\u0441\u0442\u0438 \u0441\u0430\u0439\u0442\u0430 \u0432 localStorage, \u0438 \u0435\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0431\u0435\u043a\u0435\u043d\u0434. <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e access-\u0442\u043e\u043a\u0435\u043d\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0441\u0430\u0439\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u0432\u0438\u0441\u044f\u0442 \u043e\u0442 \u0431\u0435\u043a\u0435\u043d\u0434\u0430 (\u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442 \u0431\u0435\u043a\u0435\u043d\u0434\u0430). \u042d\u0442\u043e, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445   \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c (  \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439, \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u043e\u0441\u0442). <\/p>\n<p>\u042d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 &#171;\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438\u0441\u0442\u043e\u0440\u0438\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439&#187;. \u0421\u0430\u0439\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 GET-\u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0431\u0435\u043a\u0435\u043d\u0434, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 headers \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0435  Access-\u0442\u043e\u043a\u0435\u043d\u0430. \u0411\u0435\u043a\u0435\u043d\u0434, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u0430 \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043e\u0442\u0432\u0435\u0442 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c. <\/p>\n<h4>1.2. Refresh-\u0442\u043e\u043a\u0435\u043d<\/h4>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0443 access-\u0442\u043e\u043a\u0435\u043d\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0440\u043e\u043a \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 refresh-\u0442\u043e\u043a\u0435\u043d. <\/p>\n<p>\u042d\u0442\u043e\u0442 \u0442\u043e\u043a\u0435\u043d \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 cookies, \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435\u0433\u0434\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u0446\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043d\u0430 \u0431\u0435\u043a\u0435\u043d\u0434. <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e refresh-\u0442\u043e\u043a\u0435\u043d\u0430 \u043c\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u043c \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0439 (&#171;\u043f\u0440\u043e\u0442\u0443\u0445\u0448\u0438\u0439&#187;) access-\u0442\u043e\u043a\u0435\u043d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 endpoint \u0431\u0435\u043a\u0435\u043d\u0434\u0430 (\u043e\u0431\u044b\u0447\u043d\u043e &#171;\/api\/refresh&#187;), \u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u0440\u0443 access token + refresh token.  <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0446\u0438\u043a\u043b \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0435\u0442\u0441\u044f: \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043d\u043e\u0432\u043e\u0439 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0439 \u043f\u0430\u0440\u0435 access-token + refresh-token,  \u0430 \u0441\u0430\u0439\u0442 \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 access-token  \u043a \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u043c \u043d\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. <\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0435\u0441\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043a\u0440\u0443\u0442\u043e\u0439 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 <a href=\"https:\/\/www.youtube.com\/watch?v=fN25fMQZ2v0\" rel=\"noopener noreferrer nofollow\">\u0440\u043e\u043b\u0438\u043a \u043d\u0430 \u044e\u0442\u0443\u0431?<\/a>. <\/p>\n<h2>2. \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 JWT token (\u0442\u0435\u043e\u0440\u0438\u044f)<\/h2>\n<p>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c JWT token \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0432\u0443\u0445 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u043e\u0432:<\/p>\n<ul>\n<li>\n<p> \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f (\u0442.\u0435. \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0437\u0430\u0448\u0435\u043b \u043d\u0430 \u0441\u0430\u0439\u0442, \u043b\u0438\u0431\u043e \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0440\u0430\u0437 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0434\u0430\u0432\u043d\u043e, \u0438 \u043f\u0430\u0440\u0430 JWT-\u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0443\u0441\u0442\u0430\u0440\u0435\u043b\u0430)<\/p>\n<\/li>\n<li>\n<p>\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 (\u0442.\u0435. \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, \u0437\u0430\u0442\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u043b \u0432\u043a\u043b\u0430\u0434\u043a\u0443, \u0441\u0431\u0440\u043e\u0441\u0438\u0432 \u0445\u0440\u0430\u043d\u044f\u0449\u0435\u0435\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 isAuth, \u0438 \u0434\u0430\u043b\u0435\u0435 \u0437\u0430\u043d\u043e\u0432\u043e \u043e\u0442\u043a\u0440\u044b\u043b \u0432\u043a\u043b\u0430\u0434\u043a\u0443 \u0441 \u0441\u0430\u0439\u0442\u043e\u043c; \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0430\u0440\u0430 JWT-\u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043b\u0438\u0431\u043e refresh-\u0442\u043e\u043a\u0435\u043d \u043d\u0435 \u0443\u0441\u043f\u0435\u043b\u0438 \u0443\u0441\u0442\u0430\u0440\u0435\u0442\u044c)<\/p>\n<\/li>\n<\/ul>\n<h4>2.1. \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0441 \u043d\u0443\u043b\u044f (\u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f )<\/h4>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 http:\/\/my_awesome_web_app.com<strong>\/login.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u0432\u0432\u043e\u0434\u0438\u0442 \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0432 \u0444\u043e\u0440\u043c\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442 \u043a\u043d\u043e\u043f\u043a\u0443 &#171;\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f&#187; (&#171;Login&#187;).<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u043c\u0438 \u0440\u0430\u043d\u0435\u0435 \u043b\u043e\u0433\u0438\u043d\u043e\u043c \u0438 \u043f\u0430\u0440\u043e\u043b\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0435\u0440\u0432\u0435\u0440 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043a\u0430\u044f \u043f\u0430\u0440\u0430 \u043b\u043e\u0433\u0438\u043d + \u043f\u0430\u0440\u043e\u043b\u044c \u0432 \u0435\u0433\u043e \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0432\u0432\u0435\u0434\u0435\u043d\u044b \u0432\u0435\u0440\u043d\u043e, \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0430\u0440\u0443 \u0442\u043e\u043a\u0435\u043d\u043e\u0432  access token + refresh token, \u0438 \u0441\u0440\u0430\u0437\u0443 \u0436\u0435 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 refresh \u0442\u043e\u043a\u0435\u043d \u0432 httpOnly cookie. <\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 body \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 access token. \u041e\u0442\u0432\u0435\u0442 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u0439\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 access token \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u0432 \u0441\u0432\u043e\u0439 localStorage. \u0422\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u0446\u0435\u043b\u0435\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043a \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u043c \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0430\u043c \u0441\u0430\u0439\u0442 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e isAuth = true.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043a\u043e \u0432\u0441\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f access token, \u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u0434\u0430\u0435\u0442 \u043e\u0442\u0432\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u043c\u0443 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u0438\u0437 accessToken id \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c \u0435\u043c\u0443 \u0441\u043f\u0438\u0441\u043e\u043a \u0435\u0433\u043e \u0434\u0440\u0443\u0437\u0435\u0439 \u0438\u043b\u0438 \u0435\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439).<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\">\n<div><figcaption>\u041f\u0435\u0440\u0432\u0430\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0441\u0430\u0439\u0442\u0435<\/figcaption><\/div>\n<\/figure>\n<h4> 2.2. \u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430<\/h4>\n<ul>\n<li>\n<p>\u041f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043b\u044e\u0431\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0430\u0439\u0442\u0430 http:\/\/my_awesome_web_app.com<strong>\/news.<\/strong><\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b http:\/\/my_awesome_web_app.com<strong>\/news <\/strong>\u043d\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0441\u0430\u0439\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u044d\u0442\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b http:\/\/my_awesome_web_app.com<strong>\/my_messages <\/strong> \u043d\u0443\u0436\u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0441\u0430\u0439\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u043c &#171;\u043a\u0440\u0443\u0442\u0438\u043b\u043a\u0443&#187;, \u0438 \u0432 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u0439\u0442 \u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0442\u044c access \u0442\u043e\u043a\u0435\u043d \u0438\u0437 localStorage, \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0430\u0432\u0430\u0442\u0430\u0440\u043a\u0438, \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0442.\u043f.). <\/p>\n<ul>\n<li>\n<p>\u0415\u0441\u043b\u0438 access token \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c, \u0442\u043e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0434\u0443\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438 \u0441\u0430\u0439\u0442 \u043c\u043e\u0436\u0435\u0442  \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c  \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e isAuth = true. \u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 access token \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u044b\u043c,  \u0442\u043e \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0432 \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430. \u042d\u0442\u0443 \u043e\u0448\u0438\u0431\u043a\u0443 \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0447\u0435\u0440\u0435\u0437 refresh token. \u0422\u043e \u0435\u0441\u0442\u044c \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0448\u0435\u043b \u043e\u0442\u0432\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0438 \u043d\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0430\u0434\u0440\u0435\u0441 &#171;\/api\/refresh&#187;. \u041a \u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u0440\u0438\u0446\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f cookies \u0441 refresh-\u0442\u043e\u043a\u0435\u043d\u043e\u043c. <\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0438 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432\u044b\u0434\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u043e\u0432\u0443\u044e \u043f\u0430\u0440\u0443 access token + refresh token, \u0438 \u0434\u0430\u043b\u0435\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441\u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0437\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0442\u0430\u0442\u0443\u0441\u0430 isAuth = true \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u0414\u0430\u043b\u0435\u0435, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0439 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f isAuth = false, \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u043b\u0438\u0431\u043e \u043d\u0430 \u0434\u043e\u043c\u0430\u0448\u043d\u044e\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441\u0430\u0439\u0442\u0430.<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443, \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.  <\/p>\n<\/li>\n<\/ul>\n<h2>3. \u0427\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f JWT \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 frontend<\/h2>\n<h4>3.1. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0435\u043a\u0442<\/h4>\n<p><strong> <\/strong>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>npx create-react-app jwt-auth-app<\/code><\/p>\n<details class=\"spoiler\">\n<summary>\u0415\u0441\u043b\u0438 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 React:<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/create-react-app.dev\/\" rel=\"noopener noreferrer nofollow\">https:\/\/create-react-app.dev\/<\/a><\/p>\n<\/div>\n<\/details>\n<h4>3.2. \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c axios<\/h4>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>npm install axios<\/code> <\/p>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 <code>src\/<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>api.config.js<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0434\u043b\u044f axios \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 accessToken \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043f\u0440\u0438 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u043e\u043c accessToken.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u043e\u0432 \u043a axios-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c:<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">import axios from \"axios\";  export const instance = axios.create({   \/\/ \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0443\u0435\u043f\u043b\u044f\u0442\u044c\u0441\u044f cookies \u00a0 withCredentials: true, \u00a0 baseURL: \"https:\/\/jsonplaceholder.typicode.com\/\", });   \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \/\/ \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 accessToken \u0438\u0437 localStorage instance.interceptors.request.use(   (config) => {     config.headers.Authorization = `Bearer ${localStorage.getItem(\"token\")}`     return config   } )   \/\/ \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u043e\u0442\u0432\u0435\u0442\u043e\u0432 \/\/ \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e accessToken \u043f\u043e\u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \/\/ \u0438 \u043f\u0435\u0440\u0435\u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c accessToken instance.interceptors.response.use(   \/\/ \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e accessToken \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u043c:   (config) => {     return config;   },   \/\/ \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u0435\u043d\u043d\u043e\u0433\u043e accessToken \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c:   async (error) => {    \/\/ \u043f\u0440\u0435\u0434\u043e\u0442\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u0430\u0446\u0438\u043a\u043b\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e _isRetry     const originalRequest = {...error.config};    originalRequest._isRetry = true;      if (       \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0437-\u0437\u0430 \u043d\u0435\u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0433\u043e accessToken       error.response.status === 401 &amp;&amp;        \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0447\u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0439       error.config &amp;&amp;       !error.config._isRetry     ) {       try {         \/\/ \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u043e\u0432         const resp = await instance.get(\"\/api\/refresh\");         \/\/ \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 accessToken \u0432 localStorage         localStorage.setItem(\"token\", resp.data.accessToken);         \/\/ \u043f\u0435\u0440\u0435\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0441 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u043c accessToken         return instance.request(originalRequest);       } catch (error) {         console.log(\"AUTH ERROR\");       }     }     \/\/ \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439, \u0435\u0441\u043b\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430 (\u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u0430\u044f \u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439)     \/\/ \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u043c \u044d\u0442\u0443 \u043e\u0448\u0438\u0431\u043a\u0443      throw error;   } );<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<ul>\n<li>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438:  <code>npm install axios<\/code>  <\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 <code>src\/<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>api.auth.js<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 backend: <\/p>\n<pre><code class=\"javascript\">import { instance } from \".\/api.config.js\";  export default const AuthService {      login (email, password) {         return instance.post(\"\/api\/login\", {email, password})     }          refreshToken() {         return instance.get(\"\/api\/refresh\");     }          logout() {         return instance.post(\"\/api\/logout\")     } }<\/code><\/pre>\n<h3>4. \u0421\u043e\u0437\u0434\u0430\u0435\u043c Private Routes<\/h3>\n<p>\u041d\u0430 \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0430\u0439\u0442\u0430\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u0432\u0438\u0434\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446: \u0441 \u043e\u0431\u0449\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u0438 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435. <\/p>\n<blockquote>\n<p>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0441 \u043e\u0431\u0449\u0438\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043b\u044e\u0431\u043e\u0439 \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044c \u0441\u0430\u0439\u0442\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u043e\u0432\u043e\u0441\u0442\u0438, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438). <\/p>\n<p>\u041f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c, \u0438\u043d\u0430\u0447\u0435 \u043e\u043d\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442 \u043d\u0435\u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u0435\u043b\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0430\u0439\u0442 \u0437\u043d\u0430\u043b, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0434\u0432\u0443\u0445 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445: <code>isAuth<\/code>, <code>isAuthInProgress<\/code>. <\/p>\n<\/blockquote>\n<h4>4.1. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c React Router<\/h4>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>npm install react-router react-router-dom<\/code><\/p>\n<h4>4.2. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 isAuth, isAuthInProgress<\/h4>\n<p>\u042d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 state-\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0435 (redux, mobX), \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 AuthContext, \u0442\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u0432 useState, \u043b\u0438\u0431\u043e <a href=\"https:\/\/levelup.gitconnected.com\/react-template-for-jwt-authentication-with-private-routes-and-redirects-f77c488bfb85\" rel=\"noopener noreferrer nofollow\">\u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0445\u0443\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438<\/a>.  <\/p>\n<p>\u0420\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u044d\u0442\u043e \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 mobX.<\/p>\n<p>\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438: <code>npm install mobx mobx-react-lite<\/code><\/p>\n<p>\u0412 \u043f\u0430\u043f\u043a\u0435 <code>src\/<\/code> \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0430\u0439\u043b <code>store.js<\/code>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435. <\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u043e\u0434 \u0444\u0430\u0439\u043b\u0430 store.js: <\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">import { makeAutoObservable } from \"mobx\"; import AuthService from<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-387151","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/387151","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=387151"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/387151\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=387151"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=387151"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=387151"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}