{"info":{"_postman_id":"8ddc19dc-bc5f-47a4-82a9-94640db14a62","name":"FIWARE PEP Proxy","description":"<html><head></head><body><p><a href=\"https://www.fiware.org/developers/catalogue/\"><img src=\"https://img.shields.io/badge/FIWARE-Security-ff7059.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAVCAYAAAC33pUlAAAABHNCSVQICAgIfAhkiAAAA8NJREFUSEuVlUtIFlEUx+eO+j3Uz8wSLLJ3pBiBUljRu1WLCAKXbXpQEUFERSQF0aKVFAUVrSJalNXGgmphFEhQiZEIPQwKLbEUK7VvZrRvbr8zzjfNl4/swplz7rn/8z/33HtmRhn/MWzbXmloHVeG0a+VSmAXorXS+oehVD9+0zDN9mgk8n0sWtYnHo5tT9daH4BsM+THQC8naK02jCZ83/HlKaVSzBey1sm8BP9nnUpdjOfl/Qyzj5ust6cnO5FItJLoJqB6yJ4QuNcjVOohegpihshS4F6S7DTVVlNtFFxzNBa7kcaEwUGcbVnH8xOJD67WG9n1NILuKtOsQG9FngOc+lciic1iQ8uQGhJ1kVAKKXUs60RoQ5km93IfaREvuoFj7PZsy9rGXE9G/NhBsDOJ63Acp1J82eFU7OIVO1OxWGwpSU5hb0GqfMydMHYSdiMVnncNY5Vy3VbwRUEydvEaRxmAOSSqJMlJISTxS9YWTYLcg3B253xsPkc5lXk3XLlwrPLuDPKDqDIutzYaj3eweMkPeCCahO3+fEIF8SfLtg/5oI3Mh0ylKM4YRBaYzuBgPuRnBYD3mmhA1X5Aka8NKl4nNz7BaKTzSgsLCzWbvyo4eK9r15WwLKRAmmCXXDoA1kaG2F4jWFbgkxUnlcrB/xj5iHxFPiBN4JekY4nZ6ccOiQ87hgwhe+TOdogT1nfpgEDTvYAucIwHxBfNyhpGrR+F8x00WD33VCNTOr/Wd+9C51Ben7S0ZJUq3qZJ2OkZz+cL87ZfWuePlwRcHZjeUMxFwTrJZAJfSvyWZc1VgORTY8rBcubetdiOk+CO+jPOcCRTF+oZ0okUIyuQeSNL/lPrulg8flhmJHmE2gBpE9xrJNkwpN4rQIIyujGoELCQz8ggG38iGzjKkXufJ2Klun1iu65bnJub2yut3xbEK3UvsDEInCmvA6YjMeE1bCn8F9JBe1eAnS2JksmkIlEDfi8R46kkEkMWdqOv+AvS9rcp2bvk8OAESvgox7h4aWNMLd32jSMLvuwDAwORSE7Oe3ZRKrFwvYGrPOBJ2nZ20Op/mqKNzgraOTPt6Bnx5citUINIczX/jUw3xGL2+ia8KAvsvp0ePoL5hXkXO5YvQYSFAiqcJX8E/gyX8QUvv8eh9XUq3h7mE9tLJoNKqnhHXmCO+dtJ4ybSkH1jc9XRaHTMz1tATBe2UEkeAdKu/zWIkUbZxD+veLxEQhhUFmbnvOezsJrk+zmqMo6vIL2OXzPvQ8v7dgtpoQnkF/LP8Ruu9zXdJHg4igAAAABJRU5ErkJgggA=\" alt=\"FIWARE Security\"></a></p>\n<p>This tutorial uses the FIWARE <a href=\"https://fiware-pep-proxy.rtfd.io/\">Wilma</a> PEP Proxy combined with <strong>Keyrock</strong> to secure access to endpoints exposed by\nFIWARE generic enablers. Users (or other actors) must log-in and use a token to gain access to services. The application\ncode created in the <a href=\"https://github.com/Fiware/tutorials.Securing-Access\">previous tutorial</a> is expanded to authenticate\nusers throughout a distributed system. The design of FIWARE Wilma - a PEP Proxy is discussed, and the parts of the\nKeyrock GUI and REST API relevant to authenticating other services are described in detail.</p>\n<p>The <code>docker-compose</code> files for this tutorial can be found on GitHub: </p>\n<p><img src=\"https://fiware.github.io/tutorials.PEP-Proxy/icon/GitHub-Mark-32px.png\" alt=\"GitHub\"> <a href=\"https://github.com/Fiware/tutorials.PEP-Proxy\">FIWARE 404: Securing Microservices with a PEP Proxy</a></p>\n<h1 id=\"securing-microservices-with-a-pep-proxy\">Securing Microservices with a PEP Proxy</h1>\n<blockquote>\n<p>\"Oh, it's quite simple. If you are a friend, you speak the password, and the doors will open.\"</p>\n<p> — Gandalf (The Fellowship of the Ring by J.R.R Tolkien)</p>\n</blockquote>\n<p>The <a href=\"https://github.com/Fiware/tutorials.Securing-Access\">previous tutorial</a> demonstrated that it is possible to Permit or Deny access\nto resources based on an authenticated user identifying themselves within an application.  It was simply a matter of the code following\na different line of execution if the <code>access_token</code> was not found (Level 1 - <em>Authentication Access</em>), or confirming that a given <code>access_token</code>\nhad appropriate rights (Level  2 - <em>Basic Authorization</em>). The same method of securing access can be applied by placing a Policy Enforcement\nPoint (PEP) in front of other services within a FIWARE-based Smart Solution.</p>\n<p>A <strong>PEP Proxy</strong> lies in front of a secured resource  and is an endpoint found at \"well-known\" public location. It serves\nas a gatekeeper for resource access. Users or other actors must supply sufficient information to the <strong>PEP Proxy</strong> to allow their request\nto succeed and pass through the <strong>PEP proxy</strong>. The <strong>PEP proxy</strong> then passes the request on to the real location of the\nsecured resource itself - the actual location of the secured resource is unknown to the outside user - it could be held\nin a private network behind the <strong>PEP proxy</strong> or found on a different machine altogether.</p>\n<p>FIWARE <a href=\"https://fiware-pep-proxy.rtfd.io/\">Wilma</a> is a simple implentation of a <strong>PEP proxy</strong> designed to work with the FIWARE <a href=\"http://fiware-idm.readthedocs.io/\">Keyrock</a> Generic Enabler. Whenever a user tries to gain access to the resource behind the <strong>PEP proxy</strong>, the\nPEP will describe the user's attributes to the Policy Decision Point (PDP), request a security decision, and enforce the decision.\n(Permit or Deny). There is mimimal disruption of access for authorized users  - the response received is the same as if they had\naccessed the secured service directly. Unauthorized users are simply returned a <strong>401 - Unauthorized</strong> response.</p>\n<h2 id=\"standard-concepts-of-identity-management\">Standard Concepts of Identity Management</h2>\n<p>The following common objects are found with the <strong>Keyrock</strong> Identity Management database:</p>\n<ul>\n<li><strong>User</strong> - Any signed up user able to identify themselves with an eMail and password. Users can be assigned\n rights individually or as a group</li>\n<li><strong>Application</strong> -  Any securable FIWARE application consisting of a series of microservices</li>\n<li><strong>Organization</strong> - A group of users who can be assigned a series of rights. Altering the rights of the organization\n effects the access of all users of that organization</li>\n<li><strong>OrganizationRole</strong> - Users can either be members or admins of an organization - Admins are able to add and remove users\n from their organization, members merely gain the roles and permissions of an organization. This allows each organization\n to be responsible for their members and removes the need for a super-admin to administer all rights</li>\n<li><strong>Role</strong> - A role is a descriptive bucket for a set of permissions. A role can be assigned to either a single user\n or an organization. A signed-in user gains all the permissions from all of their own roles plus all of the roles associated\n to their organization</li>\n<li><strong>Permission</strong> - An ability to do something on a resource within the system</li>\n</ul>\n<p>Additionally two further non-human application objects can be secured within a FIWARE application:</p>\n<ul>\n<li><strong>IoTAgent</strong> - a proxy between IoT Sensors and  the Context Broker</li>\n<li><strong>PEPProxy</strong> - a middleware for use between generic enablers challenging the rights of a user.</li>\n</ul>\n<p> The relationship between the objects can be seen below - the entities marked in red are used directly within this tutorial:</p>\n<p><img src=\"https://fiware.github.io/tutorials.PEP-Proxy/img/entities.png\" alt=\"\"></p>\n<h2 id=\"video--introduction-to-wilma-pep-proxy\">Video : Introduction to Wilma PEP Proxy</h2>\n<p><a href=\"https://www.youtube.com/watch?v=8tGbUI18udM\"><img src=\"http://img.youtube.com/vi/8tGbUI18udM/0.jpg\" alt=\"\"></a></p>\n<p>Click on the image above to see an introductory video</p>\n<h1 id=\"prerequisites\">Prerequisites</h1>\n<h2 id=\"docker\">Docker</h2>\n<p>To keep things simple both components will be run using <a href=\"https://www.docker.com\">Docker</a>. <strong>Docker</strong> is a\ncontainer technology which allows to different components isolated into their respective environments.</p>\n<ul>\n<li>To install Docker on Windows follow the instructions <a href=\"https://docs.docker.com/docker-for-windows/\">here</a></li>\n<li>To install Docker on Mac follow the instructions <a href=\"https://docs.docker.com/docker-for-mac/\">here</a></li>\n<li>To install Docker on Linux follow the instructions <a href=\"https://docs.docker.com/install/\">here</a></li>\n</ul>\n<p><strong>Docker Compose</strong> is a tool for defining and running multi-container Docker applications. A\n<a href=\"https://raw.githubusercontent.com/Fiware/tutorials.Identity-Management/master/docker-compose.yml\">YAML file</a> is used\nconfigure the required services for the application. This means all container services can be brought up in a single\ncommand. Docker Compose is installed by default as part of Docker for Windows and  Docker for Mac, however Linux users\nwill need to follow the instructions found  <a href=\"https://docs.docker.com/compose/install/\">here</a></p>\n<h2 id=\"cygwin\">Cygwin</h2>\n<p>We will start up our services using a simple bash script. Windows users should download <a href=\"http://www.cygwin.com/\">cygwin</a> to provide a\ncommand line functionality similar to a Linux distribution on Windows.</p>\n<h1 id=\"architecture\">Architecture</h1>\n<p>This application protects access to the existing Stock Management and Sensors-based application by adding PEP Proxy instances around the services created in previous tutorials and uses data pre-populated into the <strong>MySQL</strong> database used by <strong>Keyrock</strong>. It\nwill make use of four FIWARE components - the <a href=\"https://fiware-orion.readthedocs.io/en/latest/\">Orion Context Broker</a>,the <a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/\">IoT Agent for UltraLight 2.0</a>, the <a href=\"http://fiware-idm.readthedocs.io/\">Keyrock</a> Generic enabler\nand adds one or two instances <a href=\"https://fiware-pep-proxy.rtfd.io/\">Wilma</a> PEP Proxy dependent upon which interfaces are to be secured.\nUsage of the Orion Context Broker is sufficient for an application to qualify as <em>“Powered by FIWARE”</em>.</p>\n<p>Both the Orion Context Broker and the IoT Agent rely on open source <a href=\"https://www.mongodb.com/\">MongoDB</a> technology to keep persistence of the information they hold. We will also be using the dummy IoT devices created in the <a href=\"https://github.com/Fiware/tutorials.IoT-Sensors/\">previous tutorial</a>. <strong>Keyrock</strong> uses its own <a href=\"https://www.mysql.com/\">MySQL</a> database.</p>\n<p>Therefore the overall architecture will consist of the following elements:</p>\n<ul>\n<li>The FIWARE <a href=\"https://fiware-orion.readthedocs.io/en/latest/\">Orion Context Broker</a> which will receive requests using <a href=\"https://fiware.github.io/specifications/OpenAPI/ngsiv2\">NGSI</a></li>\n<li>The FIWARE <a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/\">IoT Agent for UltraLight 2.0</a> which will receive southbound requests using <a href=\"https://fiware.github.io/specifications/OpenAPI/ngsiv2\">NGSI</a> and convert them to  <a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">UltraLight 2.0</a> commands for the devices</li>\n<li>FIWARE <a href=\"http://fiware-idm.readthedocs.io/\">Keyrock</a> offer a complement Identity Management System including:<ul>\n<li>An OAuth2 authentication system for Applications and Users</li>\n<li>A website graphical front-end for Identity Management Administration</li>\n<li>An equivalent REST API for Identity Management via HTTP requests</li>\n</ul>\n</li>\n<li>FIWARE <a href=\"https://fiware-pep-proxy.rtfd.io/\">Wilma</a> is a PEP Proxy securing access to the <strong>Orion</strong> and/or <strong>IoT Agent</strong> microservices</li>\n<li>The underlying <a href=\"https://www.mongodb.com/\">MongoDB</a> database :<ul>\n<li>Used by the <strong>Orion Context Broker</strong> to hold context data information such as data entities, subscriptions and registrations</li>\n<li>Used by the <strong>IoT Agent</strong> to hold device information such as device URLs and Keys</li>\n</ul>\n</li>\n<li>A <a href=\"https://www.mysql.com/\">MySQL</a> database :<ul>\n<li>Used to persist user identities, applications, roles and permissions</li>\n</ul>\n</li>\n<li>The <strong>Stock Management Frontend</strong> does the following:<ul>\n<li>Displays store information</li>\n<li>Shows which products can be bought at each store</li>\n<li>Allows users to \"buy\" products and reduce the stock count.</li>\n<li>Allows authorized users into restricted areas</li>\n</ul>\n</li>\n<li>A webserver acting as set of <a href=\"https://github.com/Fiware/tutorials.IoT-Sensors\">dummy IoT devices</a> using the <a href=\"http://fiware-iotagent-ul.readthedocs.io/en/latest/usermanual/index.html#user-programmers-manual\">UltraLight 2.0</a> protocol running over HTTP - access to certain resources is restricted.</li>\n</ul>\n<p>Since all interactions between the elements are initiated by HTTP requests, the entities can be containerized and run from exposed ports.</p>\n<p>The specific architecture of each section of the tutorial is discussed below.</p>\n<h1 id=\"start-up\">Start Up</h1>\n<p>To start the installation, do the following:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">git clone git@github.com:Fiware/tutorials.PEP-Proxy.git\ncd tutorials.PEP-Proxy\n\n./services create\n</code></pre>\n<blockquote>\n<p><strong>Note</strong> The initial creation of Docker images can take up to three minutes</p>\n</blockquote>\n<p>Thereafter, all services can be initialized from the command line by running the <a href=\"https://github.com/Fiware/tutorials.PEP-PRoxy/blob/master/services\">services</a> Bash script provided within the repository:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services &lt;command&gt;\n</code></pre>\n<p>Where <code>&lt;command&gt;</code> will vary depending upon the exercise we wish to activate.</p>\n<blockquote>\n<p>:information_source: <strong>Note:</strong> If you want to clean up and start over again you can do so with the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services stop\n</code></pre>\n</blockquote>\n<h2 id=\"dramatis-personae\">Dramatis Personae</h2>\n<p>The following people at <code>test.com</code> legitimately have accounts within the Application</p>\n<ul>\n<li>Alice, she will be the Administrator of the <strong>Keyrock</strong> Application</li>\n<li>Bob, the Regional Manager of the supermarket chain - he has several store managers under him:<ul>\n<li>Manager1</li>\n<li>Manager2</li>\n</ul>\n</li>\n<li>Charlie, the Head of Security of the supermarket chain - he has several store detectives under him:<ul>\n<li>Detective1</li>\n<li>Detective2</li>\n</ul>\n</li>\n</ul>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Name</th>\n<th>eMail</th>\n<th>Password</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>alice</td>\n<td><a href=\"mailto:alice-the-admin@test.com\">alice-the-admin@test.com</a></td>\n<td><code>test</code></td>\n</tr>\n<tr>\n<td>bob</td>\n<td><a href=\"mailto:bob-the-manager@test.com\">bob-the-manager@test.com</a></td>\n<td><code>test</code></td>\n</tr>\n<tr>\n<td>charlie</td>\n<td><a href=\"mailto:charlie-security@test.com\">charlie-security@test.com</a></td>\n<td><code>test</code></td>\n</tr>\n<tr>\n<td>manager1</td>\n<td><a href=\"mailto:manager1@test.com\">manager1@test.com</a></td>\n<td><code>test</code></td>\n</tr>\n<tr>\n<td>manager2</td>\n<td><a href=\"mailto:manager2@test.com\">manager2@test.com</a></td>\n<td><code>test</code></td>\n</tr>\n<tr>\n<td>detective1</td>\n<td><a href=\"mailto:detective1@test.com\">detective1@test.com</a></td>\n<td><code>test</code></td>\n</tr>\n<tr>\n<td>detective2</td>\n<td><a href=\"mailto:detective2@test.com\">detective2@test.com</a></td>\n<td><code>test</code></td>\n</tr>\n</tbody>\n</table>\n</div><p>The following people at <code>example.com</code>  have signed up for accounts, but have no reason to be granted access</p>\n<ul>\n<li>Eve - Eve the Eavesdropper</li>\n<li>Mallory - Mallory the malicious attacker</li>\n<li>Rob - Rob the Robber</li>\n</ul>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Name</th>\n<th>eMail</th>\n<th>Password</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>eve</td>\n<td><a href=\"mailto:eve@example.com\">eve@example.com</a></td>\n<td><code>test</code></td>\n</tr>\n<tr>\n<td>mallory</td>\n<td><a href=\"mailto:mallory@example.com\">mallory@example.com</a></td>\n<td><code>test</code></td>\n</tr>\n<tr>\n<td>rob</td>\n<td><a href=\"mailto:rob@example.com\">rob@example.com</a></td>\n<td><code>test</code></td>\n</tr>\n</tbody>\n</table>\n</div><p>Two organizations have also been set up by Alice:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Name</th>\n<th>Description</th>\n<th>UUID</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Security</td>\n<td>Security Group for Store Detectives</td>\n<td><code>security-team-0000-0000-000000000000</code></td>\n</tr>\n<tr>\n<td>Management</td>\n<td>Management Group for Store Managers</td>\n<td><code>managers-team-0000-0000-000000000000</code></td>\n</tr>\n</tbody>\n</table>\n</div><p>One application, with appropriate roles and permissions has also been created:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Client ID</td>\n<td><code>tutorial-dckr-site-0000-xpresswebapp</code></td>\n</tr>\n<tr>\n<td>Client Secret</td>\n<td><code>tutorial-dckr-site-0000-clientsecret</code></td>\n</tr>\n<tr>\n<td>URL</td>\n<td><code>http://localhost:3000</code></td>\n</tr>\n<tr>\n<td>RedirectURL</td>\n<td><code>http://localhost:3000/login</code></td>\n</tr>\n</tbody>\n</table>\n</div><p>To save time, the data creating users and organizations from the <a href=\"https://github.com/Fiware/tutorials.Roles-Permissions\">previous tutorial</a> has been downloaded and is automatically persisted to the MySQL\ndatabase on start-up so the assigned UUIDs do not change and the data does not need to be entered again.</p>\n<p>The <strong>Keyrock</strong> MySQL database deals with all aspects of application security including storing users, password etc; defining access rights and dealing with OAuth2 authorization protocols.\nThe complete database relationship diagram can be found <a href=\"https://fiware.github.io/tutorials.Securing-Access/img/keyrock-db.png\">here</a></p>\n<p>To refresh your memory about how to create users and organizations and applications, you can log in at <code>http://localhost:3005/idm</code>\nusing the account <code>alice-the-admin@test.com</code> with a password of <code>test</code>.</p>\n<p><img src=\"https://fiware.github.io/tutorials.PEP-Proxy/img/keyrock-log-in.png\" alt=\"\"></p>\n<p>and look around.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"Securing Microservices with a PEP Proxy","slug":"securing-microservices-with-a-pep-proxy"},{"content":"Prerequisites","slug":"prerequisites"},{"content":"Architecture","slug":"architecture"},{"content":"Start Up","slug":"start-up"}],"owner":"513743","collectionId":"8ddc19dc-bc5f-47a4-82a9-94640db14a62","publishedId":"RWaHxUgP","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF7059"},"publishDate":"2020-01-02T11:02:20.000Z"},"item":[{"name":"Logging In to Keyrock","item":[{"name":"Create token with Password","id":"8caf9b30-5af4-45e8-855c-b717a01b03f4","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"alice-the-admin@test.com\",\n  \"password\": \"test\"\n}"},"url":"http://localhost:3005/v1/auth/tokens","description":"<p>The following example logs in using the Admin Super-User - it is the equivalent of using the log-in screen of the GUI.</p>\n<p>The response header returns an <code>X-Subject-token</code> which identifies who has logged on the application.\nThis token is required in all subsequent requests to gain access.</p>\n","urlObject":{"protocol":"http","path":["v1","auth","tokens"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"8caf9b30-5af4-45e8-855c-b717a01b03f4"},{"name":"Get token info","id":"990969ec-0c34-435a-912b-ad1b2adfe669","request":{"method":"GET","header":[{"key":"Accept","value":"application/json"},{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"},{"key":"X-Subject-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/auth/tokens","description":"<p>You can use the long-lasting  <code>X-Auth-token=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa</code> to pretend to be Alice throughout this\ntutorial. </p>\n<p>The presence of a (time-limited) token is sufficient to find out more information about the user.\nTo find information about Bob, use the long-lasting token <code>X-Subject-token=bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb</code></p>\n<p>This request indicates that <em>the\nuser authorized with the token <code>aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa</code> (i.e Alice) is enquiring about the user holding the token  <code>aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa</code></em> i.e Bob </p>\n<p>The response will return the details of the associated user. As you can see Bob holds a long-lasting token until 2026.</p>\n","urlObject":{"protocol":"http","path":["v1","auth","tokens"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"990969ec-0c34-435a-912b-ad1b2adfe669"}],"id":"f99e0d24-7b24-45f7-853d-90125242973d","description":"<p>Enter a username and password to enter the application. The default super-user has the values <code>alice-the-admin@test.com</code> and <code>test</code>. The URL <code>https://localhost:3443/v1/auth/tokens</code> should also work in a secure system.</p>\n","event":[{"listen":"prerequest","script":{"id":"b886ca21-2e87-489c-be24-cfa0df809954","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"30bf17a0-2033-4794-8351-f34ce2b67811","type":"text/javascript","exec":[""]}}],"_postman_id":"f99e0d24-7b24-45f7-853d-90125242973d"},{"name":"Managing PEP Proxies and IoT Agents","item":[{"name":"PEP Proxy CRUD Actions","item":[{"name":"Create a PEP Proxy","id":"f4347bdf-041c-4e2a-894d-5e6baf917b1f","request":{"method":"POST","header":[{"key":"Accept","value":"application/json"},{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/pep_proxies","description":"<p>To create a new PEP Proxy account within an application , send a POST request to the <code>//v1/applications/tutorial-dckr-site-0000-xpresswebapp/pep_proxies</code> endpoint  along with the <code>X-Auth-token</code> header from a previously logged in administrative user.</p>\n<p>Provided there is no previously existing PEP Proxy account associated with the application, a new account will be created with a unique <code>id</code> and <code>password</code> and the values will be returned in the response.</p>\n","urlObject":{"protocol":"http","path":["v1","applications","tutorial-dckr-site-0000-xpresswebapp","pep_proxies"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"f4347bdf-041c-4e2a-894d-5e6baf917b1f"},{"name":"Read PEP Proxy Details","id":"62b07008-1550-45ec-9176-60f2d867136b","request":{"method":"GET","header":[{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/pep_proxies/","description":"<p>Making a GET request the <code>/v1/applications/tutorial-dckr-site-0000-xpresswebapp/pep_proxies/</code> endpoint will return the details of the associated PEP Proxy Account. The <code>X-Auth-token</code> must be supplied in the headers.</p>\n","urlObject":{"protocol":"http","path":["v1","applications","tutorial-dckr-site-0000-xpresswebapp","pep_proxies",""],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"62b07008-1550-45ec-9176-60f2d867136b"},{"name":"Reset Password of PEP Proxy","id":"545f1cfb-382f-4a9d-902b-5acb0a6045e2","request":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/pep_proxies","description":"<p>To renew the password of a PEP Proxy Account, make a PATCH request to the  <code>/v1/applications/tutorial-dckr-site-0000-xpresswebapp/pep_proxies</code> endpoint will return the details of the associated PEP Proxy Account. The <code>X-Auth-token</code> must be supplied in the headers.</p>\n<p>The response returns a new password.</p>\n","urlObject":{"protocol":"http","path":["v1","applications","tutorial-dckr-site-0000-xpresswebapp","pep_proxies"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"545f1cfb-382f-4a9d-902b-5acb0a6045e2"},{"name":"Delete PEP Proxy","id":"8ac7334c-397b-4ec2-8b2c-b7fc8352340a","request":{"method":"DELETE","header":[{"key":"Accept","value":"application/json"},{"key":"Content-Type","value":"application/json"},{"key":"Content-Type","value":"{{Content-Type}}"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/pep_proxies","description":"<p>An existing PEP Proxy Account can be deleted by making a DELETE request to the  <code>/v1/applications/tutorial-dckr-site-0000-xpresswebapp/pep_proxies</code> endpoint. The <code>X-Auth-token</code> must be supplied in the headers.</p>\n","urlObject":{"protocol":"http","path":["v1","applications","tutorial-dckr-site-0000-xpresswebapp","pep_proxies"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"8ac7334c-397b-4ec2-8b2c-b7fc8352340a"}],"id":"e47a1943-7390-468d-9b5f-915d8c6b4bcd","description":"<h4 id=\"gui\">GUI</h4>\n<p>Once signed-in, users are able to create and update PEP Proxies associated to their applications for themselves.</p>\n<p><img src=\"https://fiware.github.io/tutorials.PEP-Proxy/img/create-pep-proxy.png\" alt /></p>\n<h4 id=\"rest-api\">REST API</h4>\n<p>Alternatively, the standard CRUD actions are assigned to the appropriate HTTP verbs (POST, GET, PATCH and DELETE) under the <code>/v1/applications/tutorial-dckr-site-0000-xpresswebapp/pep_proxies</code> endpoint.</p>\n","event":[{"listen":"prerequest","script":{"id":"387e4c2b-2ca2-4f82-9062-5cad900bcb98","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"2b873967-538b-4fe3-839c-e7eeffb7d9ba","type":"text/javascript","exec":[""]}}],"_postman_id":"e47a1943-7390-468d-9b5f-915d8c6b4bcd"},{"name":"IoT Agent CRUD Actions","item":[{"name":"Create an IoT Agent","id":"9213ec96-2299-41ec-8faa-6d7586884b65","request":{"method":"POST","header":[{"key":"Accept","value":"application/json"},{"key":"Content-Type","value":"application/json"},{"key":"Content-Type","value":"{{Content-Type}}"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/iot_agents","description":"<p>To create a new IoT Agent account within an application, send a POST request to the <code>/v1/applications/tutorial-dckr-site-0000-xpresswebapp/iot_agents</code> endpoint  along with the <code>X-Auth-token</code> header from a previously logged in administrative user.</p>\n<p>A new account will be created with a unique <code>id</code> and <code>password</code> and the values will be returned in the response.</p>\n","urlObject":{"protocol":"http","path":["v1","applications","tutorial-dckr-site-0000-xpresswebapp","iot_agents"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"9213ec96-2299-41ec-8faa-6d7586884b65"},{"name":"Read IoT Agent details","id":"eec9212b-0a83-4021-9208-15a3317831af","request":{"method":"GET","header":[{"key":"Accept","value":"application/json"},{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/iot_agents/iot_sensor_00000000-0000-0000-0000-000000000000","description":"<p>Making a GET request the <code>/v1/applications/tutorial-dckr-site-0000-xpresswebapp/iot_agents/iot_sensor_00000000-0000-0000-0000-000000000000</code> endpoint will return the details of the associated IoT Agent Account. The <code>X-Auth-token</code> must be supplied in the headers.</p>\n","urlObject":{"protocol":"http","path":["v1","applications","tutorial-dckr-site-0000-xpresswebapp","iot_agents","iot_sensor_00000000-0000-0000-0000-000000000000"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"eec9212b-0a83-4021-9208-15a3317831af"},{"name":"List of IoT Agents","id":"94a55658-c5b2-43de-9b31-22fb6100a98e","request":{"method":"GET","header":[{"key":"Accept","value":"application/json"},{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/iot_agents","description":"<p>A list of all IoT Agents associated with an application can be obtained by making a GET request the <code>/v1/applications/tutorial-dckr-site-0000-xpresswebapp/iot_agents</code> endpoint. The <code>X-Auth-token</code> must be supplied in the headers.</p>\n","urlObject":{"protocol":"http","path":["v1","applications","tutorial-dckr-site-0000-xpresswebapp","iot_agents"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"94a55658-c5b2-43de-9b31-22fb6100a98e"},{"name":"Reset Password of IoT Agent","id":"810362a0-89de-46a1-92e3-dca60b94bfac","request":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/iot_agents/iot_sensor_00000000-0000-0000-0000-000000000000","description":"<p>To renew the password of an individual IoT Agent Account, make a PATCH request to the  <code>/v1/applications/tutorial-dckr-site-0000-xpresswebapp//iot_agents/iot_sensor_00000000-0000-0000-0000-000000000000</code> endpoint. \nThe <code>X-Auth-token</code> must be supplied in the headers.</p>\n<p>The response returns a new password.</p>\n","urlObject":{"protocol":"http","path":["v1","applications","tutorial-dckr-site-0000-xpresswebapp","iot_agents","iot_sensor_00000000-0000-0000-0000-000000000000"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"810362a0-89de-46a1-92e3-dca60b94bfac"},{"name":"Delete an IoT Agent","id":"31aa4636-fb29-496e-93b4-646570fef140","request":{"method":"DELETE","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/applications/tutorial-dckr-site-0000-xpresswebapp/iot_agents/iot_sensor_00000000-0000-0000-0000-000000000000","description":"<p>An existing IoT Agent Account can be deleted by making a DELETE request to the  <code>/v1/applications/tutorial-dckr-site-0000-xpresswebapp/iot_agents/iot_sensor_00000000-0000-0000-0000-000000000000</code> endpoint. \nThe <code>X-Auth-token</code> must be supplied in the headers.</p>\n","urlObject":{"protocol":"http","path":["v1","applications","tutorial-dckr-site-0000-xpresswebapp","iot_agents","iot_sensor_00000000-0000-0000-0000-000000000000"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"31aa4636-fb29-496e-93b4-646570fef140"}],"id":"566306fb-15bf-469e-963c-79c3f948b4d3","description":"<h4 id=\"gui\">GUI</h4>\n<p>In a similar manner to PEP Proxy creation, signed-in, users are able to create and update IoT Sensor Accounts associated to their \napplications.</p>\n<p><img src=\"https://fiware.github.io/tutorials.PEP-Proxy/img/create-iot-sensor.png\" alt /></p>\n<h4 id=\"rest-api\">REST API</h4>\n<p>Alternatively, the standard CRUD actions are assigned to the </p>\n","event":[{"listen":"prerequest","script":{"id":"19ac2874-e6e9-43d4-8560-de18473d7a3a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"b544eada-13d0-40bd-b53c-b715a1f94dd2","type":"text/javascript","exec":[""]}}],"_postman_id":"566306fb-15bf-469e-963c-79c3f948b4d3"}],"id":"bd81ee58-ed8f-49ac-8c01-091d82aff238","description":"<p>User accounts have been created in a <a href=\"https://github.com/Fiware/tutorials.Identity-Management\">previous tutorial</a>. Non-human\nactors such as a PEP Proxy can be set up in the same manner. The account for each PEP Proxy, IoT Agent or IoT Sensor will \nmerely consist of a Username and password linked to an application within Keyrock. PEP Proxy and IoT Agents accounts can\nbe created by using either the Keyrock GUI or by using the REST API.</p>\n<h2 id=\"video--wilma-pep-proxy-configuration\">Video : Wilma PEP Proxy Configuration</h2>\n<p><a href=\"https://www.youtube.com/watch?v=b4sYU78skrw\"><img src=\"http://img.youtube.com/vi/b4sYU78skrw/0.jpg\" alt /></a></p>\n<p>Click on the image above to see a video about configuring the Wilma PEP Proxy using the <strong>Keyrock</strong> GUI</p>\n<h2 id=\"managing-pep-proxies-and-iot-agents---start-up\">Managing PEP Proxies and IoT Agents - Start Up</h2>\n<p>To start the system run the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services orion\n</code></pre>\n<p>This will start up <strong>Keyrock</strong> with a series of users. There are already two existing applications \nand an existing PEP Proxy Account associated with the application.</p>\n","event":[{"listen":"prerequest","script":{"id":"58d4e080-c9bf-4e19-aab9-08d332b71cba","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"f1ed306e-fcb8-470c-9d81-0e0e2d385f7f","type":"text/javascript","exec":[""]}}],"_postman_id":"bd81ee58-ed8f-49ac-8c01-091d82aff238"},{"name":"Securing the Orion Context Broker","item":[{"name":"PEP Proxy - No Access to Orion without an Access Token","id":"0ca4b27b-3392-4207-a84e-ba6abf4edfe6","request":{"method":"GET","header":[{"key":"X-Auth-Token","value":" 79d07d0139c66b75fc25f56a88008553f12f6ac7"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:1027/v2/entities/","description":"<p>Secured Access can be ensured by requiring all requests to the secured service are made indirectly via a PEP Proxy (in this case the PEP Proxy is found in front of the Context Broker). Requests must include an <code>X-Auth-Token</code>, failure to present a valid token results in a denial of access.</p>\n<p>if a request to the PEP Proxy is made without any access token as shown, the response is a <strong>401 Unauthorized</strong> error code, with a text explanation.</p>\n","urlObject":{"protocol":"http","port":"1027","path":["v2","entities",""],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"0ca4b27b-3392-4207-a84e-ba6abf4edfe6"},{"name":"Keyrock - User Obtains an Access Token","id":"0d2332e5-cd2e-4624-888d-16acfdd12a7f","request":{"method":"POST","header":[{"key":"Authorization","value":"Basic dHV0b3JpYWwtZGNrci1zaXRlLTAwMDAteHByZXNzd2ViYXBwOnR1dG9yaWFsLWRja3Itc2l0ZS0wMDAwLWNsaWVudHNlY3JldA==","description":"<p>base64 concatenation of Client Id and Client Secret</p>\n"},{"key":"Content-Type","value":"application/x-www-form-urlencoded"},{"key":"Accept","value":"application/json"}],"body":{"mode":"raw","raw":"username=alice-the-admin@test.com&password=test&grant_type=password"},"url":"http://localhost:3005/oauth2/token","description":"<p>To log in to an application using the user-credentials flow send a POST request to the <code>oauth2/token</code> endpoint with the <code>grant_type=password</code></p>\n<p>The response returns an <code>access_code</code> to identify the user.</p>\n<p>An <code>access_code</code> can also be done by entering the Tutorial Application on http:/localhost and logging in using any of the OAuth2 grants\non the page. A successful log-in will return an access token.</p>\n","urlObject":{"protocol":"http","path":["oauth2","token"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"0d2332e5-cd2e-4624-888d-16acfdd12a7f"},{"name":"PEP Proxy - Accessing Orion with an Access Token Copy","id":"5190d2ed-dd05-4937-9a9f-c1c327dd9649","request":{"method":"GET","header":[{"key":"X-Auth-Token","value":" 79d07d0139c66b75fc25f56a88008553f12f6ac7"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:1027/v2/entities/","description":"<p>If a request to the PEP Proxy is made including a valid access token in the <code>X-Auth-Token</code> header as shown, the request\nis permitted and the service behind the PEP Proxy (in this case the Orion Context Broker) will return the data as\nexpected.</p>\n","urlObject":{"protocol":"http","port":"1027","path":["v2","entities",""],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"5190d2ed-dd05-4937-9a9f-c1c327dd9649"},{"name":"Kong - Accessing Orion with an Access Token","id":"76d5dc5c-7b81-4600-bc11-a7896322538f","request":{"method":"GET","header":[{"key":"authorization","value":"Bearer  79d07d0139c66b75fc25f56a88008553f12f6ac7"}],"url":"http://localhost:8000/orion/v2/entities/","description":"<p>If a request to the PEP Proxy is made including a valid access token in the <code>X-Auth-Token</code> header as shown, the request\nis permitted and the service behind the PEP Proxy (in this case the Orion Context Broker) will return the data as\nexpected.</p>\n","urlObject":{"protocol":"http","port":"8000","path":["orion","v2","entities",""],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"76d5dc5c-7b81-4600-bc11-a7896322538f"},{"name":"PEP Proxy - Accessing Orion with a Bearer Auth Token","id":"5068c962-b97c-4452-a55a-b38c56a05242","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"token":" 79d07d0139c66b75fc25f56a88008553f12f6ac7"},"isInherited":false},"method":"GET","header":[],"url":"http://localhost:1027/v2/entities/","description":"<p>The standard  <code>Authorization: Bearer</code> header can also be used to identity the user,\nthe request from an authorized user is permitted and the service behind the PEP Proxy (in this case the Orion Context Broker) will return the data as\nexpected.</p>\n","urlObject":{"protocol":"http","port":"1027","path":["v2","entities",""],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"5068c962-b97c-4452-a55a-b38c56a05242"},{"name":"PEP Proxy - Accessing Orion with an Access Token Copy","id":"491659a5-8a60-4df3-8e73-d79b959594fd","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"X-Auth-Token","value":" 79d07d0139c66b75fc25f56a88008553f12f6ac7"}],"url":"http://localhost:1027/v2/entities/","description":"<p>If a request to the PEP Proxy is made including a valid access token in the <code>X-Auth-Token</code> header as shown, the request\nis permitted and the service behind the PEP Proxy (in this case the Orion Context Broker) will return the data as\nexpected.</p>\n","urlObject":{"protocol":"http","port":"1027","path":["v2","entities",""],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"491659a5-8a60-4df3-8e73-d79b959594fd"}],"id":"7587b0d8-438e-4189-ba71-9ea67e53902d","description":"<p><img src=\"https://fiware.github.io/tutorials.PEP-Proxy/img/pep-proxy-orion.png\" alt /></p>\n<h2 id=\"securing-orion---pep-proxy-configuration\">Securing Orion - PEP Proxy Configuration</h2>\n<p>The <code>orion-proxy</code> container is an instance of FIWARE <strong>Wilma</strong> listening on port <code>1027</code>, it is configured to forward traffic to\n<code>orion</code> on port <code>1026</code>, which is the default port that the Orion Context Broker is listening to for NGSI Requests.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  orion-proxy:\n    image: fiware/pep-proxy\n    container_name: fiware-orion-proxy\n    hostname: orion-proxy\n    networks:\n      default:\n        ipv4_address: 172.18.1.10\n    depends_on:\n      - keyrock\n    ports:\n      - \"1027:1027\"\n    expose:\n      - \"1027\"\n    environment:\n      - PEP_PROXY_APP_HOST=orion\n      - PEP_PROXY_APP_PORT=1026\n      - PEP_PROXY_PORT=1027\n      - PEP_PROXY_IDM_HOST=keyrock\n      - PEP_PROXY_HTTPS_ENABLED=false\n      - PEP_PROXY_AUTH_ENABLED=false\n      - PEP_PROXY_IDM_SSL_ENABLED=false\n      - PEP_PROXY_IDM_PORT=3005\n      - PEP_PROXY_APP_ID=tutorial-dckr-site-0000-xpresswebapp\n      - PEP_PROXY_USERNAME=pep_proxy_00000000-0000-0000-0000-000000000000\n      - PEP_PASSWORD=test\n      - PEP_PROXY_PDP=idm\n      - PEP_PROXY_MAGIC_KEY=1234\n</code></pre>\n<p>The <code>PEP_PROXY_APP_ID</code> and <code>PEP_PROXY_USERNAME</code> would usually be obtained by adding new entries to the application in <strong>Keyrock</strong>,\nhowever, in this tutorial, they have been pre-defined by populating the <strong>MySQL</strong> database with data on start-up.</p>\n<p>The <code>orion-proxy</code> container is listening on a single port:</p>\n<ul>\n<li>The PEP Proxy Port - <code>1027</code> is exposed purely for tutorial access - so that cUrl or Postman can requests directly to the <strong>Wilma</strong> instance\nwithout being part of the same network.</li>\n</ul>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>PEP_PROXY_APP_HOST</td>\n<td><code>orion</code></td>\n<td>The hostname of the service behind the PEP Proxy</td>\n</tr>\n<tr>\n<td>PEP_PROXY_APP_PORT</td>\n<td><code>1026</code></td>\n<td>The port of the service behind the PEP Proxy</td>\n</tr>\n<tr>\n<td>PEP_PROXY_PORT</td>\n<td><code>1027</code></td>\n<td>The port that the PEP Proxy is listening on</td>\n</tr>\n<tr>\n<td>PEP_PROXY_IDM_HOST</td>\n<td><code>keyrock</code></td>\n<td>The hostname for the Identity Manager</td>\n</tr>\n<tr>\n<td>PEP_PROXY_HTTPS_ENABLED</td>\n<td><code>false</code></td>\n<td>Whether the PEP Proxy itself is running under HTTPS</td>\n</tr>\n<tr>\n<td>PEP_PROXY_AUTH_ENABLED</td>\n<td><code>false</code></td>\n<td>Whether the PEP Proxy is checking for Authorization</td>\n</tr>\n<tr>\n<td>PEP_PROXY_IDM_SSL_ENABLED</td>\n<td><code>false</code></td>\n<td>Whether the Identity Manager is running under HTTPS</td>\n</tr>\n<tr>\n<td>PEP_PROXY_IDM_PORT</td>\n<td><code>3005</code></td>\n<td>The Port for the Identity Manager instance</td>\n</tr>\n<tr>\n<td>PEP_PROXY_APP_ID</td>\n<td><code>tutorial-dckr-site-0000-xpresswebapp</code></td>\n<td></td>\n</tr>\n<tr>\n<td>PEP_PROXY_USERNAME</td>\n<td><code>pep_proxy_00000000-0000-0000-0000-000000000000</code></td>\n<td>The Username for the PEP Proxy</td>\n</tr>\n<tr>\n<td>PEP_PASSWORD</td>\n<td><code>test</code></td>\n<td>The Password for the PEP Proxy</td>\n</tr>\n<tr>\n<td>PEP_PROXY_PDP</td>\n<td><code>idm</code></td>\n<td>The Type of service offering the Policy Decision Point</td>\n</tr>\n<tr>\n<td>PEP_PROXY_MAGIC_KEY</td>\n<td><code>1234</code></td>\n<td></td>\n</tr>\n</tbody>\n</table>\n</div><p>For this example, the PEP Proxy is checking for Level 1 - <em>Authentication Access</em> not  Level 2 - <em>Basic Authorization</em> or \nLevel 3 - <em>Advanced Authorization</em>. </p>\n<h2 id=\"securing-orion---application-configuration\">Securing Orion - Application Configuration</h2>\n<p>The tutorial application has already been registered in <strong>Keyrock</strong>, programmatically the tutorial application will\nbe making requests to the <strong>Wilma</strong> PEP Proxy in front of the <strong>Orion Conext Broker</strong>. Every request must now include\nan additional <code>access_token</code> header.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  tutorial-app:\n    image: fiware/tutorials.context-provider\n    hostname: tutorial-app\n    container_name: tutorial-app\n    depends_on:\n        - orion-proxy\n        - iot-agent\n        - keyrock\n    networks:\n      default:\n        ipv4_address: 172.18.1.7\n        aliases:\n          - iot-sensors\n    expose:\n        - \"3000\"\n        - \"3001\"\n    ports:\n        - \"3000:3000\"\n        - \"3001:3001\"\n    environment:\n        - \"WEB_APP_PORT=3000\"\n        - \"SECURE_ENDPOINTS=true\"\n        - \"CONTEXT_BROKER=http://orion-proxy:1027/v2\"\n        - \"KEYROCK_URL=http://localhost\"\n        - \"KEYROCK_IP_ADDRESS=http://172.18.1.5\"\n        - \"KEYROCK_PORT=3005\"\n        - \"KEYROCK_CLIENT_ID=tutorial-dckr-site-0000-xpresswebapp\"\n        - \"KEYROCK_CLIENT_SECRET=tutorial-dckr-site-0000-clientsecret\"\n        - \"CALLBACK_URL=http://localhost:3000/login\"\n</code></pre>\n<p>All of the <code>tutorial</code> container settings have been described in previous tutorials. One important change is necessary however,\nrather than accessing <strong>Orion</strong> directly on the default port <code>1026</code> as shown in all previous tutorials, all context broker\ntraffic is now sent to <code>orion-proxy</code> on port <code>1027</code>. As a reminder, the relevant settings are detailed below:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>WEB_APP_PORT</td>\n<td><code>3000</code></td>\n<td>Port used by web-app which displays the login screen &amp; etc.</td>\n</tr>\n<tr>\n<td>KEYROCK_URL</td>\n<td><code>http://localhost</code></td>\n<td>This is URL of the <strong>Keyrock</strong> Web Front-End itself, used for redirection when forwarding users</td>\n</tr>\n<tr>\n<td>KEYROCK_IP_ADDRESS</td>\n<td><code>http://172.18.1.5</code></td>\n<td>This is URL of the <strong>Keyrock</strong> OAuth Communications</td>\n</tr>\n<tr>\n<td>KEYROCK_PORT</td>\n<td><code>3005</code></td>\n<td>This is the port that <strong>Keyrock</strong> is listening on.</td>\n</tr>\n<tr>\n<td>KEYROCK_CLIENT_ID</td>\n<td><code>tutorial-dckr-site-0000-xpresswebapp</code></td>\n<td>The Client ID defined by Keyrock for this application</td>\n</tr>\n<tr>\n<td>KEYROCK_CLIENT_SECRET</td>\n<td><code>tutorial-dckr-site-0000-clientsecret</code></td>\n<td>The Client Secret defined by Keyrock for this application</td>\n</tr>\n<tr>\n<td>CALLBACK_URL</td>\n<td><code>http://localhost:3000/login</code></td>\n<td>The callback URL used by Keyrock when a challenge has succeeded.</td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"securing-orion---start-up\">Securing Orion - Start up</h2>\n<p>To start the system with a PEP Proxy protecting  access to <strong>Orion</strong>, run the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services orion\n</code></pre>\n<h3 id=\"video--securing-a-rest-api\">Video : Securing A REST API</h3>\n<p><a href=\"https://www.youtube.com/watch?v=coxFQEY0_So\"><img src=\"http://img.youtube.com/vi/coxFQEY0_So/0.jpg\" alt /></a></p>\n<p>Click on the image above to see a video about securing a REST API using the Wilma PEP Proxy</p>\n<h2 id=\"securing-orion---sample-code\">Securing Orion - Sample Code</h2>\n<p>When a User logs in to the application using the User Credentials Grant, an <code>access_token</code> is obtained which identifies the User.\nThe  <code>access_token</code>  is stored in session:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">function userCredentialGrant(req, res){\n    debug('userCredentialGrant');\n\n    const email = req.body.email;\n    const password = req.body.password;\n\n    oa.getOAuthPasswordCredentials(email, password)\n    .then(results =&gt; {\n        req.session.access_token =  results.access_token;\n        return;\n    })\n}\n</code></pre>\n<p>For each subsequent request, the <code>access_token</code> is supplied in the <code>X-Auth-Token</code> Header</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">function setAuthHeaders(req){\n  const headers = {};\n  if (req.session.access_token) {\n    headers['X-Auth-Token'] = req.session.access_token;\n  }\n  return headers;\n}\n</code></pre>\n<p>For example, when buying an item, two requests are made, the same  <code>X-Auth-Token</code> Header must be added to each request - therefore\nthe User can be identified and access granted.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">async function buyItem(req, res) {\n\n  const inventory = await retrieveEntity(req.params.inventoryId, {\n    options: 'keyValues',\n    type: 'InventoryItem',\n  }, setAuthHeaders(req));\n  const count = inventory.shelfCount - 1;\n\n  await updateExistingEntityAttributes(\n    req.params.inventoryId,\n    { shelfCount: { type: 'Integer', value: count } },\n    {\n      type: 'InventoryItem',\n    }, setAuthHeaders(req)\n  );\n  res.redirect(`/app/store/${inventory.refStore}/till`);\n}\n</code></pre>\n","event":[{"listen":"prerequest","script":{"id":"96981a47-ff81-43fb-b694-b80cc9a06f06","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"900a4c35-38c9-4e7d-a52d-35913760b3ba","type":"text/javascript","exec":[""]}}],"_postman_id":"7587b0d8-438e-4189-ba71-9ea67e53902d"},{"name":"Securing an IoT Agent South Port","item":[{"name":"Keyrock - IoT Sensor Obtains an Access Token","id":"5271fd3d-db77-4f8d-863c-cbb76de0d15e","request":{"method":"POST","header":[{"key":"Authorization","value":"Basic dHV0b3JpYWwtZGNrci1zaXRlLTAwMDAteHByZXNzd2ViYXBwOnR1dG9yaWFsLWRja3Itc2l0ZS0wMDAwLWNsaWVudHNlY3JldA==","description":"<p>base64 concatenation of Client Id and Client Secret</p>\n"},{"key":"Content-Type","value":"application/x-www-form-urlencoded"},{"key":"Accept","value":"application/json"}],"body":{"mode":"raw","raw":"username=iot_sensor_00000000-0000-0000-0000-000000000000&password=test&grant_type=password"},"url":"http://localhost:3005/oauth2/token","description":"<p>Logging in as an IoT Sensor follows the same  user-credentials flow as for a User.\nTo log in and identify the sensor <code>iot_sensor_00000000-0000-0000-0000-000000000000</code> with password <code>test</code></p>\n<p>The response returns an access code to identify the IoT Device</p>\n","urlObject":{"protocol":"http","path":["oauth2","token"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"5271fd3d-db77-4f8d-863c-cbb76de0d15e"},{"name":"PEP Proxy - Accessing IoT Agent with an Access Token","id":"8340f73f-7a57-44e5-9c88-7526efd73ba6","request":{"method":"POST","header":[{"key":"X-Auth-Token","value":" 79d07d0139c66b75fc25f56a88008553f12f6ac7"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:7897/iot/d?k=4jggokgpepnvsb2uv4s40d59ov&i=motion001","description":"<p>This example simulates a secured request coming from the device <code>motion001</code></p>\n<p>The POST request to a PEP Proxy in front to the Ultralight IoT Agent identifies\na previously provisioned resource <code>iot/d</code>endpoint and passes a measurement for\ndevice <code>motion001</code>. The addition of the <code>X-Auth-Token</code> Header identifies the source\nof the request as being registered in Keyrock, and therefore the measurement will \nbe passed on to the IoT Agent itself.</p>\n","urlObject":{"protocol":"http","port":"7897","path":["iot","d"],"host":["localhost"],"query":[{"key":"k","value":"4jggokgpepnvsb2uv4s40d59ov"},{"key":"i","value":"motion001"}],"variable":[]}},"response":[],"_postman_id":"8340f73f-7a57-44e5-9c88-7526efd73ba6"}],"id":"e01520ed-cf2c-412a-a2d1-0d1eaa58dbe5","description":"<p><img src=\"https://fiware.github.io/tutorials.PEP-Proxy/img/pep-proxy-south-port.png\" alt /></p>\n<h2 id=\"securing-an-iot-agent-south-port---pep-proxy-configuration\">Securing an IoT Agent South Port - PEP Proxy Configuration</h2>\n<p>The <code>iot-agent-proxy</code> container is an instance of FIWARE <strong>Wilma</strong> listening on port <code>7897</code>, it is configured to forward traffic to\n<code>iot-agent</code> on port <code>7896</code>, which is the default port that the Ultralight agent is listening to for HTTP Requests.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  iot-agent-proxy:\n    image: fiware/pep-proxy\n    container_name: fiware-iot-agent-proxy\n    hostname: iot-agent-proxy\n    networks:\n      default:\n        ipv4_address: 172.18.1.11\n    depends_on:\n      - keyrock\n    ports:\n      - \"7897:7897\"\n    expose:\n      - \"7897\"\n    environment:\n      - PEP_PROXY_APP_HOST=iot-agent\n      - PEP_PROXY_APP_PORT=7896\n      - PEP_PROXY_PORT=7897\n      - PEP_PROXY_IDM_HOST=keyrock\n      - PEP_PROXY_HTTPS_ENABLED=false\n      - PEP_PROXY_AUTH_ENABLED=false\n      - PEP_PROXY_IDM_SSL_ENABLED=false\n      - PEP_PROXY_IDM_PORT=3005\n      - PEP_PROXY_APP_ID=tutorial-dckr-site-0000-xpresswebapp\n      - PEP_PROXY_USERNAME=pep_proxy_00000000-0000-0000-0000-000000000000\n      - PEP_PASSWORD=test\n      - PEP_PROXY_PDP=idm\n      - PEP_PROXY_MAGIC_KEY=1234\n</code></pre>\n<p>The <code>PEP_PROXY_APP_ID</code> and <code>PEP_PROXY_USERNAME</code> would usually be obtained by adding new entries to the application in <strong>Keyrock</strong>,\nhowever, in this tutorial, they have been pre-defined by populating the <strong>MySQL</strong> database with data on start-up.</p>\n<p>The <code>iot-agent-proxy</code> container is listening on a single port:</p>\n<ul>\n<li>The PEP Proxy Port - <code>7897</code> is exposed purely for tutorial access - so that cUrl or Postman can requests directly to this <strong>Wilma</strong> instance\nwithout being part of the same network.</li>\n</ul>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>PEP_PROXY_APP_HOST</td>\n<td><code>iot-agent</code></td>\n<td>The hostname of the service behind the PEP Proxy</td>\n</tr>\n<tr>\n<td>PEP_PROXY_APP_PORT</td>\n<td><code>7896</code></td>\n<td>The port of the service behind the PEP Proxy</td>\n</tr>\n<tr>\n<td>PEP_PROXY_PORT</td>\n<td><code>7897</code></td>\n<td>The port that the PEP Proxy is listening on</td>\n</tr>\n<tr>\n<td>PEP_PROXY_IDM_HOST</td>\n<td><code>keyrock</code></td>\n<td>The hostname for the Identity Manager</td>\n</tr>\n<tr>\n<td>PEP_PROXY_HTTPS_ENABLED</td>\n<td><code>false</code></td>\n<td>Whether the PEP Proxy is running under HTTPS</td>\n</tr>\n<tr>\n<td>PEP_PROXY_AUTH_ENABLED</td>\n<td><code>false</code></td>\n<td>Whether the PEP Proxy is checking for Authorization</td>\n</tr>\n<tr>\n<td>PEP_PROXY_IDM_SSL_ENABLED</td>\n<td><code>false</code></td>\n<td>Whether the Identity Manager is running under HTTPS</td>\n</tr>\n<tr>\n<td>PEP_PROXY_IDM_PORT</td>\n<td><code>3005</code></td>\n<td>The Port for the Identity Manager instance</td>\n</tr>\n<tr>\n<td>PEP_PROXY_APP_ID</td>\n<td><code>tutorial-dckr-site-0000-xpresswebapp</code></td>\n<td></td>\n</tr>\n<tr>\n<td>PEP_PROXY_USERNAME</td>\n<td><code>pep_proxy_00000000-0000-0000-0000-000000000000</code></td>\n<td>The Username for the PEP Proxy</td>\n</tr>\n<tr>\n<td>PEP_PASSWORD</td>\n<td><code>test</code></td>\n<td>The Password for the PEP Proxy</td>\n</tr>\n<tr>\n<td>PEP_PROXY_PDP</td>\n<td><code>idm</code></td>\n<td>The Type of service offering the Policy Decision Point</td>\n</tr>\n<tr>\n<td>PEP_PROXY_MAGIC_KEY</td>\n<td><code>1234</code></td>\n<td></td>\n</tr>\n</tbody>\n</table>\n</div><p>For this example, the PEP Proxy is checking for Level 1 - <em>Authentication Access</em> not  Level 2 - <em>Basic Authorization</em> or \nLevel 3 - <em>Advanced Authorization</em>. </p>\n<h2 id=\"securing-an-iot-agent-south-port---application-configuration\">Securing an IoT Agent South Port - Application Configuration</h2>\n<p>The tutorial application also plays the role of providing data from our dummy IoT Sensors. The IoT Sensors are\nmaking HTTP request containing commands and measurements in Ultralight syntax. An IoT Sensor username and password\nhave already been registered in <strong>Keyrock</strong>, programmatically each sensor must obtain an OAuth2 access token and\nwill then make requests to  a second <strong>Wilma</strong> PEP Proxy in front of the <strong>IoT Agent</strong>.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  tutorial-app:\n    image: fiware/tutorials.context-provider\n    hostname: tutorial-app\n    container_name: tutorial-app\n    depends_on:\n        - orion-proxy\n        - iot-agent-proxy\n        - keyrock\n    networks:\n      default:\n        ipv4_address: 172.18.1.7\n        aliases:\n          - iot-sensors\n    expose:\n        - \"3000\"\n        - \"3001\"\n    ports:\n        - \"3000:3000\"\n        - \"3001:3001\"\n    environment:\n        - \"IOTA_HTTP_HOST=iot-agent-proxy\"\n        - \"IOTA_HTTP_PORT=7897\"\n        - \"DUMMY_DEVICES_PORT=3001\" # Port used by the dummy IOT devices to receive commands\n        - \"DUMMY_DEVICES_TRANSPORT=HTTP\" # Default transport used by dummy Io devices\n        - \"DUMMY_DEVICES_API_KEY=4jggokgpepnvsb2uv4s40d59ov\"\n        - \"DUMMY_DEVICES_USER=iot_sensor_00000000-0000-0000-0000-000000000000\"\n        - \"DUMMY_DEVICES_PASSWORD=test\"\n</code></pre>\n<p>The <code>tutorial</code> container hosts the dummy Ultralight sensors. Rather than accessing the <strong>IoT Agent</strong> directly on port <code>7896</code> as\nshown in all previous tutorials, all traffic is forwarded to <code>iot-agent-proxy</code> on port <code>7897</code>. Most of the relevant <code>tutorial</code>\ncontainer settings have been described in previous tutorials, the <code>DUMMY_DEVICES_USER</code> and <code>DUMMY_DEVICES_PASSWORD</code> are new\nadditions.</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>IOTA_HTTP_HOST</td>\n<td><code>iot-agent-proxy</code></td>\n<td>The host name of the Wilma PEP Proxy protecting the IoT Agent for UltraLight 2.0</td>\n</tr>\n<tr>\n<td>IOTA_HTTP_PORT</td>\n<td><code>7896</code></td>\n<td>The port that the Wilma PEP Proxy protecting the IoT Agent is listenting on</td>\n</tr>\n<tr>\n<td>DUMMY_DEVICES_PORT</td>\n<td><code>3001</code></td>\n<td>Port used by the dummy IOT devices to receive commands</td>\n</tr>\n<tr>\n<td>DUMMY_DEVICES_TRANSPORT</td>\n<td><code>HTTP</code></td>\n<td>Default transport used by dummy Io devices</td>\n</tr>\n<tr>\n<td>DUMMY_DEVICES_API_KEY</td>\n<td><code>4jggokgpepnvsb2uv4s40d59ov</code></td>\n<td>Random security key used for UltraLight interactions - ensures the integrity of interactions between the devices and the IoT Agent</td>\n</tr>\n<tr>\n<td>DUMMY_DEVICES_USER</td>\n<td><code>iot_sensor_00000000-0000-0000-0000-000000000000</code></td>\n<td>Username assigned to the device(s) in <strong>Keyrock</strong></td>\n</tr>\n<tr>\n<td>DUMMY_DEVICES_PASSWORD</td>\n<td><code>test</code></td>\n<td>Password assigned to the device(s) in <strong>Keyrock</strong></td>\n</tr>\n</tbody>\n</table>\n</div><p>The <code>DUMMY_DEVICES_USER</code> and <code>DUMMY_DEVICES_PASSWORD</code> would usually be obtained by adding new entries to the application in <strong>Keyrock</strong>,\nhowever, in this tutorial, they have been pre-defined by populating the <strong>MySQL</strong> database with data on start-up.</p>\n<h2 id=\"securing-iot-agent---start-up\">Securing IoT Agent - Start up</h2>\n<p>To start the system with a PEP Proxies protecting access to both <strong>Orion</strong> and the <strong>IoT Agent</strong> run the following command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services southport\n</code></pre>\n<h2 id=\"securing-an-iot-agent-south-port----sample-code\">Securing an IoT Agent South Port -  Sample Code</h2>\n<p>When an IoT Sensor starts up, it must log-in like any other user to obtain an access token:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">const DUMMY_DEVICE_HTTP_HEADERS = { 'Content-Type': 'text/plain' };\n</code></pre>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">function initSecureDevices(){\n    Security.oa.getOAuthPasswordCredentials(process.env.DUMMY_DEVICES_USER, process.env.DUMMY_DEVICES_PASSWORD)\n    .then(results =&gt; {\n        DUMMY_DEVICE_HTTP_HEADERS['X-Auth-Token'] = results.access_token;\n        return;\n    })\n    .catch(error =&gt; {\n        debug(error);\n        return;\n    });\n}\n</code></pre>\n<p>Each HTTP request thereafter includes the <code>X-Auth-Token</code> Header in the request identifying the IoT Sensor:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-javascript\">const options = { method: 'POST',\n  url: UL_URL,\n  qs: { k: UL_API_KEY, i: deviceId },\n  headers: DUMMY_DEVICE_HTTP_HEADERS,\n  body: state };\n\nrequest(options,  (error) =&gt; {\n  if (error){\n    debug( debugText +  \" \" + error.code)\n  } \n});\n</code></pre>\n","event":[{"listen":"prerequest","script":{"id":"6d3383f2-97c3-43c6-a850-81bba51d5b17","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"a21a68b9-aa92-4710-845f-c16bfe75511a","type":"text/javascript","exec":[""]}}],"_postman_id":"e01520ed-cf2c-412a-a2d1-0d1eaa58dbe5"},{"name":"Securing an IoT Agent North Port","item":[{"name":"Keyrock  - Obtaining a permanent token","id":"4f1c365a-e1ef-41e2-acf0-111c3dec15b4","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"description":"<p>base64 concatenation of Client Id and Client Secret</p>\n","key":"Authorization","value":"Basic dHV0b3JpYWwtZGNrci1zaXRlLTAwMDAteHByZXNzd2ViYXBwOnR1dG9yaWFsLWRja3Itc2l0ZS0wMDAwLWNsaWVudHNlY3JldA=="},{"key":"Content-Type","value":"application/x-www-form-urlencoded"},{"key":"Accept","value":"application/json"}],"body":{"mode":"raw","raw":"username=alice-the-admin@test.com&password=test&grant_type=password&scope=permanent"},"url":"http://localhost:3005/oauth2/token","description":"<p>The Keyrock application has been configured to offer permanent tokens</p>\n<p>The standard <code>Authorization: Basic</code> header holds the base 64 concatentation of the client id and secret. The parameter\n<code>scope=permanent</code> is added to retrieve permanent tokens when available. The response contains an <code>access_token</code> which\ncan be used for device provisioning.</p>\n","urlObject":{"protocol":"http","path":["oauth2","token"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"4f1c365a-e1ef-41e2-acf0-111c3dec15b4"},{"name":"IoT Agent - Provisioning a trusted service group","id":"07fbab9f-cba8-4265-8e4a-8e3004126f89","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"PUT","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-servicepath","value":"/","type":"text"},{"key":"Content-Type","value":"application/json","type":"text","name":"Accept"}],"body":{"mode":"raw","raw":"{\n     \"cbroker\":     \"http://orion-proxy:1027\",\n     \"trust\": \"b7a4baa86642280b446d733dc2d62c8a21112481\"\n}"},"url":"http://localhost:4041/iot/services?resource=/iot/d&apikey=1068318794","description":"<p>The Access token (also known as a Trust Token) must be added to the service group.</p>\n","urlObject":{"protocol":"http","port":"4041","path":["iot","services"],"host":["localhost"],"query":[{"key":"resource","value":"/iot/d"},{"key":"apikey","value":"1068318794"}],"variable":[]}},"response":[],"_postman_id":"07fbab9f-cba8-4265-8e4a-8e3004126f89"},{"name":"IoT Agent - Provisioning a sensor","id":"2e3bc39b-26fa-4ab7-a726-d5e0eaf9b082","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"fiware-service","value":"openiot"},{"key":"fiware-service-path","value":"/","type":"text"},{"key":"Accept","value":"application/json","type":"text","name":"Accept"}],"body":{"mode":"raw","raw":"{\n \"devices\": [\n   {\n     \"device_id\":   \"motion001\",\n     \"entity_name\": \"urn:ngsi-ld:Motion:001\",\n     \"entity_type\": \"Motion\",\n     \"timezone\":    \"Europe/Berlin\",\n     \"attributes\": [\n       { \"object_id\": \"c\", \"name\": \"count\", \"type\": \"Integer\" }\n     ],\n     \"static_attributes\": [\n       { \"name\":\"refStore\", \"type\": \"Relationship\", \"value\": \"urn:ngsi-ld:Store:001\"}\n     ]\n   }\n ]\n}"},"url":"http://localhost:4041/iot/devices","description":"<p>Once a trusted service group has been created, a device can be provisioned in the usual manner</p>\n","urlObject":{"protocol":"http","port":"4041","path":["iot","devices"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"2e3bc39b-26fa-4ab7-a726-d5e0eaf9b082"}],"id":"5c3e32b4-3054-43e1-a1d5-fde7bf580d62","description":"<p><img src=\"https://fiware.github.io/tutorials.PEP-Proxy/img/pep-proxy-north-port.png\" alt /></p>\n<h2 id=\"securing-an-iot-agent-north-port---iot-agent-configuration\">Securing an IoT Agent North Port - IoT Agent Configuration</h2>\n<p>The <code>iot-agent</code> container is listening on port <code>4041</code>, it is configured to forward traffic to <code>orion-proxy</code> on port\n<code>1027</code>.</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">iot-agent:\n    image: fiware/iotagent-ul:${ULTRALIGHT_VERSION}\n    hostname: iot-agent\n    container_name: fiware-iot-agent\n    depends_on:\n        - mongo-db\n        - orion\n    networks:\n        - default\n    ports:\n        - \"4041:4041\"\n        - \"7896:7896\"\n    environment:\n        - IOTA_CB_HOST=orion-proxy\n        - IOTA_CB_PORT=1027\n        - IOTA_NORTH_PORT=4041\n        - IOTA_REGISTRY_TYPE=mongodb\n        - IOTA_LOG_LEVEL=DEBUG\n        - IOTA_TIMESTAMP=true\n        - IOTA_CB_NGSI_VERSION=v2\n        - IOTA_AUTOCAST=true\n        - IOTA_MONGO_HOST=mongo-db\n        - IOTA_MONGO_PORT=27017\n        - IOTA_MONGO_DB=iotagentul\n        - IOTA_HTTP_PORT=7896\n        - IOTA_PROVIDER_URL=http://iot-agent:4041\n        - IOTA_AUTH_ENABLED=true\n        - IOTA_AUTH_TYPE=oauth2\n        - IOTA_AUTH_HEADER=Authorization\n        - IOTA_AUTH_HOST=keyrock\n        - IOTA_AUTH_PORT=3005\n        - IOTA_AUTH_URL=http://keyrock:3005\n        - IOTA_AUTH_TOKEN_PATH=/oauth2/token\n        - IOTA_AUTH_PERMANENT_TOKEN=true\n        - IOTA_AUTH_CLIENT_ID=tutorial-dckr-site-0000-xpresswebapp\n        - IOTA_AUTH_CLIENT_SECRET=tutorial-dckr-host-0000-clientsecret\n</code></pre>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>IOTA_AUTH_ENABLED</td>\n<td><code>true</code></td>\n<td>Whether to use authorization on the north port</td>\n</tr>\n<tr>\n<td>IOTA_AUTH_TYPE</td>\n<td><code>oauth2</code></td>\n<td>The type of authorization to be used (Keyrock uses OAuth2)</td>\n</tr>\n<tr>\n<td>IOTA_AUTH_HEADER</td>\n<td><code>Authorization</code></td>\n<td>The name of the header to be added to requests</td>\n</tr>\n<tr>\n<td>IOTA_AUTH_HOST</td>\n<td><code>keyrock</code></td>\n<td>The Identity Manager holding the application</td>\n</tr>\n<tr>\n<td>IOTA_AUTH_PORT</td>\n<td><code>3005</code></td>\n<td>The port the Identity Manager is listening on</td>\n</tr>\n<tr>\n<td>IOTA_AUTH_URL</td>\n<td><code>http://keyrock:3005</code></td>\n<td>The URL for authentication requests</td>\n</tr>\n<tr>\n<td>IOTA_AUTH_CLIENT_ID</td>\n<td><code>tutorial-dckr-site-0000-xpresswebapp</code></td>\n<td>the Id of the applicantion within Keyrock</td>\n</tr>\n<tr>\n<td>IOTA_AUTH_CLIENT_SECRET</td>\n<td><code>tutorial-dckr-host-0000-clientsecret</code></td>\n<td>The client secret of the application within Keyrock</td>\n</tr>\n<tr>\n<td>IOTA_AUTH_PERMANENT_TOKEN</td>\n<td><code>true</code></td>\n<td>Whether to use permanent tokens</td>\n</tr>\n<tr>\n<td>IOTA_AUTH_TOKEN_PATH</td>\n<td><code>/oauth2/token</code></td>\n<td>the path to be used when requesting tokens</td>\n</tr>\n</tbody>\n</table>\n</div><h2 id=\"securing-an-iot-agent-north-port---start-up\">Securing an IoT Agent North Port - Start up</h2>\n<p>To start the system with a PEP Proxy protecting access to between <strong>Orion</strong> and the <strong>IoT Agent</strong> North Port run the\nfollowing command:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>./services northport\n</code></pre>","event":[{"listen":"prerequest","script":{"id":"6d3383f2-97c3-43c6-a850-81bba51d5b17","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"a21a68b9-aa92-4710-845f-c16bfe75511a","type":"text/javascript","exec":[""]}}],"_postman_id":"5c3e32b4-3054-43e1-a1d5-fde7bf580d62"}],"event":[{"listen":"prerequest","script":{"id":"fcfbbecf-1166-488b-b366-a7cc7bd67d9d","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"be74ae42-b383-4989-b105-6b28196c6cfe","type":"text/javascript","exec":[""]}}],"variable":[{"key":"keyrock","value":"localhost:3005"},{"key":"X-Auth-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"},{"key":"X-Subject-token","value":"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"},{"key":"application-id","value":"tutorial-dckr-site-0000-xpresswebapp"},{"key":"X-Access-token","value":" 79d07d0139c66b75fc25f56a88008553f12f6ac7"},{"key":"Authorization","value":"dHV0b3JpYWwtZGNrci1zaXRlLTAwMDAteHByZXNzd2ViYXBwOnR1dG9yaWFsLWRja3Itc2l0ZS0wMDAwLWNsaWVudHNlY3JldA=="},{"key":"iot-agent-id","value":"iot_sensor_00000000-0000-0000-0000-000000000000"},{"key":"pep-proxy-id","value":"pep_proxy_00000000-0000-0000-0000-000000000000"}]}