{"id":4754,"date":"2022-12-09T14:08:14","date_gmt":"2022-12-09T14:08:14","guid":{"rendered":"https:\/\/dalelane.co.uk\/blog\/?p=4754"},"modified":"2022-12-09T14:08:14","modified_gmt":"2022-12-09T14:08:14","slug":"setting-up-the-event-streams-ui-for-developer-only-use","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=4754","title":{"rendered":"Setting up the Event Streams UI for developer-only use"},"content":{"rendered":"<p><strong>A quick tip for how to give a developer access to the IBM Event Streams UI only for the Kafka topics used by their application, and not everything else.<\/strong><\/p>\n<p>Imagine I&#8217;m a Kafka cluster admin. I&#8217;m running a cluster with a variety of topics on it.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dropbox.com\/s\/kh232cubn4zm97f\/1-admin-view.png?raw=1\" style=\"border: thin black solid\"\/><\/p>\n<h3>Only viewing their own topics<\/h3>\n<p>One of my developers is responsible for the flight tracking app, and wants to use the Event Streams UI. But I don&#8217;t want them to be able to access the other sensitive topics for other applications.<\/p>\n<p>I can create them their own login for the UI, that <strong>only lets them see their own topics<\/strong>.<\/p>\n<p>The permissions I want to give them are:<\/p>\n<pre style=\"max-height: 250px; max-width: 90%; padding: 10px; overflow: scroll; overflow-x: scroll; border: thin black solid; font-size: smaller; background-color: #eeeeee; color: black; margin-left: 16px;\">- operation: Read\n  resource:\n    name: FLIGHT.\n    patternType: prefix\n    type: topic<\/pre>\n<p>(Remember, <a href=\"https:\/\/dalelane.co.uk\/blog\/?p=4088\">managing my Kafka cluster through Kubernetes resources is a good fit with a CI\/CD workflow<\/a>.)<\/p>\n<p><!--more-->In context of a user definition, that looks like:<\/p>\n<pre style=\"max-height: 250px; max-width: 90%; padding: 10px; overflow: scroll; overflow-x: scroll; border: thin black solid; font-size: smaller; background-color: #eeeeee; color: black; margin-left: 16px;\">apiVersion: eventstreams.ibm.com\/v1beta2\nkind: KafkaUser\nmetadata:\n  labels:\n    eventstreams.ibm.com\/cluster: es\n  name: flight-topics\nspec:\n  authentication:\n    type: scram-sha-512\n  authorization:\n    acls:\n      - operation: Read\n        resource:\n          name: FLIGHT.\n          patternType: prefix\n          type: topic\n      - operation: Read\n        resource:\n          name: '*'\n          patternType: literal\n          type: group\n      - operation: Read\n        resource:\n          name: __schema_\n          patternType: prefix\n          type: topic\n    type: simple<\/pre>\n<p>(I&#8217;ve also given them access to view schemas, and see the consumer applications as well.)<\/p>\n<p>When they login with their <code>flight-topics<\/code> username and password, they only see the topics that have names starting with <code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">FLIGHT.<\/code>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dropbox.com\/s\/ibzphz94r4f4k83\/2-flights-topics.png?raw=1\" style=\"border: thin black solid\"\/><\/p>\n<p>They can click into their topics to see the events:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dropbox.com\/s\/apu7ci2poycg973\/3-flights-messages.png?raw=1\" style=\"border: thin black solid\"\/><\/p>\n<h3>Creating and viewing their own topics<\/h3>\n<p>I can do the same for the developer of the stock prices app. But that developer needs a bit more flexibility.<\/p>\n<p>I still want them to only see topics relating to their application &#8211; with names that start with <code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">STOCK.PRICES.<\/code>, but I want them to be able to create new topics like that without needing to come and ask me to do it for them.<\/p>\n<p>So I give them an extra <code>Create<\/code> permission:<\/p>\n<pre style=\"max-height: 250px; max-width: 90%; padding: 10px; overflow: scroll; overflow-x: scroll; border: thin black solid; font-size: smaller; background-color: #eeeeee; color: black; margin-left: 16px;\">- operation: Create\n  resource:\n    name: STOCK.PRICES.\n    patternType: prefix\n    type: topic\n- operation: Read\n  resource:\n    name: STOCK.PRICES.\n    patternType: prefix\n    type: topic<\/pre>\n<p>In context of a whole user specification, that looks like:<\/p>\n<pre style=\"max-height: 250px; max-width: 90%; padding: 10px; overflow: scroll; overflow-x: scroll; border: thin black solid; font-size: smaller; background-color: #eeeeee; color: black; margin-left: 16px;\">apiVersion: eventstreams.ibm.com\/v1beta2\nkind: KafkaUser\nmetadata:\n  labels:\n    eventstreams.ibm.com\/cluster: es\n  name: stock-price-topics\nspec:\n  authentication:\n    type: scram-sha-512\n  authorization:\n    acls:\n      - operation: Create\n        resource:\n          name: STOCK.PRICES.\n          patternType: prefix\n          type: topic\n      - operation: Read\n        resource:\n          name: STOCK.PRICES.\n          patternType: prefix\n          type: topic\n      - operation: Read\n        resource:\n          name: '*'\n          patternType: literal\n          type: group\n      - operation: Read\n        resource:\n          name: __schema_\n          patternType: prefix\n          type: topic\n    type: simple<\/pre>\n<p>When they login with their <code>stock-price-topics<\/code> username and password, they access topics with names starting with <code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">STOCK.PRICES.<\/code><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dropbox.com\/s\/1vy4ivcbxa9zi82\/4-stocks-messages.png?raw=1\" style=\"border: thin black solid\"\/><\/p>\n<p><strong>And<\/strong> they get the button for creating a new topic.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dropbox.com\/s\/qimiwkl3pg3bxsg\/5-stocks-topics.png?raw=1\" style=\"border: thin black solid\"\/><\/p>\n<p>Importantly, they will only be allowed to create new topics with names starting with <code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">STOCK.PRICES.<\/code> &#8211; as their <code>Create<\/code> permission only covers that.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dropbox.com\/s\/t8xcsvj0aiuqaga\/6-stocks-create.png?raw=1\" style=\"border: thin black solid\"\/><\/p>\n<p>If they try and create a topic with a name that doesn&#8217;t match that prefix, that will fail.<\/p>\n<h3>Deleting their own topics<\/h3>\n<p>If I really want to give the stock price app developer control over these topics, I could also let them delete their own topics by adding another permission:<\/p>\n<pre style=\"max-height: 250px; max-width: 90%; padding: 10px; overflow: scroll; overflow-x: scroll; border: thin black solid; font-size: smaller; background-color: #eeeeee; color: black; margin-left: 16px;\">- operation: Delete\n  resource:\n    name: STOCK.PRICES.\n    patternType: prefix\n    type: topic<\/pre>\n<h3>Enabling all of this<\/h3>\n<p>To do this, you need to switch the Event Streams UI to using SCRAM credentials as an authentication mechanism. In your <code>EventStreams<\/code> instance, you add:<\/p>\n<pre style=\"max-height: 250px; max-width: 90%; padding: 10px; overflow: scroll; overflow-x: scroll; border: thin black solid; font-size: smaller; background-color: #eeeeee; color: black; margin-left: 16px;\">spec:\n  adminUI:\n    authentication:\n      - type: scram-sha-512<\/pre>\n<p>If you do that, the login page changes to look like this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.dropbox.com\/s\/mq8xhyv830s61pg\/7-login.png?raw=1\" style=\"border: thin black solid\"\/><\/p>\n<p>Then I just need to give myself an admin user that can see everything:<\/p>\n<pre style=\"max-height: 250px; max-width: 90%; padding: 10px; overflow: scroll; overflow-x: scroll; border: thin black solid; font-size: smaller; background-color: #eeeeee; color: black; margin-left: 16px;\">apiVersion: eventstreams.ibm.com\/v1beta2\nkind: KafkaUser\nmetadata:\n  labels:\n    eventstreams.ibm.com\/cluster: es\n  name: admin\nspec:\n  authentication:\n    type: scram-sha-512\n  authorization:\n    acls:\n      - operation: Delete\n        resource:\n          name: '*'\n          patternType: literal\n          type: topic\n      - operation: Write\n        resource:\n          name: '*'\n          patternType: literal\n          type: topic\n      - operation: Read\n        resource:\n          name: '*'\n          patternType: literal\n          type: topic\n      - operation: Create\n        resource:\n          name: '*'\n          patternType: literal\n          type: topic\n      - operation: Read\n        resource:\n          name: '*'\n          patternType: literal\n          type: group\n      - operation: Read\n        resource:\n          name: __schema_\n          patternType: prefix\n          type: topic\n      - operation: Alter\n        resource:\n          name: __schema_\n          patternType: prefix\n          type: topic\n      - operation: Write\n        resource:\n          name: '*'\n          patternType: literal\n          type: transactionalId\n    type: simple<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A quick tip for how to give a developer access to the IBM Event Streams UI only for the Kafka topics used by their application, and not everything else. Imagine I&#8217;m a Kafka cluster admin. I&#8217;m running a cluster with a variety of topics on it. Only viewing their own topics One of my developers [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,4],"tags":[593,582,583,584],"class_list":["post-4754","post","type-post","status-publish","format-standard","hentry","category-code","category-ibm","tag-apachekafka","tag-eventstreams","tag-ibmeventstreams","tag-kafka"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4754"}],"version-history":[{"count":0,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4754\/revisions"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4754"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}