{"info":{"_postman_id":"83b05e2a-e6d6-4869-a632-afcbb2072759","name":"FIWARE Identity Management","description":"<html><head></head><body><p>This tutorial is an introduction to <a href=\"http://fiware-idm.readthedocs.io/en/latest/\">FIWARE Keyrock</a> - a generic enabler which introduces\n<strong>Identity Management</strong> into FIWARE services. The tutorial explains how to create users and organizations in preparation to assign\nroles and permissions to them in a later tutorial.</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.Identity-Management/icon/GitHub-Mark-32px.png\" alt=\"GitHub\"> <a href=\"https://github.com/Fiware/tutorials.Identity-Management\">FIWARE 401: Identity Management</a></p>\n<h1 id=\"identity-management\">Identity Management</h1>\n<blockquote>\n<p>\"If one meets a powerful person — ask them five questions: ‘What power have you got?\nWhere did you get it from? In whose interests do you exercise it? To whom are you\naccountable? And how can we get rid of you?’\"</p>\n<p>— Anthony Wedgwood Benn (The Five Essential Questions of Democracy)</p>\n</blockquote>\n<p>In computer security terminology, Identity management is the security and business discipline that \"enables the right\nindividuals to access the right resources at the right times and for the right reasons\". It addresses the need to\nensure appropriate access to resources across disparate systems.</p>\n<p>The FIWARE framework consists of a series of separate components, and the security chapter aims to implement\nthe common needs of these components regarding who (or what) gets to access which resources within the system,\nbut before access to resources can be locked down, the identity of the person (or service) making the request\nneeds to be known. The FIWARE <strong>Keyrock</strong> Generic Enabler sets up all of the common characteristics of an\nIdentity Management System out-of-the-box, so that other components are able to use standard authentication\nmechanisms to  accept or reject requests based on industry standard protocols.</p>\n<p>Identity Management therefore covers the issues of how to gain an identity within the system, the protection\nof that identity and the surrounding technologies such as passwords and network protocols.</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.Identity-Management/img/entities.png\" alt=\"\"></p>\n<h2 id=\"video--introduction-to-keyrock\">Video : Introduction to Keyrock</h2>\n<p><a href=\"https://www.youtube.com/watch?v=dHyVTan6bUY\"><img src=\"http://img.youtube.com/vi/dHyVTan6bUY/0.jpg\" alt=\"\"></a></p>\n<p>Click on the image above to watch an introductory video describing the <strong>Keyrock</strong> Generic Enabler</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.Entity-Relationships/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 introduction will only make use of one FIWARE component - the <a href=\"http://fiware-idm.readthedocs.io/\">Keyrock</a>\nIdentity Management Generic Enabler. Usage of <strong>Keyrock</strong> alone alone is insufficient for an application to qualify\n as <em>“Powered by FIWARE”</em>.  Additionally will be persisting user data in a <strong>MySQL</strong>  database.</p>\n<p>The overall architecture will consist of the following elements:</p>\n<ul>\n<li><p>One <strong>FIWARE Generic Enabler</strong>:</p>\n<ul>\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</ul>\n</li>\n<li><p>One <a href=\"https://www.mysql.com/\">MySQL</a> database :</p>\n<ul>\n<li>Used to persist user identities, applications, roles and permissions</li>\n</ul>\n</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><img src=\"https://fiware.github.io/tutorials.Identity-Management/img/architecture.png\" alt=\"\"></p>\n<p>The specific architecture of each section of the tutorial is discussed below.</p>\n<h2 id=\"keyrock-configuration\">Keyrock Configuration</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  keyrock:\n    image: fiware/idm\n    container_name: fiware-keyrock\n    hostname: keyrock\n    depends_on:\n      - mysql-db\n    ports:\n      - \"3005:3005\"\n      - \"3443:3443\"\n    environment:\n      - DATABASE_HOST=mysql-db\n      - IDM_DB_PASS_FILE=/run/secrets/my_secret_data\n      - IDM_DB_USER=root\n      - IDM_HOST=http://localhost:3005\n      - IDM_PORT=3005\n      - IDM_HTTPS_ENABLED=true\n      - IDM_HTTPS_PORT=3443\n      - IDM_ADMIN_USER=admin\n      - IDM_ADMIN_EMAIL=admin@test.com\n      - IDM_ADMIN_PASS=1234\n    secrets:\n      - my_secret_data\n</code></pre>\n<p>The <code>idm</code> container is a web application server listening on two ports:</p>\n<ul>\n<li>Port <code>3005</code> has been exposed for HTTP traffic so we can display the web page and interact with the REST API.</li>\n<li>Port <code>3443</code> has been exposed for secure HTTPS traffic for the website and REST API</li>\n</ul>\n<blockquote>\n<p><strong>Note</strong> HTTPS should be used throughout for any secured application, but to do this properly,\n<strong>Keyrock</strong> requires a trusted SSL certificate - the default certificate is self-certified and\navailable for testing purposes. The certificates can be overridden by attaching a volume to\nreplace the files under <code>/opt/fiware-idm/certs</code>.</p>\n<p>In a production environment, all access should occur over HTTPS, to avoid sending\nany sensitive information using plain-text. Alternatively HTTP can be used within a\nprivate network behind a configured HTTPS Reverse Proxy</p>\n<p>The port <code>3005</code> offering the HTTP protocol is being exposed for demonstration purposes only and to\nsimplify the interactions within this tutorial - you may also use HTTPS on port <code>3443</code> with certain\ncaveats.</p>\n<p>If you want to use HTTPS to access the REST API when you are using Postman, ensure that SSL\ncertificate verfication is OFF. If you want to use HTTPS to access the web front-end, please\naccept any security warnings issued.</p>\n</blockquote>\n<p>The <code>idm</code> container is driven by environment variables as shown:</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>IDM_DB_PASS</td>\n<td><code>idm</code></td>\n<td>Password of the attached MySQL Database - secured by <strong>Docker Secrets</strong> (see below)</td>\n</tr>\n<tr>\n<td>IDM_DB_USER</td>\n<td><code>root</code></td>\n<td>User name of the default MySQL user - left in plain-text</td>\n</tr>\n<tr>\n<td>IDM_HOST</td>\n<td><code>http://localhost:3005</code></td>\n<td>Host name of the <strong>Keyrock</strong>  App Server - used in activation eMails when signing up users</td>\n</tr>\n<tr>\n<td>IDM_PORT</td>\n<td><code>3005</code></td>\n<td>Port used by the <strong>Keyrock</strong> App Server for HTTP traffic - this has been altered from the default 3000 port to avoid clashes</td>\n</tr>\n<tr>\n<td>IDM_HTTPS_ENABLED</td>\n<td><code>true</code></td>\n<td>Whether to offer HTTPS Support - this will use the self-signed certs unless overridden</td>\n</tr>\n<tr>\n<td>IDM_HTTPS_PORT</td>\n<td><code>3443</code></td>\n<td>Port used by the <strong>Keyrock</strong> App Server for HTTP traffic  this has been altered from the default 443</td>\n</tr>\n</tbody>\n</table>\n</div><blockquote>\n<p>:information_source: <strong>Note</strong> that this example has secured the MySQL password using <strong>Docker Secrets</strong>\nBy using <code>IDM_DB_PASS</code> with the <code>_FILE</code> suffix and referring to a secrets file location.\nThis avoids exposing the password as an <code>ENV</code> variable in plain-text - either in the <code>Dockerfile</code> Image or\nas an injected variable which could be read using <code>docker inspect</code>.</p>\n<p>The following list of variables (where used) should be set via secrets with the  <code>_FILE</code> suffix  in a Production System:</p>\n<ul>\n<li><code>IDM_SESSION_SECRET</code></li>\n<li><code>IDM_ENCRYPTION_KEY</code></li>\n<li><code>IDM_DB_PASS</code></li>\n<li><code>IDM_DB_USER</code></li>\n<li><code>IDM_ADMIN_ID</code></li>\n<li><code>IDM_ADMIN_USER</code></li>\n<li><code>IDM_ADMIN_EMAIL</code></li>\n<li><code>IDM_ADMIN_PASS</code></li>\n<li><code>IDM_EX_AUTH_DB_USER</code></li>\n<li><code>IDM_EX_AUTH_DB_PASS</code></li>\n</ul>\n</blockquote>\n<h2 id=\"mysql-configuration\">MySQL Configuration</h2>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  mysql-db:\n    image: mysql:5.7\n    hostname: mysql-db\n    container_name: db-mysql\n    expose:\n      - \"3306\"\n    ports:\n      - \"3306:3306\"\n    networks:\n      default:\n    environment:\n      - \"MYSQL_ROOT_PASSWORD_FILE=/run/secrets/my_secret_data\"\n      - \"MYSQL_ROOT_HOST=172.18.1.5\"\n    volumes:\n      - mysql-db:/var/lib/mysql\n    secrets:\n      - my_secret_data\n</code></pre>\n<p>The <code>mysql-db</code> container is listening on a single port:</p>\n<ul>\n<li>Port <code>3306</code> is the default port for a MySQL server. It has been exposed so you can also run other database tools to display data if you wish</li>\n</ul>\n<p>The <code>mysql-db</code> container is driven by environment variables as shown:</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>MYSQL_ROOT_PASSWORD</td>\n<td><code>123</code>.</td>\n<td>specifies a password that is set for the MySQL <code>root</code> account - secured by <strong>Docker Secrets</strong> (see below)</td>\n</tr>\n<tr>\n<td>MYSQL_ROOT_HOST</td>\n<td><code>root</code></td>\n<td>By default, MySQL creates the <code>root'@'localhost</code> account. This account can only be connected to from inside the container. Setting this environment variable allows root connections from other hosts</td>\n</tr>\n</tbody>\n</table>\n</div><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.Identity-Management.git\ncd tutorials.Identity-Management\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.Identity-Management/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<h3 id=\"reading-directly-from-the-keyrock-mysql-database\">Reading directly from the Keyrock MySQL Database</h3>\n<p>All Identify Management records  and relationships are held within the the attached MySQL database. This can be\naccessed by entering the running Docker container as shown:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">docker exec -it db-mysql bash\n</code></pre>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">mysql -u &lt;user&gt; -p&lt;password&gt; idm\n</code></pre>\n<p>Where <code>&lt;user&gt;</code> and <code>&lt;password&gt;</code> match the values defined in the <code>docker-compose</code> file for <code>MYSQL_ROOT_PASSWORD</code>\nand <code>MYSQL_ROOT_USER</code>. The default values for the tutorial are usually <code>root</code> and <code>secret</code>.</p>\n<p>SQL commands can then be entered from the command line. e.g.:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-SQL\">select id, username, email, password from user;\n</code></pre>\n<h3 id=\"uuids-within-keyrock\">UUIDs within Keyrock</h3>\n<p>All IDs and tokens within  <strong>Keyrock</strong> are subject to change. The following values will need to be amended when\nquerying for records. Record IDs use Universally Unique Identifiers - UUIDs.</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Description</th>\n<th>Sample Value</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>keyrock</code></td>\n<td>URL for the location of the <strong>Keyrock</strong> service</td>\n<td><code>localhost:3005</code></td>\n</tr>\n<tr>\n<td><code>X-Auth-token</code></td>\n<td>Token received in the Header when logging in as a user - in other words <em>\"Who am I?\"</em></td>\n<td><code>51f2e380-c959-4dee-a0af-380f730137c3</code></td>\n</tr>\n<tr>\n<td><code>X-Subject-token</code></td>\n<td>Token added to requests to define <em>\"Who do I want to inquire about?\"</em> - This can also be a repeat the <code>X-Auth-token</code> defined above</td>\n<td><code>51f2e380-c959-4dee-a0af-380f730137c3</code></td>\n</tr>\n<tr>\n<td><code>user-id</code></td>\n<td>id of an existing user, found with the <code>user</code>  table</td>\n<td><code>96154659-cb3b-4d2d-afef-18d6aec0518e</code></td>\n</tr>\n<tr>\n<td><code>organization-id</code></td>\n<td>id of an existing organization, found with the <code>organization</code>  table</td>\n<td><code>e424ed98-c966-46e3-b161-a165fd31bc01</code></td>\n</tr>\n<tr>\n<td><code>organization-role-id</code></td>\n<td>type of role a user has within an organization either <code>owner</code> or <code>member</code></td>\n<td><code>member</code></td>\n</tr>\n</tbody>\n</table>\n</div><p>Tokens are designed to expire after a set period. If the <code>X-Auth-token</code> value you are using has expired, log-in again to obtain a new token.</p>\n<h2 id=\"video--creating-user-accounts-with-the-keyrock-gui\">Video : Creating User Accounts with the Keyrock GUI</h2>\n<p><a href=\"https://www.youtube.com/watch?v=dtKsjGbJ7Xc\"><img src=\"http://img.youtube.com/vi/dtKsjGbJ7Xc/0.jpg\" alt=\"\"></a></p>\n<p>Click on the image above to watch a video demonstrating how to create users with the <strong>Keyrock</strong> GUI</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"Identity Management","slug":"identity-management"},{"content":"Prerequisites","slug":"prerequisites"},{"content":"Architecture","slug":"architecture"},{"content":"Start Up","slug":"start-up"}],"owner":"513743","collectionId":"83b05e2a-e6d6-4869-a632-afcbb2072759","publishedId":"RWMLLRui","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF7059"},"publishDate":"2020-01-02T11:03:10.000Z"},"item":[{"name":"Logging In - Authentication","item":[{"name":"Create token with Password","id":"4e3e28a2-de58-4ca0-b50a-777ba7ecbf16","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n  \"name\": \"admin@test.com\",\n  \"password\": \"1234\"\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.\nThe URL <code>https://localhost:3443/v1/auth/tokens</code> should also work in a secure system.</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":"4e3e28a2-de58-4ca0-b50a-777ba7ecbf16"},{"name":"Get User Information via a Token","id":"4220597a-8fb8-4752-806a-f9ae06834161","request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"},{"key":"X-Subject-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/auth/tokens","description":"<p>In order to manage the Identity Manager through the API you must obtain an access token to be included in HTTP headers. There are two methods to obtain an access token.</p>\n","urlObject":{"protocol":"http","path":["v1","auth","tokens"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"4220597a-8fb8-4752-806a-f9ae06834161"},{"name":"Refresh token with Token","id":"8821c498-2b44-4feb-b9d8-b639ebb06bc2","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n  \"token\": \"70bb37f8-938e-4158-a8ab-7218af3c384d\"\n}"},"url":"http://localhost:3005/v1/auth/tokens","description":"<p>Tokens are time limited - it is no longer possible to gain access once a token has expired.\nHowever it is possible to refresh a token for a newer one prior to expiry.</p>\n<p>Most applications use this end-point to avoid timing out a user whilst they are interacting with the application.</p>\n<p> A new token is returned in the <code>X-Subject-Token</code> header of the response.</p>\n","urlObject":{"protocol":"http","path":["v1","auth","tokens"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"8821c498-2b44-4feb-b9d8-b639ebb06bc2"}],"id":"b71456c0-d517-4158-bbcd-f58baa22c16f","description":"<p>The Log-in Screen allows an existing user to identify themselves and obtain a token for further operations. It is the initial start-up\nscreen of the <strong>Keyrock</strong> GUI - <code>http://localhost:3005/idm</code> (or <code>https://localhost:3443/idm</code> and accept the warnings)</p>\n<p><img src=\"https://fiware.github.io/tutorials.Identity-Management/img/log-in.png\" alt /></p>\n<p>Enter a user name and password to enter the application. The default super-user has the values <code>admin@test.com</code> and <code>1234</code>.</p>\n","event":[{"listen":"prerequest","script":{"id":"04f600b8-5b31-4ed2-ada6-7db583d6b15b","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"1b5166e8-d073-4cef-9649-def95e2eeaef","type":"text/javascript","exec":[""]}}],"_postman_id":"b71456c0-d517-4158-bbcd-f58baa22c16f"},{"name":"Managing User Accounts","item":[{"name":"Create a User","id":"5fb8c7da-9be1-4ca4-8f98-d2537f49df87","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"raw","raw":"{\n  \"user\": {\n    \"username\": \"admin2\",\n    \"email\": \"admin2@test.com\",\n    \"password\": \"test\",\n    \"admin\": true\n  }\n}"},"url":"http://localhost:3005/v1/users","description":"<h2 id=\"rest-api\">REST API</h2>\n<p>To create a new user via the REST API, send a POST request to the <code>/v1/users</code> endpoint containing\nthe <code>username</code>,<code>email</code> and <code>password</code> along with the <code>X-Auth-token</code> header from a previously logged in administrative user.</p>\n<h2 id=\"gui\">GUI</h2>\n<p>Alternatively, Users are able to sign-up for themselves using the GUI. The only requirement is an email address and a password.</p>\n<p><img src=\"https://fiware.github.io/tutorials.Identity-Management/img/sign-up.png\" alt /></p>\n<p>Once an account is created, the user is sent an eMail to confirm their existence and activate their account.</p>\n<p><img src=\"https://fiware.github.io/tutorials.Identity-Management/img/email.png\" alt /></p>\n<p>The REST API is also able to create and amend users without their own interaction - this could be useful for\nbulk CRUD actions for example.</p>\n<blockquote>\n<p><strong>Note</strong> - an eMail server must be configured to send out invites properly, otherwise the invitation\nmay be deleted as spam. For testing purposes, it is easier to update the users table directly:\n<code>update user set enabled = 1;</code></p>\n</blockquote>\n","urlObject":{"protocol":"http","path":["v1","users"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"5fb8c7da-9be1-4ca4-8f98-d2537f49df87"},{"name":"Read info about a User","id":"9bb115e1-4aba-44ba-a0de-bf147eb32fa3","request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/users/aaaaaaaa-good-0000-0000-000000000000","description":"<p>Making a GET request to a resource under the <code>/v1/users/aaaaaaaa-good-0000-0000-000000000000</code> endpoint will return the user listed under that id.\nThe <code>X-Auth-token</code> must be supplied in the headers.</p>\n<p>The response contains basic details of the account in question.</p>\n","urlObject":{"protocol":"http","path":["v1","users","aaaaaaaa-good-0000-0000-000000000000"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"9bb115e1-4aba-44ba-a0de-bf147eb32fa3"},{"name":"List Users","id":"bf4cf4d5-f9ac-462b-8008-dbe25fbd1ada","request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/users","description":"<p>Obtaining a complete list of all users is a super-admin permission requiring the <code>X-Auth-token</code>  - most users will \nonly be permitted to return users within their own organization. Listing users can be done by making a GET request to \nthe  <code>/v1/users</code> endpoint</p>\n","urlObject":{"protocol":"http","path":["v1","users"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"bf4cf4d5-f9ac-462b-8008-dbe25fbd1ada"},{"name":"Update a User","id":"a81ae6a1-fb6e-465c-b2fa-101ce0b02ce8","request":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"raw","raw":"{\n\t\"user\": {\n\t    \"username\": \"alice\",\n\t    \"email\": \"alice@test.com\",\n\t    \"enabled\": true,\n\t    \"gravatar\": false,\n\t    \"date_password\": \"2018-07-26T15:25:14.000Z\",\n\t    \"description\": \"Alice works for FIWARE\",\n\t    \"website\": \"http://www.fiware.org\"\n\t}\n}"},"url":"http://localhost:3005/v1/users/aaaaaaaa-good-0000-0000-000000000000","description":"<p>Within the GUI, users can be updated from the settings page. This can also be done from the command line\nby making PATCH request to  <code>/v1/users/&lt;user-id&gt;</code> endpoint when the user id is known. The <code>X-Auth-token</code>\nheader must also be set.</p>\n<p>The response lists the fields which have been updated.</p>\n","urlObject":{"protocol":"http","path":["v1","users","aaaaaaaa-good-0000-0000-000000000000"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"a81ae6a1-fb6e-465c-b2fa-101ce0b02ce8"},{"name":"Delete a User","id":"ac942a43-afad-42d5-87a3-800557eda774","request":{"method":"DELETE","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/users/aaaaaaaa-good-0000-0000-000000000000","description":"<p>Within the GUI, users can delete their account from the settings page, selecting the <strong>Cancel Account</strong> Option,\nonce again a super-admin user can do this from the command line by sending a DELETE request to the \n<code>/v1/users/aaaaaaaa-good-0000-0000-000000000000</code> endpoint. The <code>X-Auth-token</code> header must also be set.</p>\n","urlObject":{"protocol":"http","path":["v1","users","aaaaaaaa-good-0000-0000-000000000000"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"ac942a43-afad-42d5-87a3-800557eda774"}],"id":"6ca001d1-68e7-43e2-81bf-bdf7d2ac669d","description":"<p>Users accounts are at the heart of any identity management system. The essential fields of every account hold a unique user name\nand email address to identify the user, along with a password for authentication. The other optional fields\nadd more information about the user such as a user website, description or avatar.</p>\n<p>As the default super-admin user <code>admin@test.com</code> with a password of <code>1234</code>, we will set up a series of user accounts and assign them to\nrelevant organizations within the system.</p>\n<h3 id=\"dramatis-personae\">Dramatis Personae</h3>\n<p>The following people 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<p>All the CRUD actions for Users require an <code>X-Auth-token</code> header from a previously logged in administrative user to be able\nto read or modify other user accounts. The standard CRUD actions are assigned to the appropriate HTTP verbs (POST, GET, PATCH and DELETE)\nunder the <code>/v1/users</code> endpoint.</p>\n","event":[{"listen":"prerequest","script":{"id":"f181be01-0817-44ba-a88d-241b9da2cf3b","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"28237ecf-a94a-4783-91e6-634dc845b7f7","type":"text/javascript","exec":[""]}}],"_postman_id":"6ca001d1-68e7-43e2-81bf-bdf7d2ac669d"},{"name":"Grouping Accounts under Organizations","item":[{"name":"Organization CRUD Actions","item":[{"name":"Create an Organization","id":"a6a5e5c1-6696-44f2-8d43-dabfd09e7c9e","request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"raw","raw":"{\n  \"organization\": {\n    \"name\": \"Security\",\n    \"description\": \"This group is for the store detectives\"\n  }\n}"},"url":"http://localhost:3005/v1/organizations","description":"<p>To create a new organization, send a POST request to the <code>/v1/organizations</code> endpoint containing the <code>name</code> and <code>description</code> along with the <code>X-Auth-token</code> header from a previously logged in user.</p>\n<p>The Organization is created and the user who created it is automatically assigned as a user. \nThe response returns UUID to identify the new organization.</p>\n","urlObject":{"protocol":"http","path":["v1","organizations"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"a6a5e5c1-6696-44f2-8d43-dabfd09e7c9e"},{"name":"List Organizations","id":"2a8828a2-661d-4a30-a99e-da51e0712d0d","request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/organizations","urlObject":{"protocol":"http","path":["v1","organizations"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"2a8828a2-661d-4a30-a99e-da51e0712d0d"},{"name":"Read info about an Organization","id":"21952466-75bf-4ee7-96aa-9b10ef948cdd","request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/organizations/security-team-0000-0000-000000000000","description":"<p>Making a GET request to a resource under the <code>/v1/organizations/security-team-0000-0000-000000000000</code> endpoint will return the organization\nlisted under that id. The <code>X-Auth-token</code> must be supplied in the headers as only permitted organizations will be shown.</p>\n<p>The response returns the details of the organization.</p>\n","urlObject":{"protocol":"http","path":["v1","organizations","security-team-0000-0000-000000000000"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"21952466-75bf-4ee7-96aa-9b10ef948cdd"},{"name":"Update an Organization","id":"d17a820e-b201-46fc-9671-8bcfc3525cc0","request":{"method":"PATCH","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"raw","raw":"{\n    \"organization\": {\n        \"name\": \"FIWARE Security\",\n        \"description\": \"The FIWARE Foundation is the legal independent body promoting, augmenting open-source FIWARE technologies\",\n        \"website\": \"http://fiware.org\"\n    }\n}"},"url":"http://localhost:3005/v1/organizations/security-team-0000-0000-000000000000","description":"<p>To amend the details of an existing organization, a  PATCH request is send to the <code>/v1/organizations/security-team-0000-0000-000000000000</code> endpoint.</p>\n<p>The response contains a list of the fields which have been amended.</p>\n","urlObject":{"protocol":"http","path":["v1","organizations","security-team-0000-0000-000000000000"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"d17a820e-b201-46fc-9671-8bcfc3525cc0"},{"name":"Delete an Organization","id":"28085766-e59b-4fca-82ee-db41c0064b8f","request":{"method":"DELETE","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/organizations/security-team-0000-0000-000000000000","urlObject":{"protocol":"http","path":["v1","organizations","security-team-0000-0000-000000000000"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"28085766-e59b-4fca-82ee-db41c0064b8f"}],"id":"1b7ce43a-8401-4817-9872-ec7beab18fdd","description":"<h4 id=\"gui\">GUI</h4>\n<p>Once signed-in, users are able to create and update organizations for themselves.</p>\n<p><img src=\"https://fiware.github.io/tutorials.Identity-Management/img/create-org.png\" alt /></p>\n<h4 id=\"rest-api\">REST API</h4>\n<p>Alterntively, the standard CRUD actions are assigned to the appropriate HTTP verbs (POST, GET, PATCH and DELETE) under the <code>/v1/organizations</code> endpoint.</p>\n","event":[{"listen":"prerequest","script":{"id":"4eb46ba3-0ae3-4b98-bef0-3b0a19da56aa","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"6173bfcf-4814-4c1e-9b4b-5d77d1de5a6a","type":"text/javascript","exec":[""]}}],"_postman_id":"1b7ce43a-8401-4817-9872-ec7beab18fdd"},{"name":"Users within an Organization","item":[{"name":"Add a User as a Member of an Organization","id":"265864a1-55f5-4643-8c47-cbe3e7831e10","request":{"method":"PUT","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/organizations/security-team-0000-0000-000000000000/users/aaaaaaaa-good-0000-0000-000000000000/organization_roles/member","description":"<p>To add a user as a member of an organization, an owner must make a PUT request as shown, including the <code>&lt;organization-id&gt;</code> and <code>&lt;user-id&gt;</code> in the URL path and identifying themselves using an <code>X-Auth-Token</code> in the header.</p>\n<p>The response lists the user's current role within the organization (i.e. <code>member</code>)</p>\n","urlObject":{"protocol":"http","path":["v1","organizations","security-team-0000-0000-000000000000","users","aaaaaaaa-good-0000-0000-000000000000","organization_roles","member"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"265864a1-55f5-4643-8c47-cbe3e7831e10"},{"name":"Add a User as an Owner of an Organization","id":"8f7582c1-8218-4f78-b66c-22eb383e9c88","request":{"method":"PUT","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/organizations/security-team-0000-0000-000000000000/users/aaaaaaaa-good-0000-0000-000000000000/organization_roles/owner","description":"<p>An owner can also create new owners by making a PUT request as shown, including the <code>&lt;organization-id&gt;</code> and <code>&lt;user-id&gt;</code> in the URL path and identifying themselves using an <code>X-Auth-Token</code> in the header.</p>\n<p>The response lists the user's current role within the organization (i.e. <code>owner</code>)</p>\n","urlObject":{"protocol":"http","path":["v1","organizations","security-team-0000-0000-000000000000","users","aaaaaaaa-good-0000-0000-000000000000","organization_roles","owner"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"8f7582c1-8218-4f78-b66c-22eb383e9c88"},{"name":"List Users within an organization","id":"a87a10d1-3bb7-4114-ae6f-360a6628a16b","request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/organizations/security-team-0000-0000-000000000000/users","description":"<p>Listing users within an organization is an <code>owner</code> or super-admin permission requiring the <code>X-Auth-token</code>\nListing users can be done by making a GET request to the  <code>/v1/organizations/security-team-0000-0000-000000000000/users</code> endpoint.</p>\n<p>The response contains the users list.</p>\n","urlObject":{"protocol":"http","path":["v1","organizations","security-team-0000-0000-000000000000","users"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"a87a10d1-3bb7-4114-ae6f-360a6628a16b"},{"name":"Info of user organization relationship","id":"35feb08a-b199-4e37-9746-9af429d572db","request":{"method":"GET","header":[{"key":"Accept","value":"application/json"},{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/organizations/security-team-0000-0000-000000000000/users/aaaaaaaa-good-0000-0000-000000000000/organization_roles","description":"<p>To find the role of a user within an organization, send a GET request to the <code>/v1/organizations/security-team-0000-0000-000000000000/users/aaaaaaaa-good-0000-0000-000000000000/organization_roles</code> endpoint.</p>\n<p>The response returns the role of the given <code>&lt;user-id&gt;</code></p>\n","urlObject":{"protocol":"http","path":["v1","organizations","security-team-0000-0000-000000000000","users","aaaaaaaa-good-0000-0000-000000000000","organization_roles"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"35feb08a-b199-4e37-9746-9af429d572db"},{"name":"Remove User from an Organization","id":"4927f03b-0ba4-4066-9f0e-3c2360d6b908","request":{"method":"DELETE","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3005/v1/organizations/security-team-0000-0000-000000000000/users/aaaaaaaa-good-0000-0000-000000000000/organization_roles/member","description":"<p>Owners and Super-Admins can remove a user from and organization by making a delete request.</p>\n","urlObject":{"protocol":"http","path":["v1","organizations","security-team-0000-0000-000000000000","users","aaaaaaaa-good-0000-0000-000000000000","organization_roles","member"],"host":["localhost:3005"],"query":[],"variable":[]}},"response":[],"_postman_id":"4927f03b-0ba4-4066-9f0e-3c2360d6b908"}],"id":"d22bcb81-c089-4128-ac52-bd929d978c56","description":"<p>Users within an Organization are assigned to one of types - <code>owner</code> or <code>member</code>.<br />The members of an organization inherit all of the roles and permissions assigned \nto the organization itself. In addition, owners of an organization are able to \nadd an remove other members and owners.</p>\n","event":[{"listen":"prerequest","script":{"id":"c64b6abe-444d-438b-99af-ed0fc27c528a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"a074d0bf-43f5-41f9-8617-43156bd2a774","type":"text/javascript","exec":[""]}}],"_postman_id":"d22bcb81-c089-4128-ac52-bd929d978c56"}],"id":"288b2b0a-6648-446c-9a23-20c4ede655dd","description":"<p>For any identity management system of a reasonable size, it is useful to be able to assign\nroles to groups of users, rather than setting them up individually. Since user administration\nis a time consuming business, it is also necessary to be able to delegate the responsibility\nof managing these group of users down to other accounts with a lower level of access.</p>\n<p>Consider our supermarket chain for example, there could be a group of users (Managers) who\ncan change the prices of products within the store, and another group of users (Store Detectives)\nwho can lock and unlock door after closing time. Rather than give access to each individual account,\nit would be easier to assign the rights to an organization and then add users to the groups.</p>\n<p>Furthermore, Alice, the <strong>Keyrock</strong> administrator does not need to explicitly add additional user\naccounts to each organization herself  - she could delegate that right to an owner within each organization.\nFor example Bob the Regional Manager would be made the owner of the <em>management</em> organization and could\nadd and remove addition manager accounts (such as <code>manager1</code> and <code>manager2</code>) to that organization\nwhereas Charlie the Head of Security could be handed an ownership  role in the <em>security</em> organization and add\nadditional store detectives to that organization.</p>\n<p>Note that Bob does not have the rights to alter the membership list of the <em>security</em> organization and\nCharlie does not have the rights to alter the membership list of the <em>management</em> organization.\nFurthermore neither Bob nor Charlie would be able to alter the permissions of the application themselves,\nmerely add and remove existing user accounts to the organization they control.</p>\n<p>Creating an application and setting-up the permissions is not covered here as it is the subject of the next tutorial.</p>\n","event":[{"listen":"prerequest","script":{"id":"c7f250c1-d118-4228-a631-3100cf4b0749","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"e44c9292-bf65-406b-aef4-0e01c969b714","type":"text/javascript","exec":[""]}}],"_postman_id":"288b2b0a-6648-446c-9a23-20c4ede655dd"}],"event":[{"listen":"prerequest","script":{"id":"d269e0a7-2b8d-4976-ad7f-95be8e136bec","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"fd30f550-eb89-4ac1-8dc5-cdf1ef26ef52","type":"text/javascript","exec":[""]}}],"variable":[{"key":"keyrock","value":"localhost:3005"},{"key":"X-Subject-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"},{"key":"organization-id","value":"security-team-0000-0000-000000000000"},{"key":"user-id","value":"aaaaaaaa-good-0000-0000-000000000000"},{"key":"X-Auth-token","value":"bdeb0cb0-126e-46c7-a8fc-a2a5bc290503"}]}