{"id":411414,"date":"2024-06-29T21:57:25","date_gmt":"2024-06-29T21:57:25","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=411414"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=411414","title":{"rendered":"<span>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u0431\u0435\u0434\u043d\u044b\u0445 \u0438\u043b\u0438 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c RBAC \u0434\u043b\u044f REST API \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e OPA<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/a08\/962\/928\/a08962928f72c627c04ce3ea20f45018.jpg\" width=\"1000\" height=\"800\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a08\/962\/928\/a08962928f72c627c04ce3ea20f45018.jpg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430:<\/p>\n<ul>\n<li>\n<p>\u041b\u0438\u0431\u043e \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043a \u043d\u0435\u043a\u0438\u043c \u0440\u043e\u043b\u044f\u043c\/scope\u2019\u0430\u043c;<\/p>\n<\/li>\n<li>\n<p>\u041b\u0438\u0431\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0431\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0431\u043e\u0440\u043e\u0434\u043e\u0439 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u044b\u043f\u0430\u0442\u044c \u0444\u0440\u0430\u0437\u0430\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 aba\u0441, xacml \u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430;\u00a0<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0437 \u043f\u043e\u0434\u0440\u0443\u0447\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0441\u043e\u0431\u0440\u0430\u0442\u044c RBAC \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u044e\u0449\u0438\u0439 REST, \u0442\u043e \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p><strong>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u043e?<\/strong><\/p>\n<ul>\n<li>\n<p><strong>POC<\/strong>: \u041f\u0440\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Proof of Concept \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0443\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043b\u0430\u043d. \u0410 \u0438\u043d\u043e\u0433\u0434\u0430 \u043e\u0442 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u0430\u043a \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0441\u0443\u0440\u0441\u044b<\/strong>: \u041f\u0440\u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432\u0435\u043b\u0438\u043a\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0447\u044c \u0441\u0430\u043c\u044b\u043c \u0442\u044f\u0436\u0435\u043b\u043e\u0432\u0435\u0441\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0438\u0445 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0439 \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p><strong>Firewall<\/strong>: \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0430\u0435\u0440\u0432\u043e\u043b\u0430 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0447\u0430\u0441\u0442\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0432\u0430 \u0431\u043b\u043e\u043a\u0430:  \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u043c \u0431\u043b\u043e\u043a\u043e\u043c. \u041f\u0443\u0441\u0442\u044c \u0438 \u0441 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c\u0438 \u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u0432\u0441\u044e \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0444\u0440\u0430\u0437\u0443:<\/p>\n<p>\u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e<em>\u0442\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 Nginx, \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0435\u0440\u0432\u0438\u0441, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 OPA, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d, \u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0435\u0440\u0432\u0438\u0441.<\/em><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0430\u0437\u0431\u043e\u0440 \u043f\u043e\u043b\u0435\u0442\u043e\u0432 \u0432\u0430\u043c \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 <a href=\"#implementation\" rel=\"noopener noreferrer nofollow\"><strong>\u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/strong><\/a><strong>.<\/strong><\/p>\n<h2>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c.\u00a0<\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0434\u0432\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>API Gateway;<\/p>\n<\/li>\n<li>\n<p>\u0411\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 REST API;<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2ac\/461\/cb8\/2ac461cb8d378d2579b8be9e2aa83772.png\" alt=\"\" title=\"\" width=\"431\" height=\"133\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2ac\/461\/cb8\/2ac461cb8d378d2579b8be9e2aa83772.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c REST API c CRUD-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. HTTP-\u043c\u0435\u0442\u043e\u0434 GET.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. HTTP-\u043c\u0435\u0442\u043e\u0434 POST.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. HTTP-\u043c\u0435\u0442\u043e\u0434 PUT.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. HTTP-\u043c\u0435\u0442\u043e\u0434 DELETE.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4a0\/67f\/c06\/4a067fc06177197839df96f5062bddc7.png\" width=\"682\" height=\"204\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4a0\/67f\/c06\/4a067fc06177197839df96f5062bddc7.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0430:<\/p>\n<ul>\n<li>\n<p>\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0427\u0438\u0442\u0430\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0410 \u0432\u043e\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440;<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/121\/a89\/65d\/121a8965d1e280a0d9c715751d2fde39.png\" width=\"802\" height=\"203\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/121\/a89\/65d\/121a8965d1e280a0d9c715751d2fde39.png\"\/><figcaption><\/figcaption><\/figure>\n<h2>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p>\u041a\u0442\u043e?<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<\/li>\n<li>\n<p>\u0418 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438?<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u043b\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.\u00a0<\/p>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5ac\/781\/7b0\/5ac7817b0b15eb4f12232783a203ca67.png\" width=\"592\" height=\"222\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ac\/781\/7b0\/5ac7817b0b15eb4f12232783a203ca67.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0433\u0434\u0435 \u0432\u0437\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. <\/strong>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d, \u043a\u0430\u043a \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u0435\u043f\u043e\u043a \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u0442 Keycloak \u0438 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f SSO Redhat, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u044f \u0431\u0443\u0434\u0443 \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u043e\u043a\u0435\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e Keycloak.<\/p>\n<p><strong>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<\/strong> \u041c\u0430\u0440\u043a\u0435\u0440\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 REST \u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<p>GET &#8212; \u044d\u0442\u043e \u0447\u0442\u0435\u043d\u0438\u0435, POST\/PUT &#8212; \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, DELETE &#8212; \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p><strong>\u0414\u0430\u043d\u043d\u044b\u0435.<\/strong> \u0414\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u043a\u0441\u0438 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0440\u043e\u0443\u0442. \u0422\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0442 \u0440\u043e\u0443\u0442 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d77\/b7d\/8d8\/d77b7d8d8d3c7322f9b98ae509790ae0.png\" width=\"676\" height=\"222\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d77\/b7d\/8d8\/d77b7d8d8d3c7322f9b98ae509790ae0.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>Gateway, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/strong><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0438\u0437 \u0432\u0441\u0435\u0445 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043a\u0443\u0431\u0438\u043a\u043e\u0432.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u043e\u043a\u0441\u0438\/gateway \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e Gateway \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u0443\u0431\u0438\u043a \u0432 \u0441\u0445\u0435\u043c\u0443 &#8212; \u043c\u043e\u0434\u0443\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6b1\/2ee\/395\/6b12ee3950e107a3de0611c3228797b6.png\" width=\"772\" height=\"304\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6b1\/2ee\/395\/6b12ee3950e107a3de0611c3228797b6.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0448\u0430 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u0432\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0438 \u043c\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435. \u0421 \u044d\u0442\u0438\u043c \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044f \u0432 Gateway.<\/p>\n<\/li>\n<li>\n<p>Gateway \u043d\u0430\u0434\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<p>&#8212; \u0417\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u043e\u043a\u0435\u043d \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435;<\/p>\n<p>&#8212; \u0412\u044b\u0434\u0435\u043b\u044f\u0435\u0442 HTTP-\u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c;<\/p>\n<p>&#8212;  \u0418\u0437 \u043f\u0443\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435;\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u044b \u0442\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044e \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0443 \u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0432\u0441\u0435<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d, \u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d7b\/903\/b51\/d7b903b5120b6909cd5add474a4e2154.png\" width=\"1152\" height=\"533\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d7b\/903\/b51\/d7b903b5120b6909cd5add474a4e2154.png\"\/><figcaption><\/figcaption><\/figure>\n<p><a class=\"anchor\" name=\"implementation\" id=\"implementation\"><\/a><\/p>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/strong><\/p>\n<p>\u0412\u0441\u0435. \u0421 \u0442\u0435\u043e\u0440\u0438\u0435\u0439 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438. \u0415\u0441\u043b\u0438 \u0447\u0435\u0441\u0442\u043d\u043e, \u0442\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0442\u0443\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u0441\u0430\u043c\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0427\u0435\u043c \u043b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0438 \u0438\u043c\u043f\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c OPA &#8212; <a href=\"https:\/\/www.openpolicyagent.org\" rel=\"noopener noreferrer nofollow\">https:\/\/www.openpolicyagent.org<\/a><\/p>\n<p>\u0414\u043b\u044f Gateway \u0432\u043e\u0437\u044c\u043c\u0443 Nginx &#8212; <a href=\"http:\/\/nginx.org\" rel=\"noopener noreferrer nofollow\">http:\/\/nginx.org<\/a><\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u043c\u0430\u0440\u043a\u0438 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e OPA \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 \u043f\u043e\u0434 Envoy &#8212; <a href=\"https:\/\/github.com\/open-policy-agent\/opa-envoy-plugin\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/open-policy-agent\/opa-envoy-plugin<\/a>, Traefic &#8212; <a href=\"https:\/\/doc.traefik.io\/traefik-enterprise\/v2.4\/middlewares\/opa\/\" rel=\"noopener noreferrer nofollow\">https:\/\/doc.traefik.io\/traefik-enterprise\/v2.4\/middlewares\/opa\/<\/a><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2cc\/868\/86f\/2cc86886f1712357b333baf5f1da88e7.png\" width=\"651\" height=\"303\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2cc\/868\/86f\/2cc86886f1712357b333baf5f1da88e7.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>Nginx<\/strong><\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Nginx \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439.<\/p>\n<details class=\"spoiler\">\n<summary>nginx.conf<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"nginx\">load_module modules\/ngx_http_js_module.so;  user  nginx; worker_processes  1;  error_log  \/var\/log\/nginx\/error.log warn; pid        \/var\/run\/nginx.pid;   events {     worker_connections  1024; }  http {     include       \/etc\/nginx\/mime.types;     default_type  application\/octet-stream;      log_format  main  '$remote_addr - $remote_user [$time_local] \"$request\" '                       '$status $body_bytes_sent \"$http_referer\" '                       '\"$http_user_agent\" \"$http_x_forwarded_for\"';      access_log  \/var\/log\/nginx\/access.log  main;      sendfile        on;     #tcp_nopush     on;      keepalive_timeout  65;      #gzip  on;      include \/etc\/nginx\/conf.d\/*.conf; } <\/code><\/pre>\n<\/div>\n<\/details>\n<p><strong>JWT<\/strong><\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Keycloak. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 Nginx \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<ul>\n<li>\n<p><em>\/jwt\/create<\/em> &#8212; \u0421\u043e\u0437\u0434\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d \u0431\u0435\u0437 \u0440\u043e\u043b\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p><em>\/jwt\/create\/viewer<\/em> &#8212; \u0421\u043e\u0437\u0434\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d \u0441 \u0440\u043e\u043b\u044c\u044e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f: \u201cviewer\u201d;<\/p>\n<\/li>\n<li>\n<p><em>\/jwt\/create\/editor<\/em> &#8212; \u0421\u043e\u0437\u0434\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d \u0441 \u0440\u043e\u043b\u044c\u044e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430: \u201ceditor\u201d;<\/p>\n<\/li>\n<li>\n<p><em>\/jwt\/create\/admin<\/em> &#8212; \u0421\u043e\u0437\u0434\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d \u0441 \u0440\u043e\u043b\u044c\u044e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430: \u201cadmin\u201d;<\/p>\n<\/li>\n<li>\n<p><em>\/jwt\/roles<\/em> &#8212; \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u043e\u043b\u0438 \u0432 \u0432\u044b\u0434\u0430\u043d\u043d\u043e\u043c \u0442\u043e\u043a\u0435\u043d\u0435;<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Nginx \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432 jwt.js.<\/p>\n<details class=\"spoiler\">\n<summary>jwt.conf<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"nginx\">## jwt js_import \/etc\/nginx\/conf.d\/jwt.js;  js_set $generateJwt jwt.generateJwt;  server {     listen 8081;      ### jwt view roles     location \/jwt\/roles {         return 200 $jwt_payload_roles;     }      ### create jwt token     location \/jwt\/create {         return 200 $generateJwt;     } } <\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>jwt.js<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">function generate_hs256_jwt(claims, key, valid) {     var header = { typ: \"JWT\",  alg: \"HS256\" };     var claims = Object.assign(claims, {exp: Math.floor(Date.now()\/1000) + valid});      var s = [header, claims].map(JSON.stringify)                             .map(v=>v.toString('base64url'))                             .join('.');      var h = require('crypto').createHmac('sha256', key);      return s + '.' + h.update(s).digest('base64url'); }  function generateJwt(r) {     var uri = \"\"     if (r.uri != \"\/jwt\/create\") {         uri = r.uri.replace('\/jwt\/create\/','');     }          var token = jwt([uri]);      return token; }  function jwt(roles) {     var claims = {         iss: \"nginx\",         sub: \"alice\",         foo: 123,         bar: \"qq\",         zyx: false,         realm_access: {             roles: roles         }     };      return generate_hs256_jwt(claims, 'foo', 600); }  export default {generateJwt};<\/code><\/pre>\n<\/div>\n<\/details>\n<p><strong>API<\/strong><\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 API-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0434\u0435\u043b\u0430\u043d \u0440\u043e\u0443\u0442 <em>\/security\/<\/em><\/p>\n<details class=\"spoiler\">\n<summary>api.js<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">function getReponse(r) {     r.return(200, \"Success!\"); }  export default {getReponse};<\/code><\/pre>\n<\/div>\n<\/details>\n<p><strong>OPA<\/strong><\/p>\n<details class=\"spoiler\">\n<summary>rbac.rego<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>package httpapi.rbac  import input as req  import data.roles  default allow = false  allow {   # check role   role := req.user[_]   user_roles = roles[role]    # check route   user_roles[k]   glob.match(k, [], req.path)    # check method   user_roles[k][_] = req.method }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u043e\u043b\u0435\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/p>\n<pre><code class=\"json\">{   \"roles\": {     \"viewer\": {       \"\/security\/*\": [\"GET\"]     },     \"editor\": {       \"\/security\/*\": [\"GET\", \"POST\", \"PUT\"]     },     \"admin\": {       \"\/security\/*\": [\"GET\", \"POST\", \"PUT\", \"DELETE\"]     }   } } <\/code><\/pre>\n<p><strong>Nginx + OPA<\/strong><\/p>\n<details class=\"spoiler\">\n<summary>rbac.conf<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"nginx\">js_import \/etc\/nginx\/conf.d\/rbac.js; js_import \/etc\/nginx\/conf.d\/api.js;  js_set $jwt_payload_roles rbac.jwt_payload_roles;  server {     listen 8080;      # proxy to jwt api     location \/jwt {         proxy_pass http:\/\/127.0.0.1:8081\/jwt;     }      # sample api     location \/security {         auth_request \/_authz;         js_content api.getReponse;     }      ### authorization     location = \/_authz {         internal;         js_content rbac.authz;     }      location = \/_opa {         internal;         proxy_pass http:\/\/opa:8181\/v1\/data\/httpapi\/rbac;     } } <\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>rbac.js<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">function authz(req, res) {   \/\/ get roles   var roles = jwt_payload_roles(req)   if(roles == null) {     req.return(401);     return;   }    var opa_data = {     \"input\": {       \"user\": roles,       \"path\": req.variables.request_uri,       \"method\": req.variables.request_method     }   };    var opts = {     method: \"POST\",     body: JSON.stringify(opa_data)   };    req.subrequest(\"\/_opa\", opts, function(opa) {     req.error(\"OPA response: \" + opa.responseBody);      var body = JSON.parse(opa.responseBody);     if (!body.result)  {       req.return(403);       return;     }      if (!body.result.allow) {       req.return(403);       return;     } else {       req.return(200);     }   }); }  function jwt(data) {   var parts = data.split('.').slice(0,2)       .map(v=>Buffer.from(v, 'base64url').toString())       .map(JSON.parse);   return { headers:parts[0], payload: parts[1] }; }  function jwt_payload_roles(r) {   if (r.headersIn.Authorization == null) {     return   }    return jwt(r.headersIn.Authorization.slice(7)).payload.realm_access.roles;   \/\/ when the token is provided as the \"myjwt\" argument   \/\/ return jwt(r.args.myjwt).payload.sub; }  export default {authz, jwt_payload_roles};<\/code><\/pre>\n<\/div>\n<\/details>\n<p><strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/strong><\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u044f \u0441\u043e\u0431\u0440\u0430\u043b \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u043e\u0434\u043d\u0443 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e Postman<\/p>\n<details class=\"spoiler\">\n<summary>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"json\">{\"info\":{\"_postman_id\":\"bf317dda-05db-4c0e-bbae-8b745aa65981\",\"name\":\"Nginx And Opa Authorization\",\"schema\":\"https:\/\/schema.getpostman.com\/json\/collection\/v2.0.0\/collection.json\"},\"item\":[{\"name\":\"JWT\",\"item\":[{\"name\":\"View roles in JWT\",\"id\":\"d28de3b0-f439-454e-9e3c-4e1ccfc7e71d\",\"request\":{\"auth\":{\"type\":\"bearer\",\"bearer\":{\"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuZ2lueCIsInN1YiI6ImFsaWNlIiwiZm9vIjoxMjMsImJhciI6InFxIiwienl4IjpmYWxzZSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbInZpZXdlciIsInRlc3QiXX0sImV4cCI6MTYzNzMxOTUxNX0.mZu9cbUccknBduyFXa10URmdm1RmgoGCbiPT654RBMI\"}},\"method\":\"GET\",\"header\":[],\"url\":\"http:\/\/localhost:8080\/jwt\/roles\"},\"response\":[]},{\"name\":\"Create JWT without roles\",\"id\":\"31654055-bf71-49b9-9caa-4fd0a1015a10\",\"request\":{\"method\":\"GET\",\"header\":[],\"url\":\"http:\/\/localhost:8080\/jwt\/create\"},\"response\":[]},{\"name\":\"Create JWT Viewer\",\"id\":\"25276dc6-a618-4695-8d9f-32f701037b56\",\"request\":{\"method\":\"GET\",\"header\":[],\"url\":\"http:\/\/localhost:8080\/jwt\/create\/viewer\"},\"response\":[]},{\"name\":\"Create JWT Editor\",\"id\":\"9a6fdfbc-f4d0-4f3d-8628-50135bcca9b4\",\"request\":{\"method\":\"GET\",\"header\":[],\"url\":\"http:\/\/localhost:8080\/jwt\/create\/editor\"},\"response\":[]},{\"name\":\"Create JWT Admin\",\"id\":\"c8c1934d-fb23-414e-bb89-c6adc1f2dcc1\",\"request\":{\"method\":\"GET\",\"header\":[],\"url\":\"http:\/\/localhost:8080\/jwt\/create\/admin\"},\"response\":[]}],\"id\":\"c7c6e2b1-e62a-4819-8697-0a64224be510\"},{\"name\":\"API\",\"item\":[{\"name\":\"security\",\"id\":\"ade4a701-c101-43d9-bc86-895063df7d8a\",\"request\":{\"auth\":{\"type\":\"bearer\",\"bearer\":{\"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuZ2lueCIsInN1YiI6ImFsaWNlIiwiZm9vIjoxMjMsImJhciI6InFxIiwienl4IjpmYWxzZSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImFkbWluIl19LCJleHAiOjE2MzczMTk3NzV9.eVfk0rMf1XprEsuOlCwdKIcPxKRYigUIs5wAu1aEpC8\"}},\"method\":\"GET\",\"header\":[],\"url\":\"http:\/\/localhost:8080\/security\/someid\"},\"response\":[]},{\"name\":\"security\",\"id\":\"89462dd5-ae88-48cc-9f39-cccc51f95bcc\",\"request\":{\"auth\":{\"type\":\"bearer\",\"bearer\":{\"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuZ2lueCIsInN1YiI6ImFsaWNlIiwiZm9vIjoxMjMsImJhciI6InFxIiwienl4IjpmYWxzZSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImFkbWluIl19LCJleHAiOjE2MzczMTk3NzV9.eVfk0rMf1XprEsuOlCwdKIcPxKRYigUIs5wAu1aEpC8\"}},\"method\":\"POST\",\"header\":[],\"url\":\"http:\/\/localhost:8080\/security\/someid\"},\"response\":[]},{\"name\":\"security\",\"id\":\"df04e356-ac6c-405f-ba98-57052545575d\",\"request\":{\"auth\":{\"type\":\"bearer\",\"bearer\":{\"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuZ2lueCIsInN1YiI6ImFsaWNlIiwiZm9vIjoxMjMsImJhciI6InFxIiwienl4IjpmYWxzZSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImFkbWluIl19LCJleHAiOjE2MzczMTk3NzV9.eVfk0rMf1XprEsuOlCwdKIcPxKRYigUIs5wAu1aEpC8\"}},\"method\":\"PUT\",\"header\":[],\"url\":\"http:\/\/localhost:8080\/security\/someid\"},\"response\":[]},{\"name\":\"security\",\"id\":\"3f0dbb2a-d31a-4380-ae71-d890904dfdb3\",\"request\":{\"auth\":{\"type\":\"bearer\",\"bearer\":{\"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuZ2lueCIsInN1YiI6ImFsaWNlIiwiZm9vIjoxMjMsImJhciI6InFxIiwienl4IjpmYWxzZSwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbImFkbWluIl19LCJleHAiOjE2MzczMTk3NzV9.eVfk0rMf1XprEsuOlCwdKIcPxKRYigUIs5wAu1aEpC8\"}<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u043e\u043a\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5f6\/efb\/c89\/5f6efbc89a3ed639a5a3d23259591994.png\" width=\"2018\" height=\"1020\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5f6\/efb\/c89\/5f6efbc89a3ed639a5a3d23259591994.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0417\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u044d\u0442\u043e\u0442 \u0442\u043e\u043a\u0435\u043d \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c GET \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\/c94\/b58\/f00\/c94b58f00e9c7f08306c175b5622e03e.png\" width=\"2042\" height=\"960\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c94\/b58\/f00\/c94b58f00e9c7f08306c175b5622e03e.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u0442\u043e\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441 \u044d\u0442\u0438\u043c \u0436\u0435 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 POST<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/f8b\/49e\/173\/f8b49e1735aabe97ee5f65e80c550b55.png\" width=\"2026\" height=\"1454\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/f8b\/49e\/173\/f8b49e1735aabe97ee5f65e80c550b55.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u044b\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432<\/strong><\/p>\n<ul>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043a \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u0430\u043c?<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u0427\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0423 \u043d\u0430\u0441 \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432: \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439<\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0412 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u0435\u0449\u0435 \u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430. <\/p>\n<p>\u0414\u043b\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u043e\u0442\u0432\u0435\u0442 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u0435\u043d, \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c.<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0414\u0430\u043d\u043d\u0430\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0435\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0442\u043e\u043a\u0435\u043d\u0430 &#8212; \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u0442\u0440\u0430\u0442\u044b. \u041d\u043e \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0438\u0432\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0434\u0435\u043b\u0430\u0432 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u043e\u043a\u0441\u0438. \u0423\u0447\u0438\u0442\u044b\u0432\u0430\u044f, \u0447\u0442\u043e \u0442\u043e\u043a\u0435\u043d \u043e\u0431\u044b\u0447\u043d\u043e \u0436\u0438\u0432\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 15 \u043c\u0438\u043d\u0443\u0442 &#8212; \u044d\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0442 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443.<\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043d\u0435\u0441\u0442\u0438 \u0432 \u043b\u043e\u0433\u0438\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0440\u0430\u0437\u0431\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438\u0437 \u0442\u0435\u043b\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0436\u0435 \u0443\u0436\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0435\u0442\u0435\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u201c\u0414\u0430\u0439 \u0432\u0441\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u201d \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<ul>\n<li>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 Graphql \u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u0449\u0438\u043c\u0438 REST?<\/p>\n<\/li>\n<\/ul>\n<details class=\"spoiler\">\n<summary>\u0427\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u0430\u043a<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0412\u044b\u0434\u0435\u043b\u0438\u0432 \u0438\u0437 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044e Graphql \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0447\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/p>\n<\/div>\n<\/details>\n<p>\u041d\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0432 \u0438\u0442\u043e\u0433\u0435 \u0441\u043d\u043e\u0432\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043f\u043e\u0442\u0435\u0440\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430.<\/p>\n<p><a href=\"https:\/\/github.com\/melnikovio\/nginx-opa-authorization\" rel=\"noopener noreferrer nofollow\"><strong>\u0420\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c<\/strong><\/a><\/p>\n<p>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438:<\/p>\n<p><a href=\"https:\/\/github.com\/summerwind\/opa-nginx-rbac\" rel=\"noopener noreferrer nofollow\">Nginx + OPA \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u0441 \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u043c\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438<\/a><\/p>\n<p><a href=\"https:\/\/github.com\/lcrilly\/nginx-plus-opa\" rel=\"noopener noreferrer nofollow\">RBAC \u043d\u0430 Nginx Plus + OPA. \u041f\u043e\u0445\u043e\u0436\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043a\u043e\u043c\u043c\u0435\u0440\u0447\u0435\u0441\u043a\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Nginx<\/a><\/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\/591985\/\"> https:\/\/habr.com\/ru\/articles\/591985\/<\/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<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u043e \u043f\u0440\u0430\u0432\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0442\u043e \u0438\u0437 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430:<\/p>\n<ul>\n<li>\n<p>\u041b\u0438\u0431\u043e \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0440\u0438\u0432\u044f\u0437\u043a\u0438 \u043a \u043d\u0435\u043a\u0438\u043c \u0440\u043e\u043b\u044f\u043c\/scope\u2019\u0430\u043c;<\/p>\n<\/li>\n<li>\n<p>\u041b\u0438\u0431\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043e\u0431\u0440\u0430\u0441\u0442\u0430\u0435\u0442 \u0431\u043e\u0440\u043e\u0434\u043e\u0439 \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0441\u044b\u043f\u0430\u0442\u044c \u0444\u0440\u0430\u0437\u0430\u043c\u0438 \u0432\u0440\u043e\u0434\u0435 aba\u0441, xacml \u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430;\u00a0<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0438\u0437 \u043f\u043e\u0434\u0440\u0443\u0447\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0441\u043e\u0431\u0440\u0430\u0442\u044c RBAC \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u044e\u0449\u0438\u0439 REST, \u0442\u043e \u0434\u043e\u0431\u0440\u043e \u043f\u043e\u0436\u0430\u043b\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p><strong>\u0414\u043b\u044f \u0447\u0435\u0433\u043e \u044d\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0443\u0436\u043d\u043e?<\/strong><\/p>\n<ul>\n<li>\n<p><strong>POC<\/strong>: \u041f\u0440\u0438 \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 Proof of Concept \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0438\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0443\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u043b\u0430\u043d. \u0410 \u0438\u043d\u043e\u0433\u0434\u0430 \u043e\u0442 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0445\u043e\u0442\u044f \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u043a\u0430\u043a \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p><strong>\u0420\u0435\u0441\u0443\u0440\u0441\u044b<\/strong>: \u041f\u0440\u0438 \u0440\u0430\u0437\u0432\u0435\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0438 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432\u0435\u043b\u0438\u043a\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0447\u044c \u0441\u0430\u043c\u044b\u043c \u0442\u044f\u0436\u0435\u043b\u043e\u0432\u0435\u0441\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0425\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0435\u0437 \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u0438\u0445 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0439 \u0441 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u043c\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438;<\/p>\n<\/li>\n<li>\n<p><strong>Firewall<\/strong>: \u041f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0444\u0430\u0435\u0440\u0432\u043e\u043b\u0430 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0447\u0430\u0441\u0442\u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043b\u043e\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0432\u0430 \u0431\u043b\u043e\u043a\u0430:  \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044e\u0442 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u0438 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u043c \u0431\u043b\u043e\u043a\u043e\u043c. \u041f\u0443\u0441\u0442\u044c \u0438 \u0441 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u043c\u0438 \u043e\u0433\u043e\u0432\u043e\u0440\u043a\u0430\u043c\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e, \u0442\u043e \u0432\u0441\u044e \u044d\u0442\u0443 \u0441\u0442\u0430\u0442\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0443\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0444\u0440\u0430\u0437\u0443:<\/p>\n<p>\u041f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e<em>\u0442\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 Nginx, \u043f\u0435\u0440\u0435\u0434 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0435\u0433\u043e \u0432 \u0441\u0435\u0440\u0432\u0438\u0441, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 OPA, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0435\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d, \u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0435\u0440\u0432\u0438\u0441.<\/em><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0430\u0437\u0431\u043e\u0440 \u043f\u043e\u043b\u0435\u0442\u043e\u0432 \u0432\u0430\u043c \u043d\u0435\u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0435\u043d, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0437\u0443 <a href=\"#implementation\" rel=\"noopener noreferrer nofollow\"><strong>\u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/strong><\/a><strong>.<\/strong><\/p>\n<h2>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0418\u0442\u0430\u043a, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435\u043c.\u00a0<\/p>\n<p>\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u044b \u0434\u0432\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p>API Gateway;<\/p>\n<\/li>\n<li>\n<p>\u0411\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 REST API;<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0435\u0441\u0442\u044c REST API c CRUD-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. HTTP-\u043c\u0435\u0442\u043e\u0434 GET.<\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. HTTP-\u043c\u0435\u0442\u043e\u0434 POST.<\/p>\n<\/li>\n<li>\n<p>\u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. HTTP-\u043c\u0435\u0442\u043e\u0434 PUT.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435. HTTP-\u043c\u0435\u0442\u043e\u0434 DELETE.<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0430:<\/p>\n<ul>\n<li>\n<p>\u0427\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f;<\/p>\n<\/li>\n<li>\n<p>\u0427\u0438\u0442\u0430\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0410 \u0432\u043e\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432\u0441\u0435 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440;<\/p>\n<\/li>\n<\/ul>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h2>\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<ul>\n<li>\n<p>\u041a\u0442\u043e?<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<\/li>\n<li>\n<p>\u0418 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438?<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c<\/p>\n<\/li>\n<li>\n<p>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435<\/p>\n<\/li>\n<\/ul>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0438\u043b\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.\u00a0<\/p>\n<p>\u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434, \u0447\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u0433\u0434\u0435 \u0432\u0437\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u0438\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f.<\/p>\n<p><strong>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c. <\/strong>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d, \u043a\u0430\u043a \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u043d\u044b\u0439 \u0441\u043b\u0435\u043f\u043e\u043a \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u0442 Keycloak \u0438 \u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f SSO Redhat, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u044f \u0431\u0443\u0434\u0443 \u043e\u0442\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u043e\u043a\u0435\u043d\u0430 \u0438\u043c\u0435\u043d\u043d\u043e Keycloak.<\/p>\n<p><strong>\u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0435.<\/strong> \u041c\u0430\u0440\u043a\u0435\u0440\u043e\u043c \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043d\u043e\u0442\u0430\u0446\u0438\u0435\u0439 REST \u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b<\/p>\n<p>GET &#8212; \u044d\u0442\u043e \u0447\u0442\u0435\u043d\u0438\u0435, POST\/PUT &#8212; \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435, DELETE &#8212; \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p><strong>\u0414\u0430\u043d\u043d\u044b\u0435.<\/strong> \u0414\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u043a\u0441\u0438 \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0440\u043e\u0443\u0442. \u0422\u043e \u0435\u0441\u0442\u044c \u0442\u043e\u0442 \u0440\u043e\u0443\u0442 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u0438 \u0435\u0441\u0442\u044c \u043d\u0430\u0448\u0438 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong>Gateway, \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435<\/strong><\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0438\u0437 \u0432\u0441\u0435\u0445 \u0432\u044b\u0448\u0435\u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u043a\u0443\u0431\u0438\u043a\u043e\u0432.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u043e\u043a\u0441\u0438\/gateway \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430.<\/p>\n<p>\u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e Gateway \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043a\u0443\u0431\u0438\u043a \u0432 \u0441\u0445\u0435\u043c\u0443 &#8212; \u043c\u043e\u0434\u0443\u043b\u044c \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043d\u0430\u0448\u0430 \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c:<\/p>\n<ol>\n<li>\n<p>\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0441\u0432\u043e\u0439 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d \u0438 \u043c\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u044e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435. \u0421 \u044d\u0442\u0438\u043c \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u043e\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044f \u0432 Gateway.<\/p>\n<\/li>\n<li>\n<p>Gateway \u043d\u0430\u0434\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043f\u0440\u0430\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043e\u043d \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<p>&#8212; \u0417\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u0442\u043e\u043a\u0435\u043d \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 \u0438 \u0434\u0435\u0441\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u0443\u0435\u0442, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435;<\/p>\n<p>&#8212; \u0412\u044b\u0434\u0435\u043b\u044f\u0435\u0442 HTTP-\u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442, \u0447\u0442\u043e \u044d\u0442\u043e \u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c;<\/p>\n<p>&#8212;  \u0418\u0437 \u043f\u0443\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435;\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u044b \u0442\u0440\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044e \u043c\u043e\u0436\u043d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0443 \u0447\u0438\u0442\u0430\u0442\u044c \u0438 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u0430 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u0432\u0441\u0435<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d, \u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0431\u0438\u0437\u043d\u0435\u0441-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><a class=\"anchor\" name=\"implementation\" id=\"implementation\"><\/a><\/p>\n<p><strong>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/strong><\/p>\n<p>\u0412\u0441\u0435. \u0421 \u0442\u0435\u043e\u0440\u0438\u0435\u0439 \u0437\u0430\u043a\u043e\u043d\u0447\u0438\u043b\u0438. \u0415\u0441\u043b\u0438 \u0447\u0435\u0441\u0442\u043d\u043e, \u0442\u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0442\u0443\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u0441\u0430\u043c\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0427\u0435\u043c \u043b\u0438\u0447\u043d\u043e \u043c\u043d\u0435 \u0438 \u0438\u043c\u043f\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c OPA &#8212; <a href=\"https:\/\/www.openpolicyagent.org\" rel=\"noopener noreferrer nofollow\">https:\/\/www.openpolicyagent.org<\/a><\/p>\n<p>\u0414\u043b\u044f Gateway \u0432\u043e\u0437\u044c\u043c\u0443 Nginx &#8212; <a href=\"http:\/\/nginx.org\" rel=\"noopener noreferrer nofollow\">http:\/\/nginx.org<\/a><\/p>\n<p>\u0414\u043b\u044f \u0440\u0435\u043c\u0430\u0440\u043a\u0438 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e OPA \u043d\u0430\u0431\u0438\u0440\u0430\u0435\u0442 \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u044c \u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438 \u0435\u0441\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u0438 \u043f\u043e\u0434 Envoy &#8212; <a href=\"https:\/\/github.com\/open-policy-agent\/opa-envoy-plugin\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/open-policy-agent\/opa-envoy-plugin<\/a>, Traefic &#8212; <a href=\"https:\/\/doc.traefik.io\/traefik-enterprise\/v2.4\/middlewares\/opa\/\" rel=\"noopener noreferrer nofollow\">https:\/\/doc.traefik.io\/traefik-enterprise\/v2.4\/middlewares\/opa\/<\/a><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><strong>Nginx<\/strong><\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Nginx \u0432 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439.<\/p>\n<details class=\"spoiler\">\n<summary>nginx.conf<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"nginx\">load_module modules\/ngx_http_js_module.so;  user  nginx; worker_processes  1;  error_log  \/var\/log\/nginx\/error.log warn; pid        \/var\/run\/nginx.pid;   events {     worker_connections  1024; }  http {     include       \/etc\/nginx\/mime.types;     default_type  application\/octet-stream;      log_format  main  '$remote_addr - $remote_user [$time_local] \"$request\" '                       '$status $body_bytes_sent \"$http_referer\" '                       '\"$http_user_agent\" \"$http_x_forwarded_for\"';      access_log  \/var\/log\/nginx\/access.log  main;      sendfile        on;     #tcp_nopush     on;      keepalive_timeout  65;      #gzip  on;      include \/etc\/nginx\/conf.d\/*.conf; } <\/code><\/pre>\n<\/div>\n<\/details>\n<p><strong>JWT<\/strong><\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e Keycloak. \u041d\u043e \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432 Nginx \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<ul>\n<li>\n<p><em>\/jwt\/create<\/em> &#8212; \u0421\u043e\u0437\u0434\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d \u0431\u0435\u0437 \u0440\u043e\u043b\u0435\u0439;<\/p>\n<\/li>\n<li>\n<p><em>\/jwt\/create\/viewer<\/em> &#8212; \u0421\u043e\u0437\u0434\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d \u0441 \u0440\u043e\u043b\u044c\u044e \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044f: \u201cviewer\u201d;<\/p>\n<\/li>\n<li>\n<p><em>\/jwt\/create\/editor<\/em> &#8212; \u0421\u043e\u0437\u0434\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d \u0441 \u0440\u043e\u043b\u044c\u044e \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430: \u201ceditor\u201d;<\/p>\n<\/li>\n<li>\n<p><em>\/jwt\/create\/admin<\/em> &#8212; \u0421\u043e\u0437\u0434\u0430\u0442\u044c JWT-\u0442\u043e\u043a\u0435\u043d \u0441 \u0440\u043e\u043b\u044c\u044e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430: \u201cadmin\u201d;<\/p>\n<\/li>\n<li>\n<p><em>\/jwt\/roles<\/em> &#8212; \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0440\u043e\u043b\u0438 \u0432 \u0432\u044b\u0434\u0430\u043d\u043d\u043e\u043c \u0442\u043e\u043a\u0435\u043d\u0435;<\/p>\n<\/li>\n<\/ul>\n<p>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f Nginx \u0441 \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432 jwt.js.<\/p>\n<details class=\"spoiler\">\n<summary>jwt.conf<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"nginx\">## jwt js_import \/etc\/nginx\/conf.d\/jwt.js;  js_set $generateJwt jwt.generateJwt;  server {     listen 8081;      ### jwt view roles     location \/jwt\/roles {         return 200 $jwt_payload_roles;     }      ### create jwt token     location \/jwt\/create {         return 200 $generateJwt;     } } <\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>jwt.js<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">function generate_hs256_jwt(claims, key, valid) {     var header = { typ: \"JWT\",  alg: \"HS256\" };     var claims = Object.assign(claims, {exp: Math.floor(Date.now()\/1000) + valid});      var s = [header, claims].map(JSON.stringify)                             .map(v=>v.toString('base64url'))                             .join('.');      var h = require('crypto').createHmac('sha256', key);      return s + '.' + h.update(s).digest('base64url'); }  function generateJwt(r) {     var uri = \"\"     if (r.uri != \"\/jwt\/create\") {         uri = r.uri.replace('\/jwt\/create\/','');     }          var token = jwt([uri]);      return token; }  function jwt(roles) {     var claims = {         iss: \"nginx\",         sub: \"alice\",         foo: 123,         bar: \"qq\",         zyx: false,         realm_access: {             roles: roles         }     };      return generate_hs256_jwt(claims, 'foo', 600); }  export default {generateJwt};<\/code><\/pre>\n<\/div>\n<\/details>\n<p><strong>API<\/strong><\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 API-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0441\u0434\u0435\u043b\u0430\u043d \u0440\u043e\u0443\u0442 <em>\/security\/<\/em><\/p>\n<details class=\"spoiler\">\n<summary>api.js<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">function getReponse(r) {     r.return(200, \"Success!\"); }  export default {getReponse};<\/code><\/pre>\n<\/div>\n<\/details>\n<p><strong>OPA<\/strong><\/p>\n<details class=\"spoiler\">\n<summary>rbac.rego<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>package httpapi.rbac  import input as req  import data.roles  default allow = false  allow {   # check role   role := req.user[_]   user_roles = roles[role]    # check route   user_roles[k]   glob.match(k, [], req.path)    # check method   user_roles[k][_] = req.method }<\/code><\/pre>\n<\/div>\n<\/details>\n<p>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0440\u043e\u043b\u0435\u0439 \u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/p>\n<pre><code class=\"json\">{   \"roles\": {     \"viewer\": {       \"\/security\/*\": [\"GET\"]     },     \"editor\": {       \"\/security\/*\": [\"GET\", \"POST\", \"PUT\"]     },     \"admin\": {       \"\/security\/*\": [\"GET\", \"POST\", \"PUT\", \"DELETE\"]     }   } } <\/code><\/pre>\n<p><strong>Nginx + OPA<\/strong><\/p>\n<details class=\"spoiler\">\n<summary>rbac.conf<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"nginx\">js_import \/etc\/nginx\/conf.d\/rbac.js; js_import \/etc\/nginx\/conf.d\/api.js;  js_set $jwt_payload_roles rbac.jwt_payload_roles;  server {     listen 8080;      # proxy to jwt api     location \/jwt {         proxy_pass http:\/\/127.0.0.1:8081\/jwt;     }      # sample api     location \/security {         auth_request \/_authz;         js_content api.getReponse;     }      ### authorization     location = \/_authz {         internal;         js_content rbac.authz;     }      location = \/_opa {         internal;         proxy_pass http:\/\/opa:8181\/v1\/data\/httpapi\/rbac;     } } <\/code><\/pre>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>rbac.js<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"javascript\">function authz(req, res) {   \/\/ get roles   var roles = jwt_payload_roles(req)   if(roles == null) {     req.return(401);     return;   }    var opa_data = {     \"input\": {       \"user\": roles,       \"path\": req.variables.request_uri,       \"method\": req.variables.request_method     }   };    var opts = {     method: \"POST\",     body: JSON.stringify(opa_data)   };    req.subrequest(\"\/_opa\", opts, function(opa) {     req.error(\"OPA response: \" + opa.responseBody);      var body = JSON.parse(opa.responseBody);     if (!body.result)  {       req.return(403);       return;     }      if (!body.result.allow) {       req.return(403);       return;     } else {       req.return(200);     }   }); }  function jwt(data) {   var parts = data.split('.').slice(0,2)       .map(v=>Buffer.from(v, 'base64url').toString())       .map(JSON.parse);   return { headers:parts[0], payload: parts[1] }; }  function jwt_payload_roles(r) {   if (r.headersIn.Authorization == null) {     return   }    return jwt(r.headersIn.Authorization.slice(7)).payload.realm_access.roles;   \/\/ when the token is provided as the \"myjwt\" argument   \/\/<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-411414","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/411414","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=411414"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/411414\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=411414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=411414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=411414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}