{"id":364560,"date":"2024-05-21T02:19:24","date_gmt":"2024-05-21T02:19:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=364560"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=364560","title":{"rendered":"<span>JWT-\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Spring Boot 3 \u0438 Spring Security 6<\/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>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435 \u043b\u044e\u0431\u0438\u0442\u0435 \u0442\u0435\u043e\u0440\u0438\u044e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 <a href=\"#%D0%BF%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D0%BA%D0%B0\" rel=\"noopener noreferrer nofollow\">\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Spring Security \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f, Spring Security 6, \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c JWT-\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Boot 3 \u0438 Spring Security 6, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0426\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JWT-\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0441 API-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438. \u0411\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043e \u043a\u0430\u043a \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0442\u0430\u043a \u0438 \u0440\u043e\u043b\u0435\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c. \u0421\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u043a\u0430\u043a \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c, \u0442\u0430\u043a \u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0441\u0432\u043e\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u044b. <\/p>\n<h2>\u0422\u0435\u043e\u0440\u0438\u044f<\/h2>\n<p>\u041f\u0440\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0430\u0442\u043a\u0430\u044f \u0432\u044b\u0436\u0438\u043c\u043a\u0430. JWT \u0438\u043b\u0438 Json Web Token &#8212; \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u043c, \u0442.\u0435. \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0432\u043e\u0435\u0439 \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c. \u0422\u043e\u043a\u0435\u043d \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 3-\u0445 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<ul>\n<li>\n<p><strong>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a<\/strong> &#8212; \u0445\u0440\u0430\u043d\u0438\u0442 \u0442\u0438\u043f \u0442\u043e\u043a\u0435\u043d\u0430 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430<\/strong> &#8212; \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u0442\u0434 (\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0451 \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e)<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0434\u043f\u0438\u0441\u044c<\/strong> &#8212; \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0443\u0442\u0451\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0447\u0442\u043e \u0442\u043e\u043a\u0435\u043d \u043d\u0435 \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0442\u043e\u043a\u0435\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435. <a href=\"https:\/\/jwt.io\/introduction\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e JWT.<\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/89e\/51b\/f4c\/89e51bf4c2253f11e3e731562f0b3b2a.png\" alt=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 JWT \" title=\"\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 JWT \" width=\"1200\" height=\"778\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/89e\/51b\/f4c\/89e51bf4c2253f11e3e731562f0b3b2a.png\"\/><\/p>\n<div><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 JWT <\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0435 \u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u0430 \u0432 \u0442\u0430\u043a\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0442\u043e \u0435\u0433\u043e \u0443\u0432\u0438\u0434\u0438\u0442, \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u043b\u044e\u0431\u044b\u043c jwt encoder-\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/jwt.io\/\" rel=\"noopener noreferrer nofollow\">jwt.io<\/a>. \u041f\u0440\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<h3>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e <\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u0430\u0440\u043e\u043b\u044c \u0448\u0438\u0444\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>PasswordEncoder<\/code><\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 jpa-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><code>JwtService<\/code> \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0443<\/p>\n<\/li>\n<\/ol>\n<h3>\u0412\u0445\u043e\u0434 \u0432 \u0430\u043a\u043a\u0430\u0443\u043d\u0442<\/h3>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0445\u043e\u0434\u0430 \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f.<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0430 \u0432\u0445\u043e\u0434<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>UsernamePasswordAuthenticationToken<\/code>\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>AuthenticationManager<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e &#8212; \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d \u0442\u043e\u043a\u0435\u043d, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442, \u043e\u0448\u0438\u0431\u043a\u0430 403<\/p>\n<\/li>\n<\/ol>\n<p><a class=\"anchor\" name=\"%D0%BF%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D0%BA%D0%B0\" id=\"\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430\"><\/a><\/p>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/h3>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 H2. <\/p>\n<h4>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h4>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;dependencies>     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-web&lt;\/artifactId>     &lt;\/dependency>      &lt;!-- \u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 -->     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-data-jpa&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>com.h2database&lt;\/groupId>         &lt;artifactId>h2&lt;\/artifactId>         &lt;scope>runtime&lt;\/scope>     &lt;\/dependency>      &lt;!-- \u0423\u0442\u0438\u043b\u0438\u0442\u044b -->     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-validation&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>org.apache.commons&lt;\/groupId>         &lt;artifactId>commons-lang3&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>org.springdoc&lt;\/groupId>         &lt;artifactId>springdoc-openapi-starter-webmvc-ui&lt;\/artifactId>         &lt;version>2.2.0&lt;\/version>     &lt;\/dependency>      &lt;!-- \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c -->     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-security&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>io.jsonwebtoken&lt;\/groupId>         &lt;artifactId>jjwt-api&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>io.jsonwebtoken&lt;\/groupId>         &lt;artifactId>jjwt-impl&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>io.jsonwebtoken&lt;\/groupId>         &lt;artifactId>jjwt-jackson&lt;\/artifactId>     &lt;\/dependency>      &lt;!-- \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 -->     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-test&lt;\/artifactId>         &lt;scope>test&lt;\/scope>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>org.springframework.security&lt;\/groupId>         &lt;artifactId>spring-security-test&lt;\/artifactId>         &lt;scope>test&lt;\/scope>     &lt;\/dependency> &lt;\/dependencies>  &lt;dependencyManagement>     &lt;dependencies>         &lt;dependency>             &lt;groupId>io.jsonwebtoken&lt;\/groupId>             &lt;artifactId>jjwt-api&lt;\/artifactId>             &lt;version>0.12.3&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>io.jsonwebtoken&lt;\/groupId>             &lt;artifactId>jjwt-impl&lt;\/artifactId>             &lt;version>0.12.3&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>io.jsonwebtoken&lt;\/groupId>             &lt;artifactId>jjwt-jackson&lt;\/artifactId>             &lt;version>0.12.3&lt;\/version>         &lt;\/dependency>     &lt;\/dependencies> &lt;\/dependencyManagement><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h4>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<pre><code class=\"yaml\">spring:   application:     name: security-security   datasource:     url: jdbc:h2:mem:security-security     driverClassName: org.h2.Driver     username: root     password: root   jpa:     hibernate:       ddl-auto: create-drop     show-sql: true     properties:       hibernate:         format_sql: true token:   signing:     key: 53A73E5F1C4E0A2D3B5F2D784E6A1B423D6F247D1F6E5C3A596D635A75327855<\/code><\/pre>\n<p>\u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u0432 pom \u0444\u0430\u0439\u043b\u0435 \u043d\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0440\u0443\u043a\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u043e\u043d \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0430, \u0431\u0443\u0434\u044c\u0442\u0435 \u0441 \u044d\u0442\u0438\u043c \u043e\u0447\u0435\u043d\u044c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b. <\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e Spring Security \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>UserDetails<\/code> &#8212; \u0432 \u043d\u0451\u043c \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 Spring Security.<\/p>\n<pre><code class=\"java\">@Entity @Builder @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Table(name = \"users\") public class User implements UserDetails {     @Id     @Column(name = \"id\")     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = \"user_id_seq\")     @SequenceGenerator(name = \"user_id_seq\", sequenceName = \"user_id_seq\", allocationSize = 1)     private Long id;      @Column(name = \"username\", unique = true, nullable = false)     private String username;      @Column(name = \"password\", nullable = false)     private String password;      @Column(name = \"email\", unique = true, nullable = false)     private String email;      @Enumerated(EnumType.STRING)     @Column(name = \"role\", nullable = false)     private Role role;      @Override     public Collection&lt;? extends GrantedAuthority> getAuthorities() {         return List.of(new SimpleGrantedAuthority(role.name()));     }      @Override     public boolean isAccountNonExpired() {         return true;     }      @Override     public boolean isAccountNonLocked() {         return true;     }      @Override     public boolean isCredentialsNonExpired() {         return true;     }      @Override     public boolean isEnabled() {         return true;     } }<\/code><\/pre>\n<pre><code class=\"java\">public enum Role {     ROLE_USER,     ROLE_ADMIN }<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c 3 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430, \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0434 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439.<\/p>\n<pre><code class=\"java\">@Repository public interface UserRepository extends JpaRepository&lt;User, Long> {     Optional&lt;User> findByUsername(String username);     boolean existsByUsername(String username);     boolean existsByEmail(String email); }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c DTO \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438, \u0432\u0445\u043e\u0434\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0442\u043e\u043a\u0435\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<p><strong>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/strong><\/p>\n<pre><code class=\"java\">@Data @Schema(description = \"\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e\") public class SignUpRequest {      @Schema(description = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\", example = \"Jon\")     @Size(min = 5, max = 50, message = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442 5 \u0434\u043e 50 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     @NotBlank(message = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438\")     private String username;      @Schema(description = \"\u0410\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b\", example = \"jondoe@gmail.com\")     @Size(min = 5, max = 255, message = \"\u0410\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442 5 \u0434\u043e 255 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     @NotBlank(message = \"\u0410\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438\")     @Email(message = \"Email \u0430\u0434\u0440\u0435\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 user@example.com\")     private String email;      @Schema(description = \"\u041f\u0430\u0440\u043e\u043b\u044c\", example = \"my_1secret1_password\")     @Size(max = 255, message = \"\u0414\u043b\u0438\u043d\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 255 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     private String password; }<\/code><\/pre>\n<p><strong>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/strong><\/p>\n<pre><code class=\"java\">@Data @Schema(description = \"\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e\") public class SignInRequest {      @Schema(description = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\", example = \"Jon\")     @Size(min = 5, max = 50, message = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442 5 \u0434\u043e 50 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     @NotBlank(message = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438\")     private String username;      @Schema(description = \"\u041f\u0430\u0440\u043e\u043b\u044c\", example = \"my_1secret1_password\")     @Size(min = 8, max = 255, message = \"\u0414\u043b\u0438\u043d\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0442 8 \u0434\u043e 255 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     @NotBlank(message = \"\u041f\u0430\u0440\u043e\u043b\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438\")     private String password; }<\/code><\/pre>\n<p><strong>\u041e\u0442\u0432\u0435\u0442 \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/strong><\/p>\n<pre><code class=\"java\">@Data @Builder @NoArgsConstructor @AllArgsConstructor @Schema(description = \"\u041e\u0442\u0432\u0435\u0442 c \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430\") public class JwtAuthenticationResponse {     @Schema(description = \"\u0422\u043e\u043a\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0430\", example = \"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTYyMjUwNj...\")     private String token; }<\/code><\/pre>\n<h4>\u0421\u0435\u0440\u0432\u0438\u0441\u044b<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 jwt, \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438.<\/p>\n<pre><code class=\"java\">@Service public class JwtService {     @Value(\"${token.signing.key}\")     private String jwtSigningKey;      \/**      * \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u0430      *      * @param token \u0442\u043e\u043a\u0435\u043d      * @return \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      *\/     public String extractUserName(String token) {         return extractClaim(token, Claims::getSubject);     }      \/**      * \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430      *      * @param userDetails \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      * @return \u0442\u043e\u043a\u0435\u043d      *\/     public String generateToken(UserDetails userDetails) {         Map&lt;String, Object> claims = new HashMap&lt;>();         if (userDetails instanceof User customUserDetails) {             claims.put(\"id\", customUserDetails.getId());             claims.put(\"email\", customUserDetails.getEmail());             claims.put(\"role\", customUserDetails.getRole());         }         return generateToken(claims, userDetails);     }      \/**      * \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u043e\u043a\u0435\u043d\u0430 \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c      *      * @param token       \u0442\u043e\u043a\u0435\u043d      * @param userDetails \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      * @return true, \u0435\u0441\u043b\u0438 \u0442\u043e\u043a\u0435\u043d \u0432\u0430\u043b\u0438\u0434\u0435\u043d      *\/     public boolean isTokenValid(String token, UserDetails userDetails) {         final String userName = extractUserName(token);         return (userName.equals(userDetails.getUsername())) &amp;&amp; !isTokenExpired(token);     }      \/**      * \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u0430      *      * @param token           \u0442\u043e\u043a\u0435\u043d      * @param claimsResolvers \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445      * @param &lt;T>             \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445      * @return \u0434\u0430\u043d\u043d\u044b\u0435      *\/     private &lt;T> T extractClaim(String token, Function&lt;Claims, T> claimsResolvers) {         final Claims claims = extractAllClaims(token);         return claimsResolvers.apply(claims);     }      \/**      * \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430      *      * @param extraClaims \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435      * @param userDetails \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      * @return \u0442\u043e\u043a\u0435\u043d      *\/     private String generateToken(Map&lt;String, Object> extraClaims, UserDetails userDetails) {         return Jwts.builder().setClaims(extraClaims).setSubject(userDetails.getUsername())                 .setIssuedAt(new Date(System.currentTimeMillis()))                 .setExpiration(new Date(System.currentTimeMillis() + 100000 * 60 * 24))                 .signWith(getSigningKey(), SignatureAlgorithm.HS256).compact();     }      \/**      * \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0442\u043e\u043a\u0435\u043d\u0430 \u043d\u0430 \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u044c      *      * @param token \u0442\u043e\u043a\u0435\u043d      * @return true, \u0435\u0441\u043b\u0438 \u0442\u043e\u043a\u0435\u043d \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u0435\u043d      *\/     private boolean isTokenExpired(String token) {         return extractExpiration(token).before(new Date());     }      \/**      * \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u044b \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430      *      * @param token \u0442\u043e\u043a\u0435\u043d      * @return \u0434\u0430\u0442\u0430 \u0438\u0441\u0442\u0435\u0447\u0435\u043d\u0438\u044f      *\/     private Date extractExpiration(String token) {         return extractClaim(token, Claims::getExpiration);     }      \/**      * \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u0430      *      * @param token \u0442\u043e\u043a\u0435\u043d      * @return \u0434\u0430\u043d\u043d\u044b\u0435      *\/     private Claims extractAllClaims(String token) {         return Jwts.parser().setSigningKey(getSigningKey()).build().parseClaimsJws(token)                 .getBody();     }      \/**      * \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0442\u043e\u043a\u0435\u043d\u0430      *      * @return \u043a\u043b\u044e\u0447      *\/     private Key getSigningKey() {         byte[] keyBytes = Decoders.BASE64.decode(jwtSigningKey);         return Keys.hmacShaKeyFor(keyBytes);     } }<\/code><\/pre>\n<h4>\u0421\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438<\/h4>\n<pre><code class=\"java\">@Service @RequiredArgsConstructor public class UserService {     private final UserRepository repository;      \/**      * \u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      *      * @return \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c      *\/     public User save(User user) {         return repository.save(user);     }       \/**      * \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      *      * @return \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c      *\/     public User create(User user) {         if (repository.existsByUsername(user.getUsername())) {             \/\/ \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430 \u0441\u0432\u043e\u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f             throw new RuntimeException(\"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u0442\u0430\u043a\u0438\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442\");         }          if (repository.existsByEmail(user.getEmail())) {             throw new RuntimeException(\"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u0442\u0430\u043a\u0438\u043c email \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442\");         }          return save(user);     }      \/**      * \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      *      * @return \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c      *\/     public User getByUsername(String username) {         return repository.findByUsername(username)                 .orElseThrow(() -> new UsernameNotFoundException(\"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\"));      }      \/**      * \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      * &lt;p>      * \u041d\u0443\u0436\u0435\u043d \u0434\u043b\u044f Spring Security      *      * @return \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c      *\/     public UserDetailsService userDetailsService() {         return this::getByUsername;     }      \/**      * \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      *      * @return \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c      *\/     public User getCurrentUser() {         \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 Spring Security         var username = SecurityContextHolder.getContext().getAuthentication().getName();         return getByUsername(username);     }       \/**      * \u0412\u044b\u0434\u0430\u0447\u0430 \u043f\u0440\u0430\u0432 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e      * &lt;p>      * \u041d\u0443\u0436\u0435\u043d \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438      *\/     @Deprecated     public void getAdmin() {         var user = getCurrentUser();         user.setRole(Role.ROLE_ADMIN);         save(user);     } }<\/code><\/pre>\n<h4>\u0421\u0435\u0440\u0432\u0438\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438<\/h4>\n<p>\u0411\u0438\u043d\u044b <code>PasswordEncoder<\/code> \u0438 <code>AuthenticationManager<\/code> \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043f\u043e\u0437\u0436\u0435.<\/p>\n<pre><code class=\"java\">@Service @RequiredArgsConstructor public class AuthenticationService {     private final UserService userService;     private final JwtService jwtService;     private final PasswordEncoder passwordEncoder;     private final AuthenticationManager authenticationManager;      \/**      * \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      *      * @param request \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      * @return \u0442\u043e\u043a\u0435\u043d      *\/     public JwtAuthenticationResponse signUp(SignUpRequest request) {          var user = User.builder()                 .username(request.getUsername())                 .email(request.getEmail())                 .password(passwordEncoder.encode(request.getPassword()))                 .role(Role.ROLE_USER)                 .build();          userService.create(user);          var jwt = jwtService.generateToken(user);         return new JwtAuthenticationResponse(jwt);     }      \/**      * \u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      *      * @param request \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      * @return \u0442\u043e\u043a\u0435\u043d      *\/     public JwtAuthenticationResponse signIn(SignInRequest request) {         authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(                 request.getUsername(),                 request.getPassword()         ));          var user = userService                 .userDetailsService()                 .loadUserByUsername(request.getUsername());          var jwt = jwtService.generateToken(user);         return new JwtAuthenticationResponse(jwt);     } }<\/code><\/pre>\n<h4>\u041a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0444\u0438\u043b\u044c\u0442\u0440<\/h4>\n<p>\u0424\u0438\u043b\u044c\u0442\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 <code>OncePerRequestFilter<\/code>, \u0447\u0442\u043e \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430. <\/p>\n<pre><code class=\"java\">@Component @RequiredArgsConstructor public class JwtAuthenticationFilter extends OncePerRequestFilter {     public static final String BEARER_PREFIX = \"Bearer \";     public static final String HEADER_NAME = \"Authorization\";     private final JwtService jwtService;     private final UserService userService;      @Override     protected void doFilterInternal(             @NonNull HttpServletRequest request,             @NonNull HttpServletResponse response,             @NonNull FilterChain filterChain     ) throws ServletException, IOException {          \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430         var authHeader = request.getHeader(HEADER_NAME);         if (StringUtils.isEmpty(authHeader) || !StringUtils.startsWith(authHeader, BEARER_PREFIX)) {             filterChain.doFilter(request, response);             return;         }          \/\/ \u041e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u0430         var jwt = authHeader.substring(BEARER_PREFIX.length());         var username = jwtService.extractUserName(jwt);          if (StringUtils.isNotEmpty(username) &amp;&amp; SecurityContextHolder.getContext().getAuthentication() == null) {             UserDetails userDetails = userService                     .userDetailsService()                     .loadUserByUsername(username);              \/\/ \u0415\u0441\u043b\u0438 \u0442\u043e\u043a\u0435\u043d \u0432\u0430\u043b\u0438\u0434\u0435\u043d, \u0442\u043e \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f             if (jwtService.isTokenValid(jwt, userDetails)) {                 SecurityContext context = SecurityContextHolder.createEmptyContext();                  UsernamePasswordAuthenticationToken authToken = new UsernamePasswordAuthenticationToken(                         userDetails,                         null,                         userDetails.getAuthorities()                 );                  authToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));                 context.setAuthentication(authToken);                 SecurityContextHolder.setContext(context);             }         }         filterChain.doFilter(request, response);     } }<\/code><\/pre>\n<h4>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Spring Security<\/h4>\n<pre><code class=\"java\">@Configuration @EnableWebSecurity @EnableMethodSecurity @RequiredArgsConstructor public class SecurityConfiguration {     private final JwtAuthenticationFilter jwtAuthenticationFilter;     private final UserService userService;      @Bean     public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {         http.csrf(AbstractHttpConfigurer::disable)                 \/\/ \u0421\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 CORS (\u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441\u043e \u0432\u0441\u0435\u0445 \u0434\u043e\u043c\u0435\u043d\u043e\u0432)                 .cors(cors -> cors.configurationSource(request -> {                     var corsConfiguration = new CorsConfiguration();                     corsConfiguration.setAllowedOriginPatterns(List.of(\"*\"));                     corsConfiguration.setAllowedMethods(List.of(\"GET\", \"POST\", \"PUT\", \"DELETE\", \"OPTIONS\"));                     corsConfiguration.setAllowedHeaders(List.of(\"*\"));                     corsConfiguration.setAllowCredentials(true);                     return corsConfiguration;                 }))                 \/\/ \u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u043c \u0442\u043e\u0447\u043a\u0430\u043c                 .authorizeHttpRequests(request -> request                         \/\/ \u041c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u0443\u0442\u044c, * - 1 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438, ** - \u043b\u044e\u0431\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438                         .requestMatchers(\"\/auth\/**\").permitAll()                         .requestMatchers(\"\/swagger-ui\/**\", \"\/swagger-resources\/*\", \"\/v3\/api-docs\/**\").permitAll()                         .requestMatchers(\"\/endpoint\", \"\/admin\/**\").hasRole(\"ADMIN\")                         .anyRequest().authenticated())                 .sessionManagement(manager -> manager.sessionCreationPolicy(STATELESS))                 .authenticationProvider(authenticationProvider())                 .addFilterBefore(jwtAuthenticationFilter, UsernamePasswordAuthenticationFilter.class);         return http.build();     }      @Bean     public PasswordEncoder passwordEncoder() {         return new BCryptPasswordEncoder();     }      @Bean     public AuthenticationProvider authenticationProvider() {         DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();         authProvider.setUserDetailsService(userService.userDetailsService());         authProvider.setPasswordEncoder(passwordEncoder());         return authProvider;     }      @Bean     public AuthenticationManager authenticationManager(AuthenticationConfiguration config)             throws Exception {         return config.getAuthenticationManager();     } }<\/code><\/pre>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u044d\u043d\u043f\u043e\u0438\u043d\u0442\u043e\u0432, <\/p>\n<ul>\n<li>\n<p><code>permitAll<\/code> &#8212; \u042d\u043d\u0434\u043f\u043e\u0438\u043d\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0432\u0441\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c, \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u0438 \u043d\u0435\u0442<\/p>\n<\/li>\n<li>\n<p><code>authenticated<\/code> &#8212; \u0422\u043e\u043b\u044c\u043a\u043e \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438<\/p>\n<\/li>\n<li>\n<p><code>hasRole<\/code> &#8212; \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0443\u044e \u0440\u043e\u043b\u044c, \u0438, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u044b\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c<\/p>\n<\/li>\n<li>\n<p><code>hasAnyRole<\/code> &#8212; \u0414\u043e\u043b\u0436\u0435\u043d \u0438\u043c\u0435\u0442\u044c \u043e\u0434\u043d\u0443 \u0438\u0437 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0440\u043e\u043b\u0435\u0439 <em>(\u043d\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u0432 \u043a\u043e\u0434\u0435)<\/em><\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0435\u0441\u043b\u0438 \u0432\u0430\u0441 \u043d\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0443\u043c\u0435\u043d\u0438\u0435 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e <code>authorizeHttpRequests<\/code> \u0445\u0432\u0430\u0442\u0438\u0442 \u0434\u043b\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u0432\u044b \u043d\u0435 \u0441\u0442\u0430\u043d\u0435\u0442\u0435 Middle \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u043c. \u041d\u043e \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435, \u043f\u0440\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/docs.spring.io\/spring-security\/reference\/index.html\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442<\/a>.<\/p>\n<h4>\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b<\/h4>\n<pre><code class=\"java\">@RestController @RequestMapping(\"\/auth\") @RequiredArgsConstructor @Tag(name = \"\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\") public class AuthController {     private final AuthenticationService authenticationService;      @Operation(summary = \"\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\")     @PostMapping(\"\/sign-up\")     public JwtAuthenticationResponse signUp(@RequestBody @Valid SignUpRequest request) {         return authenticationService.signUp(request);     }      @Operation(summary = \"\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\")     @PostMapping(\"\/sign-in\")     public JwtAuthenticationResponse signIn(@RequestBody @Valid SignInRequest request) {         return authenticationService.signIn(request);     } }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438.<\/p>\n<pre><code class=\"java\">@RestController @RequestMapping(\"\/example\") @RequiredArgsConstructor @Tag(name = \"\u0410\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f\") public class ExampleController {     private final UserService service;      @GetMapping     @Operation(summary = \"\u0414\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\")     public String example() {         return \"Hello, world!\";     }      @GetMapping(\"\/admin\")     @Operation(summary = \"\u0414\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 \u0441 \u0440\u043e\u043b\u044c\u044e ADMIN\")     @PreAuthorize(\"hasRole('ADMIN')\")     public String exampleAdmin() {         return \"Hello, admin!\";     }      @GetMapping(\"\/get-admin\")     @Operation(summary = \"\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u043e\u043b\u044c ADMIN (\u0434\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438)\")     public void getAdmin() {         service.getAdmin();     } }<\/code><\/pre>\n<h4>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>\u0412\u0441\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0442\u043e\u0447\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Swagger, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0430 <a href=\"http:\/\/localhost:8080\/swagger-ui\/index.html\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:8080\/swagger-ui\/index.html<\/a>. \u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e, \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fa5\/0ba\/0ce\/fa50ba0ce9faf44a86173ddb904b6b2f.png\" alt=\"\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Swagger\" title=\"\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Swagger\" width=\"3456\" height=\"2216\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fa5\/0ba\/0ce\/fa50ba0ce9faf44a86173ddb904b6b2f.png\"\/><\/p>\n<div><figcaption>\u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 Swagger<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Postman.<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0443\u0431\u0435\u0434\u0438\u043c\u0441\u044f, \u0447\u0442\u043e \u0431\u0435\u0437 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u0441\u044f \u043a \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u043e\u043c\u0443 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0443, \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0441\u0442\u0430\u0442\u0443\u0441 403, \u0430 \u043e\u0442\u0432\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f3e\/853\/e78\/f3e853e783c2bb7d25ca8ba0f8e22da7.png\" alt=\"\u041e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u043c\u0443 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0443\" title=\"\u041e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u043c\u0443 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0443\" width=\"2608\" height=\"762\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f3e\/853\/e78\/f3e853e783c2bb7d25ca8ba0f8e22da7.png\"\/><\/p>\n<div><figcaption>\u041e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u043c\u0443 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442\u0443<\/figcaption><\/div>\n<\/figure>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u043b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0432 \u0442\u0438\u043f \u0442\u0435\u043b\u0430, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 JSON.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6c8\/adc\/e71\/6c8adce7149d800a1e38f9073ad8bcd4.png\" alt=\"\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\" title=\"\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\" width=\"2596\" height=\"974\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6c8\/adc\/e71\/6c8adce7149d800a1e38f9073ad8bcd4.png\"\/><\/p>\n<div><figcaption>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c<\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u0435\u0440\u043d\u0451\u0442 \u0442\u043e\u043a\u0435\u043d, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0438 \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u043e\u0448\u0438\u0431\u043a\u0438 (\u043e\u0448\u0438\u0431\u043a\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0437\u0430\u043d\u044f\u0442\u043e\u0435 \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f) \u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0443\u0441 <em>403<\/em>. <em>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0431\u044b \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u043e\u0448\u0438\u0431\u043e\u043a, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 ControllerAdvice (\u043c\u043e\u0436\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u044c Zalando Problem). <\/em><\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0447\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u043e\u043a\u0435\u043d\u0430, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0439\u0434\u0451\u043c \u043d\u0430 <a href=\"https:\/\/jwt.io\" rel=\"noopener noreferrer nofollow\">jwt.io<\/a> \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u0442 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7e0\/341\/294\/7e0341294ab6df6ae6e28bc015e8bed4.png\" alt=\"\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430\" title=\"\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430\" width=\"2402\" height=\"1378\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7e0\/341\/294\/7e0341294ab6df6ae6e28bc015e8bed4.png\"\/><\/p>\n<div><figcaption>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0430\u043a \u0436\u0435, \u0443\u043a\u0430\u0437\u0430\u0432 \u0441\u0432\u043e\u0439 \u0441\u0435\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043a\u043b\u044e\u0447, \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u0430.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430\u0445 \u043a \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u0443, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u043d\u043e Postman \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043d\u0430\u043c \u043b\u0438\u0448\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u0438\u043f\u0430 \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430 \u0432\u0441\u0451 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e, \u043d\u0430 \u043f\u0430\u043f\u043a\u0443 \u0438 \u043d\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u0439\u0442\u0438 \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <strong><em>Authorization<\/em><\/strong> \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0442\u0438\u043f \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 <strong><em>Bearer Token<\/em><\/strong>. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/8b8\/c56\/81f\/8b8c5681f0137f772cfc826c17258673.png\" alt=\"\u0412\u044b\u0431\u043e\u0440 \u0442\u0438\u043f\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\" title=\"\u0412\u044b\u0431\u043e\u0440 \u0442\u0438\u043f\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\" width=\"2632\" height=\"1322\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8b8\/c56\/81f\/8b8c5681f0137f772cfc826c17258673.png\"\/><\/p>\n<div><figcaption>\u0412\u044b\u0431\u043e\u0440 \u0442\u0438\u043f\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0412 \u043f\u043e\u044f\u0432\u0438\u0432\u0448\u0435\u0435\u0441\u044f \u043f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0438\u043c \u0442\u043e\u043a\u0435\u043d.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d58\/22c\/881\/d5822c881e7ae9eb26db132467f8ea38.png\" alt=\"\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d\" title=\"\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d\" width=\"2598\" height=\"808\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d58\/22c\/881\/d5822c881e7ae9eb26db132467f8ea38.png\"\/><\/p>\n<div><figcaption>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u043e\u043a\u0435\u043d<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e Postman \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a <em>(Authorization)<\/em> \u0441 \u043d\u0443\u0436\u043d\u044b\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c, \u043d\u043e \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u0440\u0430\u043d\u0435\u0435, \u044d\u0442\u043e \u0442\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e46\/1cb\/eff\/e461cbeff7cd4b992fcb485a3772db03.png\" alt=\"\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c\" title=\"\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c\" width=\"2584\" height=\"730\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e46\/1cb\/eff\/e461cbeff7cd4b992fcb485a3772db03.png\"\/><\/p>\n<div><figcaption>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0442\u043e\u043a\u0435\u043d \u0432\u0432\u0435\u0434\u0451\u043d, \u043f\u043e\u0432\u0442\u043e\u0440\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d28\/670\/727\/d28670727b437f3dcd88d8bdf6b2c001.png\" alt=\"\u0417\u0430\u043f\u0440\u043e\u0441 \u043a \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u043e\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443\" title=\"\u0417\u0430\u043f\u0440\u043e\u0441 \u043a \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u043e\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443\" width=\"2596\" height=\"748\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d28\/670\/727\/d28670727b437f3dcd88d8bdf6b2c001.png\"\/><\/p>\n<div><figcaption>\u0417\u0430\u043f\u0440\u043e\u0441 \u043a \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u043e\u043c\u0443 \u0440\u0435\u0441\u0443\u0440\u0441\u0443<\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u043e\u0448\u0451\u043b \u0438 \u0432\u0435\u0440\u043d\u0443\u043b \u0441\u0442\u0440\u043e\u043a\u0443 <em>&#171;Hello, World!&#187;<\/em>, \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>\u041f\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0438, \u043f\u0440\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c username \u0438 \u043f\u0430\u0440\u043e\u043b\u044c, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0432\u0435\u0440\u043d\u044b\u0435, \u0432\u0435\u0440\u043d\u0451\u0442\u0441\u044f \u0442\u043e\u043a\u0435\u043d, \u0430 \u044d\u043d\u0434\u043f\u043e\u0438\u043d\u0442, \u0442\u0440\u0435\u0431\u0443\u044e\u0449\u0438\u0439 \u0440\u043e\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u044e\u0449\u0443\u044e \u0440\u043e\u043b\u044c.<\/p>\n<h4>\u0411\u043e\u043d\u0443\u0441<\/h4>\n<p>Postman \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443\u043f\u0440\u043e\u0449\u0430\u044e\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439, \u043e\u0434\u043d\u0430 \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 &#8212; \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438 \u0442\u0435\u0441\u0442\u044b, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f. <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0436\u043c\u0451\u043c \u043d\u0430 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0438 \u0432\u044b\u0431\u0435\u0440\u0435\u043c \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <strong><em>Variables<\/em><\/strong>, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c 2 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td>\n<p align=\"left\"><strong>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">url<\/p>\n<\/td>\n<td>\n<p align=\"left\"><a href=\"http:\/\/localhost:8080\" rel=\"noopener noreferrer nofollow\">http:\/\/localhost:8080<\/a><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">token<\/p>\n<\/td>\n<td>\n<p align=\"left\">\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0414\u043e\u043b\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/89d\/2a2\/879\/89d2a2879c47b6b5fc7b5c756da301d8.png\" alt=\"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445\" title=\"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445\" width=\"2590\" height=\"600\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/89d\/2a2\/879\/89d2a2879c47b6b5fc7b5c756da301d8.png\"\/><\/p>\n<div><figcaption>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u043c \u043f\u043e\u043b\u0435 \u0432\u0432\u043e\u0434\u0430 Postman, \u043e\u043d\u0438 \u0438\u043c\u0435\u044e\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 <code>{{varname}}<\/code>. \u041d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0439 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/500\/7a8\/379\/5007a8379a1c40162158d134f09e7bfa.png\" alt=\"\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u043a \u0442\u043e\u043a\u0435\u043d \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\" title=\"\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u043a \u0442\u043e\u043a\u0435\u043d \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438\" width=\"1562\" height=\"840\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/500\/7a8\/379\/5007a8379a1c40162158d134f09e7bfa.png\"\/><\/p>\n<div><figcaption>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043a\u0430\u043a \u0442\u043e\u043a\u0435\u043d \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438<\/figcaption><\/div>\n<\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0432\u0435\u0440\u043d\u043e, \u0442\u0435\u043a\u0441\u0442 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u0438 \u043f\u0440\u0438 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432\u0435\u0440\u043d\u0451\u043c\u0441\u044f \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438, \u043f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u0432 URL \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u0434\u043e\u043c\u0435\u043d \u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e &#8212; <code>{{url}}\/auth\/sign-up<\/code>, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0432 \u0437\u0430\u043f\u0438\u0441\u044c \u0438, \u0435\u0441\u043b\u0438 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0434\u043e\u043c\u0435\u043d\u0435, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0443\u0442\u0451\u043c \u0437\u0430\u043c\u0435\u043d\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u0430 \u043d\u0435 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<p>\u0412\u0442\u043e\u0440\u044b\u043c \u0448\u0430\u0433\u043e\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u0432\u043e \u0432\u043a\u043b\u0430\u0434\u043a\u0443 <strong>Tests<\/strong> \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434.<\/p>\n<pre><code class=\"javascript\">pm.test(\"Status code is 200\", function () {     pm.response.to.have.status(200); });  pm.test(\"Set token to variable\", () => {     var responseJson = pm.response.json();     pm.collectionVariables.set(\"token\", responseJson.token); })<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 2 \u0442\u0435\u0441\u0442\u0430, \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0443\u0441 \u043e\u0442\u0432\u0435\u0442\u0430 200, \u0432\u0442\u043e\u0440\u043e\u0439 \u0436\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0438\u0437 \u043e\u0442\u0432\u0435\u0442\u0430 \u0442\u043e\u043a\u0435\u043d \u0438 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u0422\u0435\u043f\u0435\u0440\u044c, \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0443 \u0432\u0430\u0441 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0432\u043a\u043b\u0430\u0434\u043a\u0430 <strong><em>Tests Result<\/em><\/strong> \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 2\/2, \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u0431\u0430 \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u0448\u043b\u0438 \u0438 \u0442\u043e\u043a\u0435\u043d \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4b1\/ddd\/851\/4b1ddd85117e3d91c8bea63c05325428.png\" alt=\"\u041f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\" title=\"\u041f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\" width=\"2604\" height=\"996\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4b1\/ddd\/851\/4b1ddd85117e3d91c8bea63c05325428.png\"\/><\/p>\n<div><figcaption>\u041f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u043e\u0432<\/figcaption><\/div>\n<\/figure>\n<p>\u0422\u0435\u0441\u0442\u044b \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u043e\u043a\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e, \u0447\u0442\u043e \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u0430\u0441 \u043e\u0442 \u0440\u0443\u0442\u0438\u043d\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b. \u0422\u0430\u043a \u0436\u0435 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043b\u0443\u0447\u0448\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c <strong><em>Authorization<\/em><\/strong> \u043d\u0430 <strong><em>No Auth<\/em><\/strong>, \u0447\u0442\u043e \u0431\u044b \u043f\u0440\u043e\u0441\u0440\u043e\u0447\u0435\u043d\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b \u043d\u0435 \u043c\u0435\u0448\u0430\u043b\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0443\u0442 &#8212; <a href=\"https:\/\/github.com\/MinusD\/SpringSecurity\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/MinusD\/SpringSecurity<\/a>.<\/p>\n<h4>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <\/h4>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0438 \u0440\u043e\u043b\u0435\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e \u043a\u043e\u0434\u0430 \u0438\u043b\u0438 \u0442\u0435\u043a\u0441\u0442\u0430, \u0436\u0434\u0443 \u0432\u0430\u0441 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0438\u043b\u0438 \u0432 issues \u043d\u0430 GitHub.<\/p>\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\/784508\/\"> https:\/\/habr.com\/ru\/articles\/784508\/<\/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>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0435 \u043b\u044e\u0431\u0438\u0442\u0435 \u0442\u0435\u043e\u0440\u0438\u044e, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 <a href=\"#%D0%BF%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D0%BA%D0%B0\" rel=\"noopener noreferrer nofollow\">\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043e\u0442 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u043a \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Spring Security \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f, Spring Security 6, \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u0445 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u043e\u0432 \u043d\u0430 \u044d\u0442\u0443 \u0442\u0435\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c JWT-\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Boot 3 \u0438 Spring Security 6, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438. \u0426\u0435\u043b\u044c \u0441\u0442\u0430\u0442\u044c\u0438 &#8212; \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JWT-\u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e \u0441 API-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430\u043c\u0438. \u0411\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043e \u043a\u0430\u043a \u0431\u0430\u0437\u043e\u0432\u043e\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435, \u0442\u0430\u043a \u0438 \u0440\u043e\u043b\u0435\u0432\u0430\u044f \u043c\u043e\u0434\u0435\u043b\u044c. \u0421\u0442\u0430\u0442\u044c\u044f \u043f\u043e\u0434\u043e\u0439\u0434\u0451\u0442 \u043a\u0430\u043a \u043d\u043e\u0432\u0438\u0447\u043a\u0430\u043c, \u0442\u0430\u043a \u0438 \u043f\u0440\u043e\u0434\u0432\u0438\u043d\u0443\u0442\u044b\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u043e\u0439 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u0441\u0432\u043e\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u044b. <\/p>\n<h2>\u0422\u0435\u043e\u0440\u0438\u044f<\/h2>\n<p>\u041f\u0440\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u0440\u0430\u0442\u043a\u0430\u044f \u0432\u044b\u0436\u0438\u043c\u043a\u0430. JWT \u0438\u043b\u0438 Json Web Token &#8212; \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u044b\u043c, \u0442.\u0435. \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0432\u043e\u0435\u0439 \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043a \u043a\u0430\u043a\u0438\u043c-\u043b\u0438\u0431\u043e \u0432\u043d\u0435\u0448\u043d\u0438\u043c \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c. \u0422\u043e\u043a\u0435\u043d \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 3-\u0445 \u0447\u0430\u0441\u0442\u0435\u0439:<\/p>\n<ul>\n<li>\n<p><strong>\u0417\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a<\/strong> &#8212; \u0445\u0440\u0430\u043d\u0438\u0442 \u0442\u0438\u043f \u0442\u043e\u043a\u0435\u043d\u0430 \u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430<\/strong> &#8212; \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0438 \u0442\u0434 (\u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0441\u0451 \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e)<\/p>\n<\/li>\n<li>\n<p><strong>\u041f\u043e\u0434\u043f\u0438\u0441\u044c<\/strong> &#8212; \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0443\u0442\u0451\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0447\u0442\u043e \u0442\u043e\u043a\u0435\u043d \u043d\u0435 \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0451\u043d \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0442\u043e\u043a\u0435\u043d\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043e \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435. <a href=\"https:\/\/jwt.io\/introduction\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e JWT.<\/a><\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 JWT <\/figcaption><\/div>\n<\/figure>\n<p>\u041d\u0435 \u043c\u0430\u043b\u043e\u0432\u0430\u0436\u043d\u044b\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u0430 \u0432 \u0442\u0430\u043a\u043e\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u0442\u043e \u0435\u0433\u043e \u0443\u0432\u0438\u0434\u0438\u0442, \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u043b\u044e\u0431\u044b\u043c jwt encoder-\u043e\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <a href=\"https:\/\/jwt.io\/\" rel=\"noopener noreferrer nofollow\">jwt.io<\/a>. \u041f\u0440\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0441\u043a\u0440\u044b\u0442\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<h3>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f<\/h3>\n<p>\u041f\u0440\u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0443 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e <\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u043d\u0430 \u0438\u0445 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043f\u0430\u0440\u043e\u043b\u044c \u0448\u0438\u0444\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>PasswordEncoder<\/code><\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 jpa-\u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f<\/p>\n<\/li>\n<li>\n<p><code>JwtService<\/code> \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0443<\/p>\n<\/li>\n<\/ol>\n<h3>\u0412\u0445\u043e\u0434 \u0432 \u0430\u043a\u043a\u0430\u0443\u043d\u0442<\/h3>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0445\u043e\u0434\u0430 \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f.<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u043d\u0430 \u0432\u0445\u043e\u0434<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0451\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <code>UsernamePasswordAuthenticationToken<\/code>\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>AuthenticationManager<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0441\u0451 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e &#8212; \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0451\u043d \u0442\u043e\u043a\u0435\u043d, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442, \u043e\u0448\u0438\u0431\u043a\u0430 403<\/p>\n<\/li>\n<\/ol>\n<p><a class=\"anchor\" name=\"%D0%BF%D1%80%D0%B0%D0%BA%D1%82%D0%B8%D0%BA%D0%B0\" id=\"\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430\">\u0438\u043a\u0430&#187;><\/a><\/p>\n<h3>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/h3>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 H2. <\/p>\n<h4>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438<\/h4>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;dependencies>     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-web&lt;\/artifactId>     &lt;\/dependency>      &lt;!-- \u0411\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 -->     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-data-jpa&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>com.h2database&lt;\/groupId>         &lt;artifactId>h2&lt;\/artifactId>         &lt;scope>runtime&lt;\/scope>     &lt;\/dependency>      &lt;!-- \u0423\u0442\u0438\u043b\u0438\u0442\u044b -->     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-validation&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>org.apache.commons&lt;\/groupId>         &lt;artifactId>commons-lang3&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>org.springdoc&lt;\/groupId>         &lt;artifactId>springdoc-openapi-starter-webmvc-ui&lt;\/artifactId>         &lt;version>2.2.0&lt;\/version>     &lt;\/dependency>      &lt;!-- \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c -->     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-security&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>io.jsonwebtoken&lt;\/groupId>         &lt;artifactId>jjwt-api&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>io.jsonwebtoken&lt;\/groupId>         &lt;artifactId>jjwt-impl&lt;\/artifactId>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>io.jsonwebtoken&lt;\/groupId>         &lt;artifactId>jjwt-jackson&lt;\/artifactId>     &lt;\/dependency>      &lt;!-- \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 -->     &lt;dependency>         &lt;groupId>org.springframework.boot&lt;\/groupId>         &lt;artifactId>spring-boot-starter-test&lt;\/artifactId>         &lt;scope>test&lt;\/scope>     &lt;\/dependency>     &lt;dependency>         &lt;groupId>org.springframework.security&lt;\/groupId>         &lt;artifactId>spring-security-test&lt;\/artifactId>         &lt;scope>test&lt;\/scope>     &lt;\/dependency> &lt;\/dependencies>  &lt;dependencyManagement>     &lt;dependencies>         &lt;dependency>             &lt;groupId>io.jsonwebtoken&lt;\/groupId>             &lt;artifactId>jjwt-api&lt;\/artifactId>             &lt;version>0.12.3&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>io.jsonwebtoken&lt;\/groupId>             &lt;artifactId>jjwt-impl&lt;\/artifactId>             &lt;version>0.12.3&lt;\/version>         &lt;\/dependency>         &lt;dependency>             &lt;groupId>io.jsonwebtoken&lt;\/groupId>             &lt;artifactId>jjwt-jackson&lt;\/artifactId>             &lt;version>0.12.3&lt;\/version>         &lt;\/dependency>     &lt;\/dependencies> &lt;\/dependencyManagement><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h4>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<pre><code class=\"yaml\">spring:   application:     name: security-security   datasource:     url: jdbc:h2:mem:security-security     driverClassName: org.h2.Driver     username: root     password: root   jpa:     hibernate:       ddl-auto: create-drop     show-sql: true     properties:       hibernate:         format_sql: true token:   signing:     key: 53A73E5F1C4E0A2D3B5F2D784E6A1B423D6F247D1F6E5C3A596D635A75327855<\/code><\/pre>\n<p>\u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u0432 pom \u0444\u0430\u0439\u043b\u0435 \u043d\u0435 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u043a\u043b\u044e\u0447 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u0440\u0443\u043a\u0438 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430, \u043e\u043d \u0441\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0430, \u0431\u0443\u0434\u044c\u0442\u0435 \u0441 \u044d\u0442\u0438\u043c \u043e\u0447\u0435\u043d\u044c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u044b. <\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439<\/h4>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u043e Spring Security \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>UserDetails<\/code> &#8212; \u0432 \u043d\u0451\u043c \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 Spring Security.<\/p>\n<pre><code class=\"java\">@Entity @Builder @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Table(name = \"users\") public class User implements UserDetails {     @Id     @Column(name = \"id\")     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = \"user_id_seq\")     @SequenceGenerator(name = \"user_id_seq\", sequenceName = \"user_id_seq\", allocationSize = 1)     private Long id;      @Column(name = \"username\", unique = true, nullable = false)     private String username;      @Column(name = \"password\", nullable = false)     private String password;      @Column(name = \"email\", unique = true, nullable = false)     private String email;      @Enumerated(EnumType.STRING)     @Column(name = \"role\", nullable = false)     private Role role;      @Override     public Collection&lt;? extends GrantedAuthority> getAuthorities() {         return List.of(new SimpleGrantedAuthority(role.name()));     }      @Override     public boolean isAccountNonExpired() {         return true;     }      @Override     public boolean isAccountNonLocked() {         return true;     }      @Override     public boolean isCredentialsNonExpired() {         return true;     }      @Override     public boolean isEnabled() {         return true;     } }<\/code><\/pre>\n<pre><code class=\"java\">public enum Role {     ROLE_USER,     ROLE_ADMIN }<\/code><\/pre>\n<p>\u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u043c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c 3 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430, \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0434 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0435\u0439.<\/p>\n<pre><code class=\"java\">@Repository public interface UserRepository extends JpaRepository&lt;User, Long> {     Optional&lt;User> findByUsername(String username);     boolean existsByUsername(String username);     boolean existsByEmail(String email); }<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c DTO \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438, \u0432\u0445\u043e\u0434\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0442\u043e\u043a\u0435\u043d\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e.<\/p>\n<p><strong>\u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/strong><\/p>\n<pre><code class=\"java\">@Data @Schema(description = \"\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e\") public class SignUpRequest {      @Schema(description = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\", example = \"Jon\")     @Size(min = 5, max = 50, message = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442 5 \u0434\u043e 50 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     @NotBlank(message = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438\")     private String username;      @Schema(description = \"\u0410\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b\", example = \"jondoe@gmail.com\")     @Size(min = 5, max = 255, message = \"\u0410\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442 5 \u0434\u043e 255 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     @NotBlank(message = \"\u0410\u0434\u0440\u0435\u0441 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0439 \u043f\u043e\u0447\u0442\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438\")     @Email(message = \"Email \u0430\u0434\u0440\u0435\u0441 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 user@example.com\")     private String email;      @Schema(description = \"\u041f\u0430\u0440\u043e\u043b\u044c\", example = \"my_1secret1_password\")     @Size(max = 255, message = \"\u0414\u043b\u0438\u043d\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 255 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     private String password; }<\/code><\/pre>\n<p><strong>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f<\/strong><\/p>\n<pre><code class=\"java\">@Data @Schema(description = \"\u0417\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0430\u0443\u0442\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044e\") public class SignInRequest {      @Schema(description = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\", example = \"Jon\")     @Size(min = 5, max = 50, message = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043e\u0442 5 \u0434\u043e 50 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     @NotBlank(message = \"\u0418\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438\")     private String username;      @Schema(description = \"\u041f\u0430\u0440\u043e\u043b\u044c\", example = \"my_1secret1_password\")     @Size(min = 8, max = 255, message = \"\u0414\u043b\u0438\u043d\u0430 \u043f\u0430\u0440\u043e\u043b\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0442 8 \u0434\u043e 255 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432\")     @NotBlank(message = \"\u041f\u0430\u0440\u043e\u043b\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438\")     private String password; }<\/code><\/pre>\n<p><strong>\u041e\u0442\u0432\u0435\u0442 \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430<\/strong><\/p>\n<pre><code class=\"java\">@Data @Builder @NoArgsConstructor @AllArgsConstructor @Schema(description = \"\u041e\u0442\u0432\u0435\u0442 c \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0430\") public class JwtAuthenticationResponse {     @Schema(description = \"\u0422\u043e\u043a\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f\u0430\", example = \"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTYyMjUwNj...\")     private String token; }<\/code><\/pre>\n<h4>\u0421\u0435\u0440\u0432\u0438\u0441\u044b<\/h4>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 jwt, \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c\u0438.<\/p>\n<pre><code class=\"java\">@Service public class JwtService {     @Value(\"${token.signing.key}\")     private String jwtSigningKey;      \/**      * \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u0430      *      * @param token \u0442\u043e\u043a\u0435\u043d      * @return \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      *\/     public String extractUserName(String token) {         return extractClaim(token, Claims::getSubject);     }      \/**      * \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430      *      * @param userDetails \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f      * @return \u0442\u043e\u043a\u0435\u043d      *\/     public String generateToken(UserDetails userDetails) {         Map&lt;S<\/code><\/pre>\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-364560","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364560","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=364560"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364560\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364560"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364560"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364560"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}