{"id":294,"date":"2023-07-19T06:50:59","date_gmt":"2023-07-19T06:50:59","guid":{"rendered":"http:\/\/www.adartis.de\/?p=294"},"modified":"2023-07-19T06:50:59","modified_gmt":"2023-07-19T06:50:59","slug":"keycloak","status":"publish","type":"post","link":"https:\/\/www.adartis.de\/?p=294","title":{"rendered":"Keycloak"},"content":{"rendered":"\n<p class=\"has-text-align-center has-medium-font-size\"><strong>Keycloak integration mit Reacjs-App<\/strong><\/p>\n\n\n\n<p>Diese Doku ist eine Anleitung f\u00fcr die Integration von Keycloak Access Management mit einer Frontend Beispielanwendung (Reactjs app).<\/p>\n\n\n\n<p><strong>Hinweise:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"1\">\n<li>Keycloak wird mittels folgender <a href=\"https:\/\/artifacthub.io\/packages\/helm\/bitnami\/keycloak\">Helm Chart<\/a> [1] installiert. Es ist in unserer Installation unter <a href=\"http:\/\/key.apps.rancher.adartish.de\/\">http:\/\/key.apps.rancher.adartish.de<\/a> ansprechbar.<\/li>\n\n\n\n<li>Beispielanwendungen zu Keycloak findet man in <a href=\"https:\/\/github.com\/dasniko\/keycloak-reactjs-demo\">Repo1<\/a> [2] oder <a href=\"https:\/\/github.com\/keycloak\/keycloak-quickstarts\/tree\/latest\/applications\/app-vue\">Repo2<\/a> [3]<\/li>\n\n\n\n<li><a href=\"https:\/\/www.keycloak.org\/docs\/latest\/securing_apps\/#_javascript_adapter\">Keycloak configuration f\u00fcr Javascript<\/a> [4] Projekte mit schon im Code integriertem Keycloak.<\/li>\n\n\n\n<li>Die Apps k\u00f6nnen mithilfe der <a href=\"https:\/\/github.com\/loft-sh\/devspace\">\u201edevspace\u201c package<\/a> [5] dockerisiert werden und dann zum K8s Cluster gepusht werden. (<a href=\"https:\/\/morioh.com\/p\/0db462f79048\">Beispiel<\/a> [6])<\/li>\n\n\n\n<li>Man kann auch Ingresse f\u00fcr die App konfigurieren. Die Ingress dieses Apps ist unter folgender URL ansprechbar: <a href=\"http:\/\/react.apps.rancher.adartish.de\/\">http:\/\/react.apps.rancher.adartish.de<\/a><\/li>\n<\/ol>\n\n\n\n<p><strong>Ablauf:<\/strong><\/p>\n\n\n\n<p>Zuerst muss man als Keycloak Admin einen Realm definieren unter dem die Konfigurationen abgespeichert werden. In diesem Beispiel hei\u00dft er \u201eNew.<\/p>\n\n\n\n<p>Wenn alles bereit ist, muss man einen \u201eClient\u201c im Keycloak Realm \u201eNew\u201c erstellen.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"171\" src=\"http:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-1-1024x171.png\" alt=\"\" class=\"wp-image-295\" srcset=\"https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-1-1024x171.png 1024w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-1-300x50.png 300w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-1-768x129.png 768w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-1-1536x257.png 1536w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-1.png 1792w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Man w\u00e4hlt einen \u201eclient-id\u201c aus und dr\u00fcckt Save. Die andere Felder k\u00f6nnen wie folgt ausgef\u00fcllt werden.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"858\" src=\"http:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-2-1024x858.png\" alt=\"\" class=\"wp-image-296\" srcset=\"https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-2-1024x858.png 1024w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-2-300x251.png 300w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-2-768x643.png 768w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-2-1536x1287.png 1536w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-2.png 1590w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Wichtige Punkte:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Access Type muss \u201epublic\u201c sein.<\/li>\n\n\n\n<li>Root-Url, Redirect-URI, Admin-Url und Web-origins m\u00fcssen entsprechend angepasst werden.<\/li>\n\n\n\n<li>Wenn die Webseite \u201ehttp\u201c ist, dann muss web-origins \u201e*\u201c sein.<\/li>\n<\/ul>\n\n\n\n<p>Zun\u00e4chst muss man zwei Rollen f\u00fcr die App definieren.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"456\" src=\"http:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-3-1024x456.png\" alt=\"\" class=\"wp-image-297\" srcset=\"https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-3-1024x456.png 1024w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-3-300x133.png 300w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-3-768x342.png 768w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-3.png 1472w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Danach muss man ein paar Benutzer definieren. Die Benutzer k\u00f6nnen entweder manuell in Keycloak eingetragen oder durch LDAP-Integration bezogen werden. Die andere M\u00f6glichkeit ist der Bezug durch Soziale Apps, u.a. GitHub, GitLab, Facebook usw.&nbsp;<\/p>\n\n\n\n<p>Wenn ein Benutzer definiert ist, muss ihm im \u201eRole Mappings\u201c Tab die passende Rolle \u00fcbertragen werden. Und zwar:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"456\" src=\"http:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-4-1024x456.png\" alt=\"\" class=\"wp-image-298\" srcset=\"https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-4-1024x456.png 1024w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-4-300x133.png 300w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-4-768x342.png 768w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-4.png 1472w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Wichtiger Punkt: Definieren Sie zwei Benutzer, einer als normal-user und der andere als admin-user. (Hier sind das die User:<\/p>\n\n\n\n<p>a)&nbsp;&nbsp;&nbsp;&nbsp; User<\/p>\n\n\n\n<p>b)&nbsp;&nbsp;&nbsp; Admin<\/p>\n\n\n\n<p>Alles ist bereit. Rufen Sie die URL der App auf und testen Sie, ob alles Reibungslos funktioniert: <a href=\"http:\/\/react.apps.rancher.adartish.de\/\">http:\/\/react.apps.rancher.adartish.de<\/a><\/p>\n\n\n\n<p><strong>LDAP Konfiguration:<\/strong><\/p>\n\n\n\n<p><strong>\u00a0<\/strong>W\u00e4hlen Sie \u201eUser Federation\u201c in Keycloak Admin Panel aus, dann \u201eldap\u201c als Typ und f\u00fcllen Sie danach die Felder wie folgt aus:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"920\" src=\"http:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-5-1024x920.png\" alt=\"\" class=\"wp-image-299\" srcset=\"https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-5-1024x920.png 1024w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-5-300x269.png 300w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-5-768x690.png 768w, https:\/\/www.adartis.de\/wp-content\/uploads\/2023\/07\/2023-5.png 1472w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Testen Sie die Konfiguration mit den \u201eTest connection\u201c und \u201eTest authentication\u201c Buttons.<\/p>\n\n\n\n<p>Gleichen Sie die Benutzer ab. Fertig!<\/p>\n\n\n\n<p><strong>GitHub-Integration:<\/strong><\/p>\n\n\n\n<p>Die GitHub-Integration ist unter <a href=\"https:\/\/medium.com\/keycloak\/github-as-identity-provider-in-keyclaok-dca95a9d80ca\">diesem Link<\/a> beschrieben. [7]<\/p>\n\n\n\n<p><strong>Anhang<\/strong><\/p>\n\n\n\n<p>Verwendete URLs:<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"1\">\n<li><a href=\"https:\/\/artifacthub.io\/packages\/helm\/bitnami\/keycloak\">keycloak 15.1.6 \u00b7 bitnami\/bitnami<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/dasniko\/keycloak-reactjs-demo\">GitHub &#8211; dasniko\/keycloak-reactjs-demo: Reference example for React.JS and Keycloak SSO integration.<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/keycloak\/keycloak-quickstarts\/tree\/latest\/applications\/app-vue\">keycloak-quickstarts\/applications\/app-vue at latest \u00b7 keycloak\/keycloak-quickstarts<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.keycloak.org\/docs\/latest\/securing_apps\/#_javascript_adapter\">Securing Applications and Services Guide<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/loft-sh\/devspace\">GitHub &#8211; devspace-sh\/devspace: DevSpace &#8211; The Fastest Developer Tool for Kubernetes \u26a1 Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/morioh.com\/p\/0db462f79048\">How to deploy a Vue.js application to Kubernetes<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/medium.com\/keycloak\/github-as-identity-provider-in-keyclaok-dca95a9d80ca\">Github as Identity Provider in Keyclaok<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Keycloak integration mit Reacjs-App Diese Doku ist eine Anleitung f\u00fcr die Integration von Keycloak Access [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-294","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.adartis.de\/index.php?rest_route=\/wp\/v2\/posts\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.adartis.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.adartis.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.adartis.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.adartis.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294"}],"version-history":[{"count":1,"href":"https:\/\/www.adartis.de\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":300,"href":"https:\/\/www.adartis.de\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions\/300"}],"wp:attachment":[{"href":"https:\/\/www.adartis.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.adartis.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.adartis.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}