<?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 Linda Luz on Medium]]></title>
        <description><![CDATA[Stories by Linda Luz on Medium]]></description>
        <link>https://medium.com/@lindaluisarosenthal?source=rss-6cbee9397f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*klNFsbECOm7iyqLzOiG5Mw.jpeg</url>
            <title>Stories by Linda Luz on Medium</title>
            <link>https://medium.com/@lindaluisarosenthal?source=rss-6cbee9397f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 05:45:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lindaluisarosenthal/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[Join Ironhack]]></title>
            <link>https://medium.com/@lindaluisarosenthal/join-ironhack-76b6ef0058bf?source=rss-6cbee9397f------2</link>
            <guid isPermaLink="false">https://medium.com/p/76b6ef0058bf</guid>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Linda Luz]]></dc:creator>
            <pubDate>Fri, 24 May 2019 19:21:38 GMT</pubDate>
            <atom:updated>2021-10-30T09:02:32.461Z</atom:updated>
            <content:encoded><![CDATA[<p>Ironhack Review from March 2018</p><blockquote>Hey you, most probably you are in the situation right now I was half a year ago. You are maybe asking yourself if a bootcamp is the right thing for you. Six month ago, I was as indecisive as you right now. I tried out some online resources of really basic programming languages and noticed I really like it, however I was not sure if it is enough to put all on one card and pursue a career change.</blockquote><p>Now after the bootcamp has ended, I can tell you that it was totally worth it. If you are a person that feels uncomfortable with the comfortable and aspire a career where you feel that your effort work is really meaningful than just go for it. In the review I try to stress out why Ironhack is the right choice for you. Enjoy the read : )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*APd1tIHSPEw7UVbxuUXKcw.png" /><figcaption>Web Dev Cohort 01/2018</figcaption></figure><h4><strong>TEACHERS &amp; CURRICULUM</strong></h4><p>I couldn’t think of better teachers than the ones from Ironhack. Learning from Andre, our main teacher, was an incredibly valuable experience. He is not at all comparable to any other teacher I met in the course of my academic journey. He is inspiring, incredibly skilled and knowledgeable in all realms of the industry. The same applies to the great technical assistants. Everyone is really eager to help you and motivate you throughout the course. <br>I don’t want to sugarcoat anything, the curriculum is intense and your personal outcome also depends a lot on yourself and how much effort you put in. Be consistent and don’t stress out when you don’t get a concept right a way. You will get there with sufficient practice. As Andre taught us, they give us the shoes; we are the ones to put them on. Apart from the curriculum, you will have the chance to educate yourself in related fields. Almost everyday there are events, lectures and workshops that you can attend.</p><h4>BARCELONA OPEN SPACE</h4><p>When it comes to the right location for you to attend a bootcamp, Barcelona is definitely the place to be; the city is vibrant, young and is known for its growing tech scene. I recommend you to make use of all the great facilities that the Ironhack office provides. You’ll have the possibility to be at Ironhack 24/7. The open space with all its facilities offers you the perfect place to unfold your potential and really immerse into the world of programming. There is also a flat upstairs with a nice rooftop to study and have a barbecue with your IH friends to unwind after hours of learning and coding. The staff really trusts you guys and gives you all the freedom you need to feel as comfortable as possible. They are all really attentive to your needs and are very perceptive to any feedback. In general, the staff is always friendly and always approachable with whatever question you have.</p><h4>JOB PERSPECTIVES</h4><p>Regarding job perspectives, it is a bit too soon to be opinionated since it’s two days since the bootcamp is over. However, if it helps you to get an idea, everyone from the previous cohort landed a developer job before our cohort ended. The placement manager as well as the rest of the team are really supportive and provide help with your portfolio. Also, the hiring week at the end of the bootcamp will help you to get in touch with different tech companies in Barcelona. Update 2019: I work at a company that I got in contact to during IH hiring week.</p><h4>PREPARATION</h4><p>I’d like to make a short remark for those of you who have no prior knowledge. Although the program does not require any prior preparation besides the pre-work, I strongly recommend you to prepare yourself upfront using free online resources with main focus on JavaScript. It will keep your frustration level lower in case you are starting from scratch. However, don’t feel intimidated by this, it is not required and you can go along without any pre-knowledge.</p><h4>IRONHACK FAM</h4><p>Last but not least, I would like to address a very special thing about the program. When applying for Ironhack, I mainly focused on the learning experience itself and haven’t thought so much about the positive factors that this course brings along. But believe me, it’s the piiiiipool that make this experience so unforgettable! Although you might think that 2 1/2 months are a pretty short time to build close relationships, the bootcamp will prove you wrong!! You will have an amazing time with amazing likeminded people and will grow close together as a group. The group dynamics were unbelievable. We did a lot of different activities where everybody was included from day 1. We had legendary Friday nights, did rooftop BBQs, ping pong tournaments, samba nights, skiing trips and so much more). The Ironhack quarter really becomes your first home, the people your family and coding the nexus between both!</p><p>If you are really thinking of pursuing a career change, don’t hesitate anymore and join the Ironhack fam. Ironhack nails it, so will you! : )</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F262519127%3Fapp_id%3D122963&amp;dntp=1&amp;url=https%3A%2F%2Fvimeo.com%2F262519127&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F691814405_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a2b22979f027ad9d3da8e4560bb0c41/href">https://medium.com/media/6a2b22979f027ad9d3da8e4560bb0c41/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76b6ef0058bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[User Authentication with JWT in Express.js & Node.js]]></title>
            <link>https://medium.com/@lindaluisarosenthal/user-authentication-with-jwt-in-express-js-node-js-27ef68272580?source=rss-6cbee9397f------2</link>
            <guid isPermaLink="false">https://medium.com/p/27ef68272580</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[token]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[ohmyjwt]]></category>
            <dc:creator><![CDATA[Linda Luz]]></dc:creator>
            <pubDate>Fri, 03 Aug 2018 08:20:28 GMT</pubDate>
            <atom:updated>2018-08-03T08:20:28.101Z</atom:updated>
            <content:encoded><![CDATA[<h4>From a non-technical introduction to JWT (JSON web token) to comprehensive code for implementation in your back-end</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2tSD_jA1wtFFhAe3-K4fQ.jpeg" /><figcaption>Asterix &amp; Obelix, <a href="https://www.youtube.com/watch?v=GI5kwSap9Ug">Find Permit A38 in the Place That Sends You Mad</a></figcaption></figure><p>Contrary to my initial thoughts on JSON web tokens (JWT — pronounced <em>“jot” </em>), they are <em>not</em> aiming to encrypt data, but to rather serve as an agent to communicate user information between a client and a server. JWT fulfill an authentication purpose and help us to know if the registered user is who he or she claims to be. Once a user successfully logs in with his or her credentials, a unique token for that user will be generated. Tokens may vary in validity. When a token expires, let’s say within two days, the user needs to log in again for a new token to be returned. Although a user holds one and the same token for as long as it is valid, the user’s identity will be verified with every server request the user makes.</p><p><strong>Token pieces &lt;/3</strong>. Let’s take a look at the structure of a token. The picture below depicts the nature of a JSON web token. It always consists of three parts separated by a period: the header (red), the payload (purple) and the signature (blue).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*QnPyVNIEZHK_x9CLSbVmsw.png" /><figcaption>header. payload.signature</figcaption></figure><p>I briefly touch upon each entity of the token, however if you are interested in diving deeper into the nature of JSON web tokens, you might want to check out the <a href="https://jwt.io/">official JWT docs</a>.</p><p>I. The <strong>Header</strong> entails the type of the token (JWT) and the respective hashing algorithm. There are eleven different algorithms to chose from. In the coding example, I am using the symmetric default algorithm: SHA256 (Hash Secure Algorithm 256). <a href="https://hackernoon.com/symmetric-and-asymmetric-encryption-5122f9ec65b1">Symmetric algorithms</a> require one single secret key, which is shared between two parties.</p><pre>{<br> “alg”: “HS256”,<br> “typ”: “JWT”<br> }</pre><p>II. The <strong>Payload</strong> is the part between the periods and encodes the users personal credentials such as username, email and password — in theory, the payload can hold whatever kind of information, but usually it consists of user data. In the decoded example, you can see user details such as username, email, password, as well as additional claims stating at what time the token was signed (iat,issuedAt)and an expiration timestamp (exp).</p><pre>{<br>  &quot;user&quot;: {<br>    &quot;role&quot;: &quot;USER_ROLE&quot;,<br>    &quot;_id&quot;: &quot;5b62dcf3d118ef1cc42cf040&quot;,<br>    &quot;username&quot;: &quot;Linda Luz&quot;,<br>    &quot;email&quot;: &quot;<a href="/service/mailto:linda@luz.com">linda@luz.com</a>&quot;,<br>    &quot;password&quot;: &quot;$2a$10$j2jsH9ELLG7MUp/f6AoPdODlH4et72mvahPs12cMewk1WBgWRsUXa&quot;,<br>    &quot;__v&quot;: 0<br>  },<br>  &quot;iat&quot;: 1533205806,<br>  &quot;exp&quot;: 1536805806<br>}</pre><p>III. The last part of the token is the <strong>Signature </strong>containing the <a href="https://brockallen.com/2014/10/17/base64url-encoding/">base64url</a> encoded header and payload as well as a secret set key string, whose three components are ultimately hashed with the selected algorithm (by default, SHA256).</p><pre>HMACSHA256(<br> base64UrlEncode(header) + “.” +<br> base64UrlEncode(payload),<br> <strong><em>your-256-bit-secret</em></strong><br> )</pre><p><strong>(Secret) Key Note. </strong>Again, JSON web tokens do not encrypt users’ information, they only encode and sign the data. That’s why there is no guarantee of safe-keeping sensitive data. A third party being in possession of the token will be able to decode the header and the payload containing the user data (see <a href="https://jwt.io/#debugger">JWT debugger</a>). Hence, the secret is of utmost important and should be chosen with thorough consideration. As long as the secret is sufficiently secure, it is possible to decode the token but not possible to pass verification. The server needs to verify the token with every request the user makes. If the secret key is wrong or lacking, the user will not be authenticated. Ultimately, it goes without saying that in (real) applications the secret or sensitive data such as passwords must not be published and should be encrypted.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fn3lELizD28FHO%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fn3lELizD28FHO%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fn3lELizD28FHO%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="250" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6b75137e0ec3196e1738c0ce7f9d011/href">https://medium.com/media/d6b75137e0ec3196e1738c0ce7f9d011/href</a></iframe><p><strong>Previously on THE SERVER.</strong> So far, I have carried out regular CRUD item operations for a shopping cart application. In this context, only users whose token is verified should be allowed to create a new item for sale. In order to keep the article to the point, the code snippets provided in this article are confined to the implementation of JWT only, however since it is my main goal to provide comprehensive instructions, please see <a href="https://github.com/lindaluisa/be-hellobcn-ecommerce">this GitHub repo</a> as further reference.</p><p><strong>NPM install.</strong> Finally time to hit some code. To make JSON web tokens work in the project, we need to install the <a href="https://github.com/auth0/node-jsonwebtoken">jwt library</a> as a dependency of the app.</p><pre>npm install jsonwebtoken — save</pre><p><strong>Import.</strong> To make the library accessible, we import the module to the file where we operate our login.</p><pre>// file where jwt is implemented <br>const jwt = require(&#39;jsonwebtoken&#39;); </pre><p><strong>What’s next? </strong>There are two logical steps using token based authentication with JWT.</p><ol><li>Creating a token at login</li><li>Verifying user’s token with every new request to server</li></ol><h4><strong>1.) Creating a Token</strong></h4><p>After the login request has successfully passed data validation, a token can be assigned to that user. The function to sign a token looks as follows:</p><pre>jwt.sign( payload, secretOrPrivateKey, [options, callback] )</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95147ff51e0e106e7fe8224d3a848ea6/href">https://medium.com/media/95147ff51e0e106e7fe8224d3a848ea6/href</a></iframe><p><strong>Secret Key. </strong>Although the secret can be inserted as a parameter (as shown above), I created a new <em>config </em>folder with a configuration file assigning the seed to a constant variable and export the object.</p><pre>const SECRET_KEY = ‘asterix-needs-permit-a-38’;</pre><pre>module.exports = { SECRET_KEY };</pre><p><strong>Import Module.</strong> Subsequently, we need to access the object in the file where we operate the signing of the token (e.g., login.js).</p><pre>const SECRET_KEY = require(&#39;../config/config&#39;).SECRET_KEY;</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/db3f23bf6712019a9fd630a9d75b07ea/href">https://medium.com/media/db3f23bf6712019a9fd630a9d75b07ea/href</a></iframe><p>After having passed the validation, the jwt.sign() method takes the data of the user with the requested email credentials — the payload — and the secret key as parameters. This is everything needed for the server to create the token. After successful error handling, the server responds with a 200 Status (‘Ok!’) and returns a token. For demo purposes, I am adding the user who was signed with the token. I use <a href="https://www.getpostman.com/">Postman</a> for testing server requests on behalf of the user. See below for the response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uCme0GliS2PVcGF11VFFfQ.png" /><figcaption>API response: Signed token</figcaption></figure><h4><strong>2.) Verifying a Token.</strong></h4><p>Once the user is successfully logged in, subsequent API calls must verify if the user is still authenticated. That’s when the verifyToken() method comes into play. The server needs to receive the token to see if the token matches the JWT signature created at the moment of authentication. If the signature matches, we can expect the JWT to be valid and that the user is the one he or she claims to be.</p><p><strong>Folder middleware. </strong>Let’s create a separate folder handling middlewares. In this new folder, we validate if the token exists and whether it is valid. Therefore, inside the folder, the <em>auth.js</em> file carries the jwt.verify() method. See the pseudo code below:</p><pre>jwt.verify(token, secretOrPublicKey, [options, callback])</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8056e0113ae6d52875e01b89ff0b35e6/href">https://medium.com/media/8056e0113ae6d52875e01b89ff0b35e6/href</a></iframe><p><strong>#TGIV — Thank JWT, it’s verified!</strong> First, the token is obtained from the url via a query string. The jwt.verify()<strong> </strong>method then takes the token, the secret key and a callback with error handling and the decoded payload. If an error occurs, the server responds with an 401 error message, stating that the user is unauthorized. In case the signature is approved, implying that the user has been identified, the callback with the decoded payload is called. We can obtain the decoded user and attach it to the request object:</p><pre>req.user = decoded.user</pre><p>Hence, the user’s payload is coinciding with the data encoded in the token. Here, the next() function is needed to ensure that subsequent CRUD functions will still be executed.</p><p><strong>CRUD Items — Allow User to Create Item</strong>. Let’s put the token into practice. For now, we have created and validated the token and know it has not been altered by a malicious source. Making additional API requests, for instance to allow the user to create a new item, we want the server to authenticate the user before execution.</p><p>We import the middleware containing the verifyToken() method into the file where we operate our common CRUD item operations.</p><pre>// item.js<br>const middlewareAuth = require(‘../middlewares/auth’);</pre><p>The only thing we have to do now is to pass the middleware as a second parameter via object notation (middlewareAuth.verifyToken). Only if the token is being verified, the user is granted permission to create a new item.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d603b8c7f6d482ce7ef4665b1e82c749/href">https://medium.com/media/d603b8c7f6d482ce7ef4665b1e82c749/href</a></iframe><p>There is no need to query the database in order to retrieve the user since the user data can be retrieved from the decoded user. Testing the server request with Postman, you see the new item created, as well as the verified user (for demo purposes only). Modifying the token and thereby making it invalid, the server will throw an error not allowing the user to create a new one.</p><pre>localhost:3001/item<strong>?token=</strong>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7InJvbGUiOiJVU0VSX1JPTEUiLCJfaWQiOiI1YjYyZGNmM2QxMThlZjFjYzQyY2YwNDAiLCJ1c2VybmFtZSI6IkxpbmRhIEx1eiIsImVtYWlsIjoibGluZGFAbHV6LmNvbSIsInBhc3N3b3JkIjoiJDJhJDEwJGoyanNIOUVMTEc3TVVwL2Y2QW9QZE9EbEg0ZXQ3Mm12YWhQczEyY01ld2sxV0JnV1JzVVhhIiwiX192IjowfSwiaWF0IjoxNTMzMjA2ODk4LCJleHAiOjE1MzY4MDY4OTh9.Badfc8Lm0u4OJ0NHu5fiIJrx-Iv29TdVsxdBz_OAsxA</pre><p>As you can see in the following Postman output, the token has been verified and the user could create a new item.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U_Jdmlxce3s1s1lwNFa0iQ.png" /><figcaption>API response — the userToken is displayed only to underline the need for verification of the user’s token to create a new item</figcaption></figure><p><strong>Remark.</strong> Instead of embedding the token in a URL parameter as I did, there are other ways of transmitting the token, such as sending the token with the request in the header keeping the URL as clean as possible.</p><p>I hope you could derive some value out of this article. My goal was to provide an understandable and practical introduction to JSON web tokens, paving the way for further exploration on the topic. Also, since it is my first article writing about code execution, I am looking forward to some constructive feedback. A personal note in the end, turning code from my immaterial thoughts into written lines helped me to prove my understanding and resonate better with each line of code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27ef68272580" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>