<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lucas Lopez on Medium]]></title>
        <description><![CDATA[Stories by Lucas Lopez on Medium]]></description>
        <link>https://medium.com/@lopezlucas?source=rss-4bd88339bf85------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Fu5Zg_C-liCQ_MfefPQ25A.jpeg</url>
            <title>Stories by Lucas Lopez on Medium</title>
            <link>https://medium.com/@lopezlucas?source=rss-4bd88339bf85------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 13:50:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lopezlucas/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From AWS Cognito to DynamoDB Using Triggers]]></title>
            <link>https://medium.com/@lopezlucas/from-aws-cognito-to-dynamodb-using-triggers-bdf54f1904a9?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdf54f1904a9</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Mon, 30 Jul 2018 00:53:49 GMT</pubDate>
            <atom:updated>2018-07-30T00:53:49.905Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<p>In previous articles, we looked at how to use <strong>AWS Cognito</strong>, an Identity as a Service provider. One of the features of AWS Cognito that I find most interesting is the use of Triggers to extend the default flows. These triggers are serverless functions using another Amazon service, <strong>AWS Lambda.</strong></p><h4>Triggers on AWS Cognito</h4><p>Event triggers allow us to customize actions to send a personalized message, before or after authentication or after confirmation. The complete information on the triggers and their data model is available in the <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html"><strong>documentation</strong></a>. In our example, we are going to use the <strong>Post Confirmation Trigger</strong>.</p><h4>Table in DynamoDB — Part I</h4><p>In this example, we will see how an entry in DynamoDB can be generated after the user confirms the account. The table will save the information of the registered user. The creation of the table and the features of DynamoDB and NoSQL is not part of this article but it is super simple. Like the rest of the AWS services, it can be done directly from the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r2PLT4g-2XsiXAh-EwauPg.png" /></figure><h4>Post Confirmation Trigger — Part I</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9l29AuP4cAtiidjNyWWWQ.png" /></figure><p>The first thing is to create a function in AWS Lambda. It can be created using different programming languages. In this example, we will use Node.js since it allows us to use the online editor.</p><p>After creating the function, it appears in the drop-down options, you just need to select it and that’s it. When Cognito invokes the function, it does so with a data schema of the given events. This is important in order to define the test case.</p><h3>Security Policy</h3><p>Now we must implement the logic of the function, but, first, we must configure the security policy that will allow the lambda function to access the table in DynamoDB. Otherwise, <strong>the function will generate an error</strong> when we try to save the record in the table. Security policies are created and managed from the <strong>Amazon Web Services IAM</strong> service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3s_fcAGbvJ5GMsyY5iM30w.png" /></figure><p>Below is the JSON representation of the security policy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b190299ccdc1961d77c92910d0024d2/href">https://medium.com/media/8b190299ccdc1961d77c92910d0024d2/href</a></iframe><blockquote>The complete article is available in <strong>DZone Security</strong></blockquote><p><a href="https://dzone.com/articles/from-aws-cognito-to-dynamobd-using-triggers">From AWS Cognito to DynamoDB Using Triggers - DZone Security</a></p><blockquote>Artículo en <strong>español</strong></blockquote><p><a href="https://medium.com/@lopezlucas/de-aws-cognito-a-dynamobd-usando-disparadores-o-triggers-87c065367c73">De AWS Cognito a DynamoBD usando Disparadores o Triggers</a></p><p>Thanks for reading!</p><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdf54f1904a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrado Inventario a Ecommerce Marketplace - Durable Azure Functions]]></title>
            <link>https://medium.com/@lopezlucas/integrado-inventario-a-ecommerce-marketplace-durable-azure-functions-31cef4af43c6?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/31cef4af43c6</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[spanish]]></category>
            <category><![CDATA[tecnologia]]></category>
            <category><![CDATA[español]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Sun, 29 Jul 2018 00:27:04 GMT</pubDate>
            <atom:updated>2018-07-29T00:27:04.908Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Integrado Inventario a Ecommerce Marketplace — Durable Azure Functions</h3><p>El ejemplo del artículo anterior muestra la implementación de la integración entre <strong>SAP S/4HANA Cloud</strong> y <strong>MercadoLibre</strong> usando una función muy simple en Azure. Al tener que agregar un nuevo destino, como ser <strong>Wish</strong>, tenemos la oportunidad de mejorar el patrón de diseño y usar <strong><em>Azure Durable Functions</em></strong>.</p><blockquote>La colección de <a href="https://www.getpostman.com/">Postman </a>con todos los ejemplos y el programa de prueba están disponible en<strong> </strong><a href="https://github.com/lopezlucas/InventoryToMarketplace"><strong>GitHub</strong></a><strong>.</strong></blockquote><p><a href="https://medium.com/@lopezlucas/integrado-inventario-a-ecommerce-marketplace-batch-en-azure-8884e0bd7442">Integrado Inventario a Ecommerce Marketplace - Batch en Azure</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dpANSNozwZRTjY1S." /><figcaption>by <a href="https://unsplash.com/@bwobble11?utm_source=medium&amp;utm_medium=referral">Brennan Burling</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Azure Durable Functions</h4><p><em>Durable Functions</em> es una extensión a <strong>Azure Functions</strong> y <strong>Azure WebJobs</strong> que permite implementar lógica <em>stateful </em>en una ambiente <em>serverless </em>y <em>stateless</em>. El objetivo de la extensión es mejorar la coordinación y como orquestar distintas funciones, permitiendo implementar distintos patrones.</p><h4>Patrones — Function Chaining &amp; Fan-Out/Fan-In</h4><p>Considerado que la lógica de actualizar los inventarios en los <em>Marketplaces </em>primero depende de obtener el inventario desde S4HC y luego modificar los valores en cada uno de los <em>Marketplaces</em>, podemos aplicar los siguientes dos patrones para nuestra integración.</p><p>El patrón <strong>Function Chaining</strong> representa la ejecución en secuencia de distintas funciones, donde la salida de una función se utiliza en la siguiente.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*XHFVeQaFVU5JheTw.png" /></figure><p>El patrón <strong>Fan-Out/Fan-In</strong> representa la ejecución en paralelo de las funciones y esperar a que todas terminen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/0*yJ3_WH-cue3E_C8m.png" /></figure><p>La documentación de Azure sobre<strong><em> </em></strong><a href="https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-overview"><strong><em>Durable Functions</em></strong></a><strong><em> </em></strong>incluye estos dos diagramas así como más detalles sobre estos y otros patrones.</p><h4>Creando la función</h4><p>En los ejemplos anteriores vimos como crear una Azure Function usando Visual Studio. En este artículo vamos a volver a hacerlo pero con algunas diferencias fundamentales.</p><p>Primero, en el momento de definir el tipo de función que vamos a crear, tenemos que elegir <strong>Azure Functions v2 </strong>— en este momento está en <em>preview</em> — . Luego, tenemos que elegir <em>Empty </em>como <em>template </em>ya <em>Durable Functions</em> no está disponible en las opciones que se presentan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*KZIII3EGAhRIvqhsqFMPCA.png" /></figure><p>Luego de que se crea la función, tenemos que ir a la administración de <em>NuGet Packages</em> e instalar <a href="https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DurableTask"><strong>Microsoft.Azure.WebJobs.Extensions.DurableTask</strong></a>. Ahora podemos agregar una nueva función a nuestro proyecto y al momento de elegir el tipo de función, tenemos que elegir la opción <em>Durable Functions Orchestration</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*DdC5eQfTaQj__g8Oo5PQzw.png" /></figure><p>La función se crea usando un <em>template </em>definido como ejemplo, usando el patrón <em>Function Chaining.</em></p><p>En el caso de <strong>Durable Functions</strong> vamos a tener tres tipos de funciones. La función que orquesta la lógica, la función <em>trigger </em>— por ejemplo usando un <em>HttpTrigger </em>— y las funciones que implementan cada paso o actividad— en este caso, una para obtener el inventario desde S4HC, una para actualizar MercadoLibre y otra para actualizar Wish.</p><h4>Función Orchestrator</h4><p>La función principal tiene la lógica que orquesta las llamadas a cada uno de pasos. En este caso, el patrón es una mezcla de los dos que vimos antes. Primero, hay que obtener el inventario desde S4HC y <strong>esperar la respuesta</strong> para poder continuar.</p><p>Pero en el caso de las actualizaciones, podemos <strong>iniciar los dos procesos en paralelo</strong> ya que no hay dependencias entre ellos. Lo único que indicamos es, que cuando todas las funciones termine, se compruebe que todas funciones terminaron sin problemas.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/733b597f7a517a62aa2251377ae78f05/href">https://medium.com/media/733b597f7a517a62aa2251377ae78f05/href</a></iframe><h4>Función GetInventory</h4><p>La función para obtener es similar a la que vimos en otros ejemplos.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5ea2e2181a96db2945de2f21b1445ecb/href">https://medium.com/media/5ea2e2181a96db2945de2f21b1445ecb/href</a></iframe><h4>Funciones Update</h4><p>Las funciones de actualización también son iguales a los de los ejemplos anteriores con una pequeña diferencia. La definición las funciones que implementa la lógica — o actividades — no permite múltiples parámetros. Así que tenemos la opción utilizar un <em>array </em>de objectos o <a href="https://docs.microsoft.com/dotnet/csharp/tuples"><strong>ValueTuples</strong></a>, como vamos a usar en este caso.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/365a6417de10eb66ef04d079c7a2d47d/href">https://medium.com/media/365a6417de10eb66ef04d079c7a2d47d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26ad6174ee28fa72bf090999630ddb17/href">https://medium.com/media/26ad6174ee28fa72bf090999630ddb17/href</a></iframe><h4>Función Trigger</h4><p>La función que define el <em>template </em>sirve para nuestro ejemplo ya que permite comenzar la ejecución de la función mediante una invocación HTTP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*inFPTdWi9CrVi-2CRurxrg.png" /></figure><p>Luego de ejecutar nuestra función desde Visual Studio, la misma espera a una invocación en la URL que expone a la función <em>Trigger</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47ufat7cvgZkwIt75kpaAA.png" /></figure><p>Esta función solo se encarga de iniciar la ejecución y retorna la respuesta. Lo interesante son las URLs que incluye la misma. Por ejemplo, la URL statusQueryGeuthorize nos permite consultar el estado de la ejecución.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5TtitdihmOKb-nwOWMkEYw.png" /></figure><h4>Comentarios finales</h4><p><strong>Azure Durable Functions</strong> nos permiten implementar patrones con mayor escalabilidad y eficiencia en tiempo de ejecución, ya que desacopla el código de nuestras funciones. Además, podemos agregar nuevos <em>Marketplaces </em>para actualizar sin tener modificar la lógica existente para los otros destinos. Solamente es necesario agregar la invocación de la nueva función en la función principal que orquesta la ejecución.</p><h4>Otros Artículos</h4><ul><li><a href="https://medium.com/@lopezlucas/desde-un-sistema-de-inventario-a-ecommerce-marketplace-apis-cloud-erp-d1877d97f3f9">Desde un Sistema de Inventario a Ecommerce Marketplace — APIs &amp; Cloud &amp; ERP</a></li><li><a href="https://medium.com/@lopezlucas/como-obtener-el-nivel-de-inventario-desde-sap-s-4hana-cloud-usando-apis-40ab76951493">Como obtener el nivel de inventario desde SAP S/4HANA Cloud usando APIs</a></li><li><a href="https://medium.com/@lopezlucas/actualizando-inventario-en-mercadolibre-api-be08c72cc9df">Actualizando Inventario en MercadoLibre - API</a></li><li><a href="https://medium.com/@lopezlucas/integrado-inventario-a-ecommerce-marketplace-batch-en-azure-8884e0bd7442">Integrado Inventario a Ecommerce Marketplace - Batch en Azure</a></li></ul><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado.</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31cef4af43c6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Actualizando Inventario en Wish - API]]></title>
            <link>https://medium.com/@lopezlucas/actualizando-inventario-en-wish-api-34cd07f74e5f?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/34cd07f74e5f</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[español]]></category>
            <category><![CDATA[tecnologia]]></category>
            <category><![CDATA[spanish]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Wed, 25 Jul 2018 00:09:48 GMT</pubDate>
            <atom:updated>2018-07-25T00:09:48.420Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Actualizando Inventario en Wish — API</h3><p>Este artículo es parte de una serie que tiene como idea el mostrar cómo se puede actualizar la información de un Ecommerce Marketplace desde un sistema de inventarios. En este caso vamos a ver cómo podemos actualizar la información de inventario en <strong>Wish</strong>.</p><p><a href="https://medium.com/@lopezlucas/desde-un-sistema-de-inventario-a-ecommerce-marketplace-apis-cloud-erp-d1877d97f3f9">Desde un Sistema de Inventario a Ecommerce Marketplace — APIs &amp; Cloud &amp; ERP</a></p><blockquote>La colección de <a href="https://www.getpostman.com/">Postman </a>con todos los ejemplos está disponible en<strong> </strong><a href="https://github.com/lopezlucas/InventoryToMarketplace"><strong>GitHub</strong></a><strong>.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EFQjm0a3Oze-Ux3J." /><figcaption>by <a href="https://unsplash.com/@rawpixel?utm_source=medium&amp;utm_medium=referral">rawpixel.com</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Wish Merchant</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4bQ8J_8iTRDg1ZZ7vPz0LA.png" /></figure><p>La verdad es que este artículo primero iba a ser sobre Amazon Marketplace — pero tuve algunas dudas de como obtener los accesos — , luego lo cambie a eBay, y lo empece — pero casi al final de las pruebas me encontré con un problema que no pude solucionar todavía. Así que ambos ambas pruebas terminaron en el <em>parking lot </em>y empece a jugar con Wish.</p><p><strong>Wish</strong> es una plataforma de eCommerce bastante nueva comparada con los otros grandes jugadores, como ser Amazon o Alibaba. Iniciaron sus operaciones de ventas en 2013 y en dos años, ya se hablaba de que se podía convertir en el próximo Walmart. Su estrategia de posicionamiento es muy interesante ya que se basa casi exclusivamente en Ads en <strong>Facebook</strong> e <strong>Instagram</strong>. En este momento, Wish esta segunda en el <em>top chart</em> de apps para <em>shopping</em> en <strong>App Store</strong>, detrás solamente de Amazon, lo que no es poco decir.</p><p>Wish Merchant permite crear cuentas para vender productos en la plataforma y como parte de las herramientas disponibles, se encuentra el <a href="https://sandbox.merchant.wish.com/"><strong>Sandbox</strong></a>, donde podemos probar los desarrollos que utilizan las APIs de la plataforma.</p><p>Luego de completar un simple formulario, tenemos acceso a utilizar el Sandbox.</p><h4>Registrar la Aplicación</h4><p>Antes de utilizar las APIs, tenemos que registrar la aplicación y ejecutar el flujo de autenticación, basado en <strong>OAuth 2.0</strong> como era de esperarse. El registro de la aplicación se realiza desde el menú <em>Account</em> &gt; <em>Settings &gt; API Setting</em>. Tenemos que completar el nombre de nuestra app — <em>App Name </em>— y la URL donde va a re-direccionar el flujo — <em>Redirect URI </em>— luego de la autenticación. Luego de crear la app, vamos a tener acceso al <em>Client Id</em> y <em>Client Secret</em> que identifica a nuestra aplicación.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xo7GJngpUNVvyhu_kcMb6Q.png" /></figure><p>Cuando accedemos a la siguiente URL, wish nos va a pedir nuestra confirmación para permitir acceso a la aplicación. Luego de la confirmación, el flujo pasa a nuestra aplicación, que recibe el <em>code</em> necesario para obtener el access_token — me sorprendió que el tiempo de espiración es de 30 días — y el refresh_token.</p><pre><strong>https://sandbox.merchant.wish.com/oauth/authorize?client_id={{clientID}}</strong></pre><h4>Producto</h4><p>Con los <em>tokens</em> en nuestra app podemos realizar la llamadas a las APIs. Los productos pueden crearse desde la interfaz de usuario para <em>Merchants</em> desde el menú <em>Products</em> o directamente utilizando la API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*33ymiErRmtgLkSaYhBJ0YA.png" /></figure><p>Por defecto, cuando creamos una nueva cuenta en el <em>sandbox</em>, Wish crea un producto por defecto. Podemos utilizar ese o crear el nuestro propio para realizar las pruebas.</p><h4>Actualizar el inventario</h4><p>Las <a href="https://merchant.wish.com/documentation/api/v2#api"><strong>APIs</strong></a> disponibles en Wish son bastantes y cubren todas las funciones principales de la plataforma, desde la <strong>gestión de productos y variantes</strong> así como <strong>ordenes</strong>, <strong>notificaciones</strong> y <strong>campañas de promoción</strong>. En este ejemplo, nos vamos a centrar en la API el update-inventory que nos permite actualizar el inventario de cualquier variante de producto que tengamos definido en Wish.</p><pre><strong>https://sandbox.merchant.wish.com/api/v2/variant/update-inventory</strong></pre><p>La invocación es muy simple, ya que espera tres parámetros: el access_token obligatorio para cada invocación, el camposku que representa nuestro producto y el campo inventory que representa el nuevo valor de inventario.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CXaIet087E-W9ZW8-vzWQg.png" /></figure><p>Si la invocación es exitosa, entonces la API responde HTTP 200 OK y code igual a cero. Si tuviésemos que comprobar el valor de inventario del un producto luego de la actualización, es necesario llamar a la API product y/o variant.</p><p>Dos comentarios finales, el inventario en Wish está asociado siempre a las <strong>variantes del producto</strong> y el valor máximo del inventario de un producto es de <strong>500000 unidades.</strong></p><p>El uso de la APIs de Wish y la actualización del inventario de productos es muy sencillo.</p><h4>Comentarios finales</h4><p>En otro artículo vimos como crear una función en Azure para actualizar el inventario de MercadoLibre desde SAP S/4HANA Cloud. Ahora tenemos otro destino que actualizar, en el caso de querer vender nuestros productos en ambos marketplaces. Que podemos hacer?</p><p>Una opción es copiar la función y reemplazar la lógica de MercadoLibre por la de Wish, aunque estaríamos <strong>duplicando el código y el tiempo de ejecución</strong> para obtener el inventario desde S4HC. No parece el mejor camino.</p><p>Es mejor si creamos una función que orqueste las llamadas a la función para obtener el inventario y luego llamar a las dos funciones de actualización en los marketplace. Esta es la idea que vamos a implementar en el próximo artículo.</p><h4>Otros Artículos</h4><ul><li><a href="https://medium.com/@lopezlucas/desde-un-sistema-de-inventario-a-ecommerce-marketplace-apis-cloud-erp-d1877d97f3f9">Desde un Sistema de Inventario a Ecommerce Marketplace — APIs &amp; Cloud &amp; ERP</a></li><li><a href="https://medium.com/@lopezlucas/como-obtener-el-nivel-de-inventario-desde-sap-s-4hana-cloud-usando-apis-40ab76951493">Como obtener el nivel de inventario desde SAP S/4HANA Cloud usando APIs</a></li><li><a href="https://medium.com/@lopezlucas/actualizando-inventario-en-mercadolibre-api-be08c72cc9df">Actualizando Inventario en MercadoLibre - API</a></li></ul><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado.</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34cd07f74e5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[De AWS Cognito a DynamoBD usando Disparadores o Triggers]]></title>
            <link>https://medium.com/@lopezlucas/de-aws-cognito-a-dynamobd-usando-disparadores-o-triggers-87c065367c73?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/87c065367c73</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[tecnologia]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[spanish]]></category>
            <category><![CDATA[español]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Sat, 21 Jul 2018 21:58:54 GMT</pubDate>
            <atom:updated>2018-07-21T21:58:54.564Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<p>En artículos anteriores vimos como usar AWS Cognito, un servicio de Identidad como Servicio — <em>Identity-As-A-Service</em>. Una de las características de AWS Cognito que me parecen más interesante es el uso de <em>Triggers </em>o Disparadores para extender los flujos por defecto. Estos disparadores son funciones <em>serverless </em>utilizando otro servicio de Amazon, <strong>AWS Lambda</strong>.</p><h4>Disparadores en AWS Cognito</h4><p>Los disparadores de eventos o <em>triggers </em>nos permiten personalizar acciones para enviar un mensaje personalizado, antes o luego de la autenticación o luego de la confirmación. La información completa de los eventos está disponible en la <a href="https://docs.aws.amazon.com/es_es/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html">documentación</a>. En nuestro ejemplo vamos a usar el disparador <strong>Posterior a la confirmación</strong> o <strong><em>Post confirmation</em>.</strong></p><h4>Tabla en DynamoDB — Parte I</h4><p>En este ejemplo vamos a ver como se puede generar una entrada en <strong>DynamoDB </strong>luego de que el usuario confirme la cuenta. La tabla va a guardar la información del usuario registrado. La creación de la tabla y las características de DynamoDB &amp; NoSQL no es parte de este artículo pero es súper simple. Como el resto de los servicios de AWS, se puede realizar directamente desde la consola.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r2PLT4g-2XsiXAh-EwauPg.png" /></figure><h4>Posterior a la confirmación — Parte I</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W9l29AuP4cAtiidjNyWWWQ.png" /></figure><p>Lo primero es crear una función en AWS Lambda. Se puede crear usando distintos lenguajes de programación. En este ejemplo vamos a usar <a href="https://nodejs.org/es/"><strong>Node.JS</strong> </a>ya que nos permite usar en editor <em>online</em>.</p><p>Luego de creada la función, la misma aparece en las opciones desplegables, solo hace falta seleccionarla y listo. Cuando Cognito invoca a la función, lo hace con un esquema de datos del eventos determinado. Esto es importante para poder definir el caso de prueba.</p><h4>Política de seguridad</h4><p>Ahora hay que implementar la lógica de la función pero antes que nada hay que configurar la política de seguridad que le va a permitir a la función lambda acceder a la tabla en DynamoDB. Si no la función va a generar un error cuando tratemos de guardar el registro en la tabla. Las políticas de seguridad se crean y administran desde el servicio IAM de <em>Amazon Web Services</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3s_fcAGbvJ5GMsyY5iM30w.png" /></figure><p>A continuación como queda el JSON de la política de seguridad</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b190299ccdc1961d77c92910d0024d2/href">https://medium.com/media/8b190299ccdc1961d77c92910d0024d2/href</a></iframe><h4>Posterior a la confirmación — Parte II</h4><p>Ya podemos escribir la función que va a tomar el evento. La función tiene que incluir las librerías necesarias para acceder a DynamoDB.</p><p>El código es simple, tenemos que asignar los valores del evento a la estructura que vamos a usar para insertar en DynamoDB y finalmente invocar la función para realizar el <em>insert</em>. Algo que me paso al ser mi primera vez usando DynamoDB, los <em>strings</em> a insertar no pueden ser vacíos. Si queremos que el campo esté en el ítem aunque sea vacío, es necesario insertarlo como null<em>.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e47e83bcaaf59f5f49a12b3610fb0d70/href">https://medium.com/media/e47e83bcaaf59f5f49a12b3610fb0d70/href</a></iframe><p>Y la función esta lista.</p><h4>Caso de Test</h4><p>Para poder probar la función, es necesario que configuremos un caso de prueba que sea igual a los datos que la función va a recibir de Cognito cuando la invoque. La <a href="https://docs.aws.amazon.com/es_es/cognito/latest/developerguide/cognito-user-pools-lambda-trigger-parameters.html">documentación</a> muestra los parámetros para cada uno de los disparadores de Cognito. En nuestro caso, el caso de prueba se ve como a continuación:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/831e2aa72c56e158e8e7375432f4578b/href">https://medium.com/media/831e2aa72c56e158e8e7375432f4578b/href</a></iframe><p>Luego de crear el caso de prueba, podemos probar la función.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WgKuuCEBOL9t8UAVtYs8kA.png" /></figure><h4>Prueba completa</h4><p>Usando la app que armamos en el artículo anterior, al momento de registrar y confirmar el usuario, Cognito va a ejecutar la función antes de retornar a la app. Si comprobamos la tabla en DynamoDB vamos a encontrar los datos que se insertaron desde la función gracias a la información que le paso el disparador.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7RyhF7Yr0lrG7duBGLQFgw.png" /></figure><h4>Tabla en DynamoDB — Parte II</h4><p>Como extra, veamos que tenemos que hacer si en vez de completar una única tabla queremos afectar dos tablas. Primero tenemos que crear la nueva tabla y modificar la política de seguridad.</p><h4>Posterior a la confirmación — Parte III</h4><p>Luego, solo es necesario modificar la función lambda pero hay una salvedad. Al tener que ejecutar en dos tablas, hay que considerar que las llamadas a funciones de DynamoDB son asincrónicas y qué hay que esperar a que terminen ambas. La forma de lograr esto en <a href="http://node.js/">Node.js</a> es utilizando <em>Promises</em>. En código sería el siguiente.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab5a9348755f8d935d49be5cf196e6e3/href">https://medium.com/media/ab5a9348755f8d935d49be5cf196e6e3/href</a></iframe><p>Para ser sincero, la primera vez escribí un función similar, no tuve en cuenta esta situación y me confundí creyendo que era otro el problema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fpFftzkg6eIUoOS48GQRDA.png" /></figure><h4>Notas finales</h4><p>Los disparadores o triggers en AWS Cognito son una caracteristica excelente que puede usarse para extender los flujos de gestion de usuarios e identidades mas alla de lo que AWS Cognito ofrece por defecto. La unica consideracion es que las funciones Lambda tienen un costo aparte a Cognito, aunque el <em>free tier</em> incluye una cantidad gratis de ejecuciones de funciones Lambda.</p><h4>Aclaración</h4><p>Es muy probable que luego de terminar este articulo cancele la cuenta AWS que use de ejemplo por si prueba algunas de las URL y les da error.</p><p>Gracias Totales por leer!!!</p><h4>Links</h4><ul><li><a href="https://portal.aws.amazon.com/billing/signup">Amazon Web Services Sign Up</a></li><li><a href="https://docs.aws.amazon.com/es_es/cognito/latest/developerguide/what-is-amazon-cognito.html">Documentación AWS Cognito Español</a></li><li><a href="https://www.visualstudio.com/downloads/">Visual Studio Downloads</a></li><li><a href="https://github.com/lopezlucas/IDaaS-Example">Código fuente en GitHub</a></li></ul><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado.</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87c065367c73" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identity as a Service (IDaaS) : ASP.NET Core API and AWS Cognito]]></title>
            <link>https://medium.com/@lopezlucas/identity-as-a-service-idaas-asp-net-core-api-and-aws-cognito-aa89fa72503?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa89fa72503</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Sun, 10 Jun 2018 15:10:38 GMT</pubDate>
            <atom:updated>2018-06-10T15:10:38.878Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<p>This is another article in a series on Identity as a Service. In this article, we are going to see how to configure an <strong>ASP.NET Core</strong> API to validate the identities of the users using <strong>AWS Cognito</strong>.</p><p>For this example, we need the app that we developed in the previous article — <a href="https://dzone.com/articles/identity-as-a-service-idaas-aws-cognito-and-aspnet?preview=true"><strong>Identity as a service (IDaaS): AWS Cognito and ASP.NET Core</strong></a>. In addition, we will continue using Visual Studio 2017 Community Edition.</p><blockquote><em>All code for this example is available on </em><a href="https://github.com/lopezlucas/IDaaS-Example"><strong><em>GitHub</em></strong></a><strong><em>.</em></strong></blockquote><h4>Protecting API Access</h4><p>The objective of these examples is to add the necessary validations in the API developed in ASP.NET Core to allow only invocations from apps that have a valid user connected.</p><p>This example uses web apps but it is very simple to do the same for single page apps using JavaScript or for a mobile app. The important thing is the propagation of the token from the client to the API, which will validate it before returning the result of the invocation.</p><blockquote><em>This is one of the best aspects of the </em><strong><em>OAuth2.0</em></strong><em> and </em><strong><em>OIDC</em></strong><em> model. Each layer of our apps do not have to trust whoever contacts them, there is only a relationship of trust with the identity provider. The key element of the model are the </em><strong><em>JWTs ( JSON Web Tokens).</em></strong></blockquote><p>This relationship of trust is achieved through the publication of configuration parameters that are public for any service that wants to use them. New services and layers can be added to our ecosystem without modifying existing services.</p><p>Something to keep in mind when we create or modify an API Controller in ASP.NET Core is that the [Authorize] attribute can be applied to a particular method or to the whole class. When applied to the entire class, then all methods will require you to meet the access criteria before responding.</p><blockquote>The complete article is available in <strong>DZone Security</strong></blockquote><p><a href="https://dzone.com/articles/identity-as-a-service-idaas-asp-net-core-api-and-a">Identity as a Service (IDaaS) :  ASP.NET Core API and AWS Cognito - DZone Security</a></p><blockquote>Artículo en español</blockquote><p><a href="https://medium.com/@lopezlucas/identidad-como-servicio-idaas-asp-net-core-api-aws-cognito-6abc4ee9bfa1">Identidad como Servicio (IDaaS) — ASP Net Core API &amp; AWS Cognito</a></p><p>Thanks for reading!</p><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa89fa72503" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identidad como Servicio (IDaaS) — ASP Net Core API & AWS Cognito]]></title>
            <link>https://medium.com/@lopezlucas/identidad-como-servicio-idaas-asp-net-core-api-aws-cognito-6abc4ee9bfa1?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/6abc4ee9bfa1</guid>
            <category><![CDATA[tecnologia]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[spanish]]></category>
            <category><![CDATA[español]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Sat, 09 Jun 2018 22:45:03 GMT</pubDate>
            <atom:updated>2018-06-09T22:45:03.082Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Identidad como Servicio (IDaaS) — ASP Net Core API &amp; AWS Cognito</h3><p>Este es el quinto artículo de una serie sobre Identidad como Servicio — <em>Identity-As-A-Service</em>. Es este artículo vamos a ver cómo configurar una API <strong>ASP Net Core</strong> para validar las identidades de los usuarios usando <strong>AWS Cognito</strong>.</p><p><a href="https://medium.com/@lopezlucas/identidad-como-servicio-idaas-aws-cognito-asp-net-core-64bb2e11517c">Identidad como servicio (IDaaS) — AWS Cognito &amp; ASP Net Core</a></p><p>Para este ejemplo necesitamos el app que desarrollamos en el articulo anterior — <strong>Identidad como servicio (IDaaS) — AWS Cognito &amp; ASP Net Core</strong>. Además vamos a seguir utilizando Visual Studio 2017 Community Edition.</p><blockquote>Todo el código de este ejemplo está disponible en<strong> </strong><a href="https://github.com/lopezlucas/IDaaS-Example"><strong>GitHub</strong></a><strong>.</strong></blockquote><h4>Protegiendo el acceso a API</h4><p>El objetivo de estos ejemplos es agregar la validaciones necesarias en la API desarrollada en ASP Net Core para permitir solamente invocaciones desde apps que tengan un usuario valido conectado.</p><p>Este ejemplo usa Web Apps pero es muy simple hacer lo mismo para <em>Single Page App</em> usando <em>JavaScript </em>o desde una app <em>Mobile</em>. Lo importante es la propagación del token desde el cliente a la API, que va a validarlo antes de devolver el resultado de la invocación.</p><blockquote>Este es un de los mejores aspectos del modelo de <strong>OAuth2.0</strong> y <strong>OIDC</strong>. Cada capa de nuestras apps no tienen que confiar en quien las contacta, solamente existe una relación de confianza con el proveedor de identidades. El elemento clave del modelo son los <strong>JWT — JSON Web Token</strong></blockquote><p>Esta relación de confianza se logra mediante la publicación de los parámetros de configuración que son públicos para todo servicio que quiera utilizarlos. Se pueden agregar nuevos servicios y capas a nuestro ecosistema sin necesidad de tocar a los servicio existentes.</p><p>Algo para tener en cuenta cuando creamos o modificamos un API <em>Controller </em>en ASP Net Core es que el atributo [Authorize] lo podemos aplicar a un método en particular o a toda la clase. Cuando se lo aplica a toda la clase, entonces todos los métodos va a requerir de cumplir los criterios de acceso antes de responder.</p><h3>Web API utilizando AWS Cognito</h3><p>Comencemos creando y configurando una ASP Net Core API para utilizar AWS Cognito como proveedor de identidades. Nuevamente la mayoría de los cambios los tenemos que hacer en startup.cs aunque en este ejemplo también vamos a crear un nuevo <em>controller </em>para retornar uno de los valores del JWT token.</p><h4>Cambios en Startup.cs</h4><p>Los primeros cambios necesarios son los using.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c9fe307d08ac98db786ce955d3d2211/href">https://medium.com/media/0c9fe307d08ac98db786ce955d3d2211/href</a></iframe><p>La mayoría de los cambios son en el método ConfigureServices. Algunos comentarios antes de ver el código.</p><p>Primero, en vez de harcodear las propiedades la validación del <em>JWT </em>en el código, usamos el appsettings.json para mayor flexibilidad.</p><p>Luego hay que usar AddAuthentication para indicar los esquemas de <em>Authentication</em> y AddJwtBearer para indicar los parámetros de validación del <em>JWT</em>, por lejos la sección más importante del código. El valor MetaDataAddress depende de nuestra cuenta de AWS Cognito, el mismo valor que usamos en nuestra Web App.</p><blockquote>Es obligatorio que nuestra Web App y API usen la misma MetaDataAddress para poder propagar las identidades. El valor MetaDataAdress es el mismo sin importar la Web App registrada en AWS Cognito</blockquote><p>Algo distintivo de AWS Cognito es que los tokens no tiene el claim Audience por lo cual hay que indicarle a las rutinas de validación de ASP Net que no lo hagan. Si no se incluye ValidateAudience = false cada validación va a dar error.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cee3271f8c9a675e0fbbb5d714a6d19/href">https://medium.com/media/7cee3271f8c9a675e0fbbb5d714a6d19/href</a></iframe><p>Y finalmente, modificar el método Configure<em> </em>para usar el modelo de <em>Authentication</em> que configuramos en el paso anterior.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e657ebb7be4a262ccc515f7aaed7e18c/href">https://medium.com/media/e657ebb7be4a262ccc515f7aaed7e18c/href</a></iframe><p>Nota: Como estaba usando el ejemplo del API usando Okta, me olvide de incluir esta linea… estuve 15 minutos revisando el resto del código antes de encontrar el error. En cada prueba, la respuesta era <em>Invalid Token</em> sin mas explicación en el mensaje de error o en el <em>debug log</em>.</p><h4>Nuevo API Controller</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*NGlw1EyVnLa-RODSKh_Aiw.png" /></figure><p>Cada nuevo proyecto API en VS 2017 crea un <em>API controller </em>por defecto ValuesController. En vez de modificarlo, vamos a crear un <em>controller </em>nuevo. Esto nos va a permitir ver que las invocaciones ValuesControllerno van a requerir el JWT pero si va a ser necesario para el nuevo <em>controller </em>.</p><p>Al nuevo<em> API Controller</em> lo vamos a llamar TokenController y vamos implementar solamente el <em>action </em>Get que simplemente retorna la fecha cuando expira el token. El atributo [Authorize]indica que para invocar a cualquier método de esta clase se necesita un usuario valido.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26b4ea9bb944f094be9f40b13feb4b47/href">https://medium.com/media/26b4ea9bb944f094be9f40b13feb4b47/href</a></iframe><p>Luego de realizar la invocación, podemos tomar la respuesta y mostrarla en la pantalla.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*yHyXKaOVOZo8BxYG3_YwrA.png" /></figure><h4>Aclaración</h4><p>Es muy probable que luego de terminar este articulo cancele la cuenta AWS que use de ejemplo por si prueba algunas de las URL y les da error.</p><p>Gracias Totales por leer!!!</p><h4>Links</h4><ul><li><a href="https://portal.aws.amazon.com/billing/signup">Amazon Web Services Sign Up</a></li><li><a href="https://docs.aws.amazon.com/es_es/cognito/latest/developerguide/what-is-amazon-cognito.html">Documentación AWS Cognito Español</a></li><li><a href="https://www.visualstudio.com/downloads/">Visual Studio Downloads</a></li><li><a href="https://github.com/lopezlucas/IDaaS-Example">Código fuente en GitHub</a></li></ul><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado.</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6abc4ee9bfa1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identity-as-a-Service (IDaaS) : AWS Cognito and ASP.NET Core - DZone Security]]></title>
            <link>https://medium.com/@lopezlucas/identity-as-a-service-idaas-aws-cognito-and-asp-net-core-dzone-security-21c5e2c81d76?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/21c5e2c81d76</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Sun, 03 Jun 2018 21:01:53 GMT</pubDate>
            <atom:updated>2018-06-09T22:43:19.527Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Identity-as-a-Service (IDaaS) : AWS Cognito and ASP.NET Core</h3><p>This is another article in a series about <strong>Identity as a Service</strong>. In this article, we are going to see how to configure <strong>ASP.NET Core</strong> to use <strong>AWS Cognito</strong> as an identity provider. The concepts are similar to working with other providers, such as Okta, although there are always some subtleties in the configuration.</p><blockquote><em>All code for this example is available on </em><a href="https://github.com/lopezlucas/IDaaS-Example"><strong><em>GitHub</em></strong></a><strong><em>.</em></strong></blockquote><h3>Web App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*-jjPwOgOD8l-q2ynIybGoQ.png" /></figure><p>First, we create a web application in ASP.NET Core in Visual Studio 2017. In this case, the app that gets created by default is enough. Configuring <strong>Authentication</strong> in ASP.NET Core 2.0 is very simple, most of the changes occur in the startup.cs file. But before we start setting up the app, we have to have our Identity-as-a-Service. Let’s start with the configuration in AWS Cognito.</p><h3>Amazon Web Services — New Account</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*HIGrsE9mlG2K3wSpzqAmFw.png" /></figure><p>In order to use AWS Cognito, it is necessary to have an Amazon Web Services account. The AWS Cognito service is included in the <strong>Free Tier</strong> and never expires. We can manage up to <strong>50,000 monthly active users</strong>. And it gives us the basics to be able to manage the users of our apps.</p><p>To create the account we have to go to the <a href="https://portal.aws.amazon.com/billing/signup#/start"><strong>AWS signup</strong></a>. After completing the initial details, we have to fill in more data, including the details of a credit card and automatic verification with a phone call. After creating the account you could follow some indications from Amazon to not use the Root user for the configurations but, in this example, we will ignore it and go directly to AWS Cognito to create the User Pool.</p><h3>AWS Cognito User Pool</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*y0Y9eWKaUzZORRjt6GL9QA.png" /></figure><p>To access AWS Cognito we can look for the option in the <strong>All Services</strong> menu in the <strong>Security, Identity &amp; Compliance</strong> section or simply search for it.</p><p>The documentation is available in English and other languages such as Spanish. It explains many more details and examples and is highly recommended for those who want to use the service seriously.</p><p>The creation starts from the AWS Cognito main page, choosing the option ‘Manage Your User Pools.’</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*v8Qyq1olyXMk9g1OvWUMmQ.png" /></figure><p>Since we have not created any User Pool yet, the only option available is ‘Create a User Pool.’ First, we have to indicate the name — <strong>Pool Name</strong>. As the default configuration is useful, we can select the Review Defaults option and create the Pool.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*C4YL-vXrRovVU9oF1AKfxQ.png" /></figure><p>Now we have to configure our app so we can access it. We do this from the <strong>General settings &gt; App</strong> clients option, choosing <strong>Add an app client</strong>. We indicate the name of the app — <strong>App client name</strong> — and that’s it.</p><p>Then we have to configure how our app will negotiate the identities with AWS Cognito. We configure this from <strong>App integration &gt; App client</strong> settings.</p><p>First of all, we have to select the identity provider — <strong>Enabled Identity Providers</strong> — in our case. we only have the Cognito User Pool option. Then we have to indicate the URL where AWS Cognito will contact our app after the user completes in sign-in — <strong>Callback URL(s)</strong>. In our case, it is the URL localhost where our app will run, plus the path signin-oidc. The last step is to configure OAuth 2.0. In our case, we will choose the <strong>Authorization code</strong> grant and <strong>email</strong>, <strong>openid, </strong>and <strong>profile</strong> values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*39XiCZGkl3kzNvjBocLcwA.png" /></figure><blockquote>The complete article is available in DZone Security</blockquote><p><a href="https://dzone.com/articles/identity-as-a-service-idaas-aws-cognito-and-aspnet">Identity-as-a-Service (IDaaS) : AWS Cognito and ASP.NET Core - DZone Security</a></p><blockquote>Artículo en español</blockquote><p><a href="https://medium.com/@lopezlucas/identidad-como-servicio-idaas-aws-cognito-asp-net-core-64bb2e11517c">Identidad como servicio (IDaaS) — AWS Cognito &amp; ASP Net Core</a></p><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado.</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated</p><p><em>Originally published at </em><a href="https://dzone.com/articles/identity-as-a-service-idaas-aws-cognito-and-aspnet"><em>dzone.com</em></a><em>.</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21c5e2c81d76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identity as a Service (IDaaS) - ASP Net Core API & Okta]]></title>
            <link>https://medium.com/@lopezlucas/identity-as-a-service-idaas-asp-net-core-api-okta-b043faac1374?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/b043faac1374</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Thu, 31 May 2018 02:20:38 GMT</pubDate>
            <atom:updated>2018-05-31T02:20:38.322Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Identity as a Service (IDaaS) — ASP Net Core API &amp; Okta</h3><p>This is the third article in a series on Identity as a Service — Identity-As-A-Service. In this article, we are going to see how to configure an <strong>ASP Net Core</strong> API to validate the identities of the users using <strong>Okta</strong>.</p><p>For this example, we need the app that we developed in the previous article — <a href="https://medium.com/@lopezlucas/identity-as-a-service-idaas-okta-asp-net-core-e52b2e7b49b1"><strong>Identity as a service (IDaaS) — Okta &amp; ASP Net Core</strong></a>. In addition, we will continue using Visual Studio 2017 Community Edition.</p><p><a href="https://medium.com/@lopezlucas/identity-as-a-service-idaas-okta-asp-net-core-e52b2e7b49b1">Identity as a Service (IDaaS) - Okta &amp; ASP Net Core</a></p><blockquote>All code for this example is available on <a href="https://github.com/lopezlucas/IDaaS-Example"><strong>GitHub</strong></a><strong>.</strong></blockquote><h4>Protecting API Access</h4><p>The objective of these examples is to add the necessary validations in the API developed in ASP Net Core to allow only invocations from apps that have a valid user connected.</p><p>This example uses Web Apps but it is very simple to do the same for Single Page App using JavaScript or from a Mobile app. The important thing is the propagation of the token from the client to the API, which will validate it before returning the result of the invocation.</p><blockquote>This is one of the best aspects of the <strong>OAuth2.0</strong> and <strong>OIDC</strong> model. Each layer of our apps do not have to trust whoever contacts them, there is only a relationship of trust with the identity provider. The key element of the model are the <strong>JWT — JSON Web Token</strong></blockquote><p>This relationship of trust is achieved through the publication of configuration parameters that are public for any service that wants to use them. New services and layers can be added to our ecosystem without modifying existing services.</p><p>Something to keep in mind when we create or modify an API Controller in ASP Net Core is that the [Authorize] attribute can be applied to a particular method or to the whole class. When applied to the entire class, then all methods will require you to meet the access criteria before responding.</p><p>Thanks for reading!!!</p><blockquote>The complete article is available in DZone Security</blockquote><p><a href="https://dzone.com/articles/identity-as-a-service-idaas-asp-net-core-api-and-o">Identity as a Service (IDaaS) :  ASP.NET Core API and Okta - DZone Security</a></p><blockquote>Artículo en español</blockquote><p><a href="https://medium.com/@lopezlucas/identidad-como-servicio-idaas-asp-net-core-api-okta-5e89c6e91dc0">Identidad como Servicio (IDaaS) — ASP Net Core API &amp; Okta</a></p><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado.</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b043faac1374" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identidad como servicio (IDaaS) — AWS Cognito & ASP Net Core]]></title>
            <link>https://medium.com/@lopezlucas/identidad-como-servicio-idaas-aws-cognito-asp-net-core-64bb2e11517c?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/64bb2e11517c</guid>
            <category><![CDATA[spanish]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[tecnologia]]></category>
            <category><![CDATA[español]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Tue, 29 May 2018 22:23:05 GMT</pubDate>
            <atom:updated>2018-05-29T22:34:47.424Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Identidad como servicio (IDaaS) — AWS Cognito &amp; ASP Net Core</h3><p>Este es el cuarto artículo de una serie sobre Identidad como Servicio — <em>Identity-As-A-Service</em>. Es este artículo vamos a ver cómo configurar <strong>ASP Net Core</strong> para usar <strong>AWS Cognito</strong> como proveedor de identidades. Los conceptos son similares a usar otro proveedor, como ser Okta, aunque siempre hay algunas sutilezas en la configuración.</p><p><a href="https://medium.com/@lopezlucas/identidad-como-servicio-idaas-aws-cognito-okta-parte-1-894b407f8121">Identidad como servicio (IDaaS) — AWS Cognito &amp; Okta</a></p><p>Para este ejemplo necesitamos dos cuentas de email, una para el administrador de AWS y otra para ver cómo es el registro de un usuario. Además vamos a usar Visual Studio 2017 Community Edition.</p><blockquote>Todo el código de este ejemplo está disponible en<strong> </strong><a href="https://github.com/lopezlucas/IDaaS-Example"><strong>GitHub</strong></a><strong>.</strong></blockquote><h4>Web App</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*-jjPwOgOD8l-q2ynIybGoQ.png" /></figure><p>Primero creamos una <em>Web Application</em> en ASP Net Core desde Visual Studio 2017. Para este caso, la app que crea por defecto es suficiente. Configurar <em>Authentication</em> en ASP Net Core 2.0 es muy simple, la mayor parte de los cambios en startup.cs. Pero antes de empezar a configurar la app, tenemos que tener nuestro servicio de Identidad como Servicio. Comencemos con la configuración en AWS Cognito.</p><h4>Amazon Web Services — Nueva Cuenta</h4><p>Para poder utilizar AWS Cognito es necesario tener una cuenta de Amazon Web Services. El servicio de AWS Cognito está incluido en el <em>Free Tier</em> y nunca expira. Podemos manejar hasta 50000 usuarios activos mensuales. Y nos da lo básico para poder gestionar los usuarios de nuestras apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*HIGrsE9mlG2K3wSpzqAmFw.png" /></figure><p>Para crear la cuenta tenemos que ir al <a href="https://portal.aws.amazon.com/billing/signup#/start"><strong>registro</strong> </a>de AWS. Luego de completar los detalles iniciales, tenemos que completar más datos, lamentablemente incluye completar los datos de una tarjeta de crédito y la verificación automática con una llamada por teléfono. Luego de crear la cuenta hay que seguir unas indicaciones de Amazon para no utilizar el usuario Root para las configuraciones pero en este ejemplo lo vamos a obviar e ir directamente a AWS Cognito a crear el <em>User Pool.</em></p><h4>AWS Cognito User Pool</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*y0Y9eWKaUzZORRjt6GL9QA.png" /></figure><p>Para acceder a AWS Cognito podemos buscar la opción en el menú <em>All Services </em>en la sección <em>Security, Identity &amp; Compliance</em> o simplemente buscarlo.</p><p>La documentación está disponible en inglés y español. Explica muchos más detalles de los que vamos a ver es este ejemplo y es muy recomendable para quienes quiera usar el servicio seriamente.</p><p>La creación empieza desde la página principal de AWS Cognito, eligiendo la opción <em>Manage your User Pools</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v8Qyq1olyXMk9g1OvWUMmQ.png" /></figure><p>Como no tenemos creado ningún <em>User Pool</em> todavía, la única opción disponible es <em>Create a user pool</em>. Lo primero que tenemos que indicar es el nombre —<em> </em><strong><em>Pool Name</em></strong><em> </em>— . Como la configuración por defecto nos sirve, podemos seleccionar la opción <em>Review Defaults </em>y crear el <em>Pool</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C4YL-vXrRovVU9oF1AKfxQ.png" /></figure><p>Ahora tenemos que configurar nuestra app para que pueda acceder. Esto lo hacemos desde la opción <em>General settings &gt; App clients, </em>eligiendo <em>Add an app client</em>. Indicamos el nombre de la app — <strong><em>App client name</em></strong> — y listo.</p><p>Luego tenemos que configurar como nuestra app va a negociar las identidades con AWS Cognito. Esto lo configuramos desde <em>App integration</em> &gt; <em>App client settings</em>.</p><p>Primero que nada tenemos que seleccionar el proveedor de identidades — <strong><em>Enabled Identity Providers</em></strong> — en nuestro caso solo tenemos la opción <em>Cognito User Pool</em>. Luego tenemos que indicar la URL donde AWS Cognito va a contactar a nuestra app después de que el usuario complete en <em>sign-in — </em><strong><em>Callback URL(s)</em></strong>-. Es nuestro caso es la URL localhost donde va a correr nuestra app, más el <em>path </em>signin-oidc. El último paso es configurar OAuth 2.0. En nuestro caso vamos a elegir los valores <strong><em>Authorization code grant</em> </strong>y<strong> <em>email</em></strong>, <strong><em>openid </em></strong>&amp; <strong><em>profile</em></strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*39XiCZGkl3kzNvjBocLcwA.png" /></figure><h4>Datos para la configuración</h4><p>En la opción <em>General settings &gt; App clients, </em>podemos ver los detalles la configuración, principalmente el <strong><em>App client id </em></strong>y <strong><em>App client secret</em> </strong>que necesitamos para configurar el acceso de nuestra app.</p><p>El último valor que necesitamos es el <strong><em>PoolId </em></strong>que está en <em>General setting </em>para poder configurar la dirección de donde la ASP Net Web App obtiene los valores de configuración. La URL depende de dos variables realmente, el <strong><em>PoolID </em></strong>y la región donde está configurado nuestra instancia de AWS Cognito. Es este caso <strong><em>US East (Ohio)</em></strong></p><pre><strong>https://cognito-idp.us-east-2.amazonaws.com/us-east-2_54E8jWmWw/.well-known/openid-configuration</strong></pre><p>Otra configuración que puede ser importante es <em>App integration &gt; Domain</em> <em>name</em>. Nos permite configurar cual va a ser el dominio de las páginas de <em>sign-in</em> y <em>sign-up</em>.</p><p>Terminada la creación de la app en AWS Cognito, podemos volver a Visual Studio.</p><h4>Cambios en Startup.cs</h4><p>Los primeros cambios necesarios son los using</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69935b7d300157c2092d2430c9cf7575/href">https://medium.com/media/69935b7d300157c2092d2430c9cf7575/href</a></iframe><p>La mayoría de los cambios son en el método ConfigureServices. Algunos comentarios antes de ver el código.</p><p>Primero, en vez de harcodear las propiedades de la conexión OIDC en el código, usamos el appsettings.jsonpara mayor flexibilidad.</p><p>Luego, al estar usando <em>Razon Pages</em>, la forma de indicar cuales son los recursos a proteger es distinta, usando el método AuthorizePage, en este caso solo la página <em>Index</em>.</p><p>La tercera sección tiene dos partes, AddAuthentication para indicar los esquemas de <em>Authentication</em> y AddOpenIdConnect para indicar los parámetros de la conexión OIDC, por lejos la sección más importante del código.</p><p>Si leyeron el <a href="https://medium.com/@lopezlucas/identidad-como-servicio-idaas-okta-asp-net-core-f761e28cee90">ejemplo usando Okta</a>, verán que AWS Cognito usa distintos valores de las opciones de OIDC, por ejemplo MetadataAddress en vez de Authority . El resto del código es casi igual.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3eeb12b16217cf9fdf1385f7651dd25/href">https://medium.com/media/c3eeb12b16217cf9fdf1385f7651dd25/href</a></iframe><p>Y finalmente, modificar el método Configure<em> </em>para usar el modelo de <em>Authentication</em> que configuramos en el paso anterior.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24b0819bd2be14c0dbd2435439dc1e86/href">https://medium.com/media/24b0819bd2be14c0dbd2435439dc1e86/href</a></iframe><p>Al ejecutar la app nos lleva automáticamente al <em>Sign In</em> de AWS Cognito ya que para acceder a Index necesita que el usuario este autenticado. A diferencia de Okta, AWS Cognito nos permite crear un nuevo usuario desde esta página.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*Y1bIRS3xB1z3WnfMXDPPwA.png" /></figure><p>Los datos que nos va a pedir el formulario de Sign-up dependen de los valores del perfil que configuramos como obligatorios. En nuestro caso, solamente una dirección de correo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*mBUn8TaxGeMhMw1NXIFRkA.png" /></figure><p>Al completar el registro, AWS nos enviara un <em>email </em>con el <em>verification code. </em>Luego de copiarlo y confirma la cuenta, AWS Cognito nos devuelve a nuestra app, ya identificados.</p><h4>Algunos comentarios finales</h4><p>La configuración del servicio en ASP Net Core 2.0 es muy simple y en poco tiempo podemos estar desarrollando nuestra app sin preocuparnos de la seguridad o gestionar los usuarios nosotros mismos. Este caso muestra la configuración básica para AWS Cognito pero la verdad es que cualquier otro servicio OIDC requiere un esfuerzo similar.</p><p>Es recomendable usar <strong>ASP Net Core Secrets</strong> para guardar los valores ClientId y ClientSecret en vez de usar <em>appsettings.json.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50382656760c7ccb0641b0c898f0fb13/href">https://medium.com/media/50382656760c7ccb0641b0c898f0fb13/href</a></iframe><p>Gracias Totales por leer!!!</p><h3>Links</h3><ul><li><a href="https://portal.aws.amazon.com/billing/signup">Amazon Web Services Sign Up</a></li><li><a href="https://docs.aws.amazon.com/es_es/cognito/latest/developerguide/what-is-amazon-cognito.html">Documentación AWS Cognito Español</a></li><li><a href="https://www.visualstudio.com/downloads/">Visual Studio Downloads</a></li><li><a href="https://github.com/lopezlucas/IDaaS-Example">Código fuente en GitHub</a></li></ul><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado.</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64bb2e11517c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Identity as a Service (IDaaS) - Okta & ASP Net Core]]></title>
            <link>https://medium.com/@lopezlucas/identity-as-a-service-idaas-okta-asp-net-core-e52b2e7b49b1?source=rss-4bd88339bf85------2</link>
            <guid isPermaLink="false">https://medium.com/p/e52b2e7b49b1</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Lucas Lopez]]></dc:creator>
            <pubDate>Sun, 27 May 2018 21:24:24 GMT</pubDate>
            <atom:updated>2018-05-27T21:24:24.812Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-nd/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Identity as a Service (IDaaS) — Okta &amp; ASP Net Core</h3><p>In the previous article, we discussed identity as service providers — Identity-as-a-Service — <strong>AWS Cognito</strong> and <strong>Okta</strong>. Now let’s see how we can use one of them, <strong>Okta</strong> with an <strong>ASP Net Core</strong> web application.</p><p><a href="https://medium.com/@lopezlucas/identity-as-a-service-idaas-aws-cognito-okta-503a981bb4e8">Identity as a service (IDaaS) - AWS Cognito &amp; Okta - Lucas Lopez - Medium</a></p><p>For this example, we only need an email account and Visual Studio. The Community version is more than enough.</p><blockquote>All code for this example is available on <a href="https://github.com/lopezlucas/IDaaS-Example"><strong>GitHub</strong></a><strong>.</strong></blockquote><h4>Web App</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*-jjPwOgOD8l-q2ynIybGoQ.png" /></figure><p>First, we create a Web Application in ASP Net Core in Visual Studio 2017. In this case, the app that creates by default is enough. Configuring Authentication in ASP Net Core 2.0 is very simple, most of the changes in startup.cs. But before we start setting up the app, we have to have our Identity service as a Service. Let’s start with the configuration in Okta.</p><h4>Okta — New Account</h4><p>In the<a href="https://developer.okta.com/signup/"> Okta Developer</a> site, you can create a new account. After completing the form, it shows us the welcome message. We also received an email from Okta to confirm our account and the temporary password to access our new account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c3FD_TiR_JRvzVRAhWuXBQ.png" /></figure><p>After confirming, changing the password and other security questions, we have access to the console, which includes the links to Okta’s quick start guides for different front-end and back-end technologies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*rhGdq77RjXvzJWA9QWJDyA.png" /></figure><p>The first thing we have to do next is to create the entry of our app, to allow it to contact Okta to identify the users. This is achieved from the Applications menu, then on that page, by pressing the Add Application button. The selection of the application type directly impacts flow the OAuth flows that will be used in the app. For example, <strong>SPA</strong> — Single Page App — only allows implicit since the JavaScript is vulnerable to other types. For this example, we are going to choose the <strong>Web</strong> type and use the Authorization Code flow, which is the default option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*123OrIol9V4iGcE_NEd35g.png" /></figure><p>The form to create the app has two values to configure: <strong>Base URIs</strong> and <strong>Login redirect URIs</strong>. Although the guide mentions another value, <strong>Logout redirect URI</strong>, we can not modify it until later when the app has been created. These three values depend on the configuration of our web app, mainly the port where it will run on localhost.<br>Something that in the past needed to be done and that Okta now does automatically at the time of creation is to assign the domain to the Trusted Origins list. But if for some reason we have to change the domains of our app, we must make the change manually not only in the app in Okta but also in the menu option API&gt; Trusted Origins.</p><blockquote>The complete article is available in DZone Security</blockquote><p><a href="https://dzone.com/articles/identity-as-a-service-idaas-okta-amp-asp-netnbspco">Identity-as-a-Service (IDaaS) : Okta and ASP.Net Core - DZone Security</a></p><blockquote>Artículo en español</blockquote><p><a href="https://medium.com/@lopezlucas/identidad-como-servicio-idaas-okta-asp-net-core-f761e28cee90">Identidad como servicio (IDaaS) — Okta &amp; ASP.Net Core</a></p><p>Todas las opiniones expresadas son mías y no representan opiniones de ninguna entidad con la que he estado, estoy o estaré afiliado.</p><p>All views expressed are my own and do not represent opinions of any entity whatsoever with which I have been, am now, or will be affiliated.</p><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FuserId%3D5ae68d5ece3c95045f413697%26mediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f&amp;src=https%3A%2F%2Flcontacts.herokuapp.com%2Fembed%2Fbutton%2Fwritercta%3FmediumUserId%3D1bb11f901c17828938c84acbc0e85a5ea147e3bc5c38edd747b12c7e82f2b843f%26userId%3D5ae68d5ece3c95045f413697&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=lcontacts" width="480" height="350" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href">https://medium.com/media/5a3efa15f29e01a6a7c7fe72d97d0db8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e52b2e7b49b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>