{"id":6870,"date":"2023-01-05T05:04:34","date_gmt":"2023-01-05T05:04:34","guid":{"rendered":"https:\/\/www.ardorsys.com\/blog\/?p=6870"},"modified":"2023-05-09T13:35:07","modified_gmt":"2023-05-09T13:35:07","slug":"jwt-authentication-in-golang","status":"publish","type":"post","link":"https:\/\/www.ardorsys.com\/blog\/jwt-authentication-in-golang\/","title":{"rendered":"JWT Authentication in Golang"},"content":{"rendered":"<h3 style=\"text-align: left;\">Explanation of JWT Authentication in Golang using Gin Web Framework<\/h3>\n<h4>Introduction<\/h4>\n<p>Do you know, How to create a JWT Authentication <a href=\"https:\/\/www.ardorsys.com\/blog\/how-much-does-it-cost-to-develop-a-netflix-clone-mobile-app\/\">Application<\/a> in Golang using Gin Web Framework? If not!! Then no worries, you clicked the right content. In this tutorial, I will give you some idea about JWT Authentication with an example code. This blog will also cover an explanation regarding some concepts that are required to create a JWT Authentication App in Golang. But before proceeding the first thing that, I will mention is the prerequisites part that you need to have the knowledge of and the second thing is What exactly JWT Authentication is in <a href=\"https:\/\/golang.company\/golang-web-development\" target=\"_blank\" rel=\"noopener nofollow\">Golang web development<\/a>.<\/p>\n<h4>Prerequisites<\/h4>\n<p>You should be aware of the below-mentioned concepts so that you can understand the tutorial and get a proper learning outcome from it.<br \/>\n\u25cf You should know how to set up a workspace for your project. If you don\u2019t know about it you can refer to this <a href=\"https:\/\/golang.company\/blog\/connect-the-golang-app-using-mongodb#:~:text=Setting%20up%20the%20Workspace\" target=\"_blank\" rel=\"nofollow noopener\">page<\/a>.<br \/>\n\u25cf You should know what are the commands and processes to import mod files and other external packages.<br \/>\n\u25cf You should know the concept of Struct.<br \/>\n\u25cf You should know about Routing and concepts like API.<br \/>\n\u25cf Downloads<\/p>\n<p style=\"padding-left: 40px;\">1) <a href=\"https:\/\/go.dev\/dl\/\" target=\"_blank\" rel=\"nofollow noopener\">Go Programming Language<\/a><br \/>\n2) IDE (VS CODE)<br \/>\n3) PostMan Application<\/p>\n<h4>JWT Authentication<\/h4>\n<p>Let&#8217;s start with a definition of JWT Authentication. JWT is an abbreviation for JSON web token, which is a token-based stateless authentication method. It is frequently used as a client-side stateless session, allowing the server to save session data without relying entirely on a database. JWT is most commonly used in server-to-server authorization and API authentication.<\/p>\n<h4>Integration of JWT<\/h4>\n<p>Hereafter creating the directory on our command prompt, I will start building the Application to explain how you can create JWT Authentication Application. I hope you know about the command \u201ccode.\u201d which will open up the IDE on your screen. Here the first file with which we will begin is main.go. In that main.go file I will import some internal packages like \u201clog\u201d and \u201cos\u201d. And some external packages are also required to be imported like github.com\/gin-gonic\/gin&#8221; (Gin), &#8220;github.com\/golangcompany\/JWT-Authentication\/routes&#8221; (routes), and &#8220;github.com\/joho\/godotenv. Then after importing the packages, I will move ahead with my main.go function which includes the entry point of the program and it&#8217;s executed when you run your application. We&#8217;re using<\/p>\n<pre lang=\"go\">\u201cif port == \"\" {port = \"8000\"}\u201d<\/pre>\n<p>to set a default value for the port. If the environment variable PORT is not set, we&#8217;ll use 8000 as the default value. Here, \u201croutes.AuthRoutes(router)\u201d and \u201croutes.UserRoutes(router)\u201d call the functions AuthRoutes and UserRoutes from the package routes. The function takes in an argument of type *gin.Engine, which is a pointer to a struct called Engine that belongs to the package gin. Then we state a simple API that returns JSON data that has two endpoints: \/api-1 and \/api-2. Finally, we instruct the program to start the server with router.Run(&#8220;:&#8221; + port). This is how you will proceed with the main.go file. (Refer to Image 1)<\/p>\n<figure id=\"attachment_6894\" aria-describedby=\"caption-attachment-6894\" style=\"width: 1311px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6894 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABR8AAAMsAQMAAADnMUemAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAJlJREFUeNrtwTEBAAAAwqD1T20JT6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACApwELegABPsm6egAAAABJRU5ErkJggg==\"  alt=\"\"  width=\"1311\"  height=\"812\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1311px) 100vw, 1311px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/1.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/1.webp 1311w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/1-300x186.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/1-1024x634.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/1-768x476.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/1-380x235.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/1-800x495.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/1-1160x718.webp 1160w\" ><figcaption id=\"caption-attachment-6894\" class=\"wp-caption-text\">[Image 1]<\/figcaption><\/figure>I will next move on to creating a struct but before that let me give you an idea through an image of what folders and files you need to create in order to structure your program and execute it as expected. Please refer to image 2.<\/p>\n<p>Now, let&#8217;s proceed towards struct. Here, my struct will carry different fields like ID, First Name, Last Name, Password, E-Mail, Phone Number, Token ID, User Type, Refresh Token ID, Created at, Updated at, and User ID. I have the primitive package in my models since, I want that for every user, who gets registered gets a unique ID in my database so that while fetching the users, I can use that ID to fetch the user without any conflicts. I used \u201cvalidate\u201d, which checks if the data entered from the client side is in the format we&#8217;ve programmed for and returns an error if it isn&#8217;t. In the User type field, I mentioned eq=ADMIN|eq=USER because it validates the value of the field user type to be either ADMIN or USER. I will now guide you on the routes folder.<\/p>\n<figure id=\"attachment_6883\" aria-describedby=\"caption-attachment-6883\" style=\"width: 1024px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6883 size-large pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABAAAAAJdAQMAAACWE5fTAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAGJJREFUeNrtwTEBAAAAwqD1T20MH6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgbDDsAAHgbkI9AAAAAElFTkSuQmCC\"  alt=\"\"  width=\"1024\"  height=\"605\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/2-1024x605.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/2-1024x605.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/2-300x177.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/2-768x454.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/2-380x225.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/2-800x473.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/2.webp 1118w\" ><figcaption id=\"caption-attachment-6883\" class=\"wp-caption-text\">[Image 2]<\/figcaption><\/figure><figure id=\"attachment_6887\" aria-describedby=\"caption-attachment-6887\" style=\"width: 1016px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6887 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAA\/gAAAC8AQMAAAD2NJczAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAC5JREFUeNrtwTEBAAAAwqD1T20JT6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHgYXgAAAQ7WWHMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"1016\"  height=\"188\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1016px) 100vw, 1016px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/3.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/3.webp 1016w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/3-300x56.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/3-768x142.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/3-380x70.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/3-800x148.webp 800w\" ><figcaption id=\"caption-attachment-6887\" class=\"wp-caption-text\">[Image 3]<\/figcaption><\/figure><figure id=\"attachment_6888\" aria-describedby=\"caption-attachment-6888\" style=\"width: 1023px\" class=\"wp-caption aligncenter\"><img  decoding=\"async\"  class=\"wp-image-6888 pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"1023\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"(max-width: 1024px) 100vw, 1024px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/4-1024x325.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/4-1024x325.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/4-300x95.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/4-768x244.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/4-1536x488.webp 1536w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/4-380x121.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/4-800x254.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/4-1160x369.webp 1160w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/4.webp 1599w\" ><figcaption id=\"caption-attachment-6888\" class=\"wp-caption-text\">[Image 4]<\/figcaption><\/figure><figure id=\"attachment_6889\" aria-describedby=\"caption-attachment-6889\" style=\"width: 1000px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6889 pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"1000\"  height=\"424\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1000px) 100vw, 1000px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/5-1024x434.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/5-1024x434.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/5-300x127.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/5-768x326.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/5-1536x651.webp 1536w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/5-380x161.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/5-800x339.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/5-1160x492.webp 1160w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/5.webp 1542w\" ><figcaption id=\"caption-attachment-6889\" class=\"wp-caption-text\">[Image 5]<\/figcaption><\/figure>Here in routes, I have created two files i.e., authRouter.go and userRouter.go. Where in authRouter.go includes a function that sets up the routes for our application. It takes in an instance of gin.Engine and adds two routes to it: one for signup and one for login. And userRouter.go states a function that takes in an object of type *gin.Engine and returns nothing. It adds two routes to the incomingRoutes object: \/users and \/users\/:user_id. The first route will call the GetUsers() function from the controller package, while the second route will call the GetUser() function from the controller package (Refer to Images 4 &amp; 5). Now we need to work on our MongoDB connection for which you can refer to my other <a href=\"https:\/\/golang.company\/blog\/connect-the-golang-app-using-mongodb\" target=\"_blank\" rel=\"nofollow noopener\">blog<\/a>. After the Database setup, I will explain about middlewares and controllers. (Refer to Image 6).<\/p>\n<figure id=\"attachment_6890\" aria-describedby=\"caption-attachment-6890\" style=\"width: 1000px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6890 pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"1000\"  height=\"468\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1000px) 100vw, 1000px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/6-1024x479.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/6-1024x479.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/6-300x140.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/6-768x359.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/6-1536x719.webp 1536w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/6-380x178.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/6-800x374.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/6-1160x543.webp 1160w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/6.webp 1690w\" ><figcaption id=\"caption-attachment-6890\" class=\"wp-caption-text\">[Image 6]<\/figcaption><\/figure>Middleware contains an Authentication function that checks if the request has a token in its header. If it does, it validates the token and sets some values to the context. This code has 4 imports and they are &#8220;fmt&#8221;, &#8220;github.com\/gin-gonic\/gin&#8221;, &#8220;github.com\/golangcompany\/JWT-Authentication\/helpers&#8221; (helper), and &#8220;net\/http&#8221;. Please refer to above code for more information on the code. After middleware, here come the controllers where we have userController.go where we have imported mongo driver, validator, gin, and some other packages for which you can refer to image 7.<\/p>\n<figure id=\"attachment_6895\" aria-describedby=\"caption-attachment-6895\" style=\"width: 1000px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6895 pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=\"  alt=\"\"  width=\"1000\"  height=\"502\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1000px) 100vw, 1000px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/7-1024x514.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/7-1024x514.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/7-300x151.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/7-768x386.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/7-380x191.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/7-800x402.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/7-1160x582.webp 1160w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/7.webp 1492w\" ><figcaption id=\"caption-attachment-6895\" class=\"wp-caption-text\">[Image 7]<\/figcaption><\/figure><figure id=\"attachment_6896\" aria-describedby=\"caption-attachment-6896\" style=\"width: 1541px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6896 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABgUAAACAAQMAAAARafuOAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAC9JREFUeNrtwTEBAAAAwqD1T20IX6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+A2EAAAET3AXlAAAAAElFTkSuQmCC\"  alt=\"\"  width=\"1541\"  height=\"128\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1541px) 100vw, 1541px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/8.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/8.webp 1541w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/8-300x25.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/8-1024x85.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/8-768x64.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/8-1536x128.webp 1536w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/8-380x32.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/8-800x66.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/8-1160x96.webp 1160w\" ><figcaption id=\"caption-attachment-6896\" class=\"wp-caption-text\">[Image 8]<\/figcaption><\/figure>This is a variable declaration. It declares a variable with the identifier userCollection and assigns it the value of the database.UserData(database.Client, &#8220;user&#8221;). The type of this variable is *mongo.Collection. The function database.UserData() returns a pointer to a mongo collection object (which is why we use the asterisk). This object represents the user collection in our database, which contains all users&#8217; data. The second line declares another variable called validate, which has been assigned the value returned by calling the function validator.New(). The type of this variable is also a pointer to an object: *validator.Validate. Next, I have stated the functions, The first function i.e., HashPassword takes in a string and returns a string. It hashes the password using bcrypt.GenerateFromPassword() and returns the hashed password as a string (Refer to Image 9). Then I stated the VerifyPassword function that verifies the password. It takes two parameters, the userPassword, and providedPassword. The function returns a boolean value and a string (Refer to image 10). Next comes the SignUp function that creates a user. It takes in the user&#8217;s details, validates them, and then stores them in the database (Refer to Image 11). Simultaneously, I have mentioned the Login function which handles a user&#8217;s login with its ID and Password (Refer to Image 12). Finally, I have worked on the last two functions i.e., GetUsers and GetUser. Here, GetUsers is a function that will list all users in the database and return them to the client and GetUser is a function that will list users by their ID and return them to the client (Refer to Images 13 &amp; 14).<\/p>\n<figure id=\"attachment_6898\" aria-describedby=\"caption-attachment-6898\" style=\"width: 1681px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6898 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABpEAAAD8AQMAAAClyR6nAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAEpJREFUeNrtwTEBAAAAwqD1T+1vBqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAN9CwAAEvzILbAAAAAElFTkSuQmCC\"  alt=\"\"  width=\"1681\"  height=\"252\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1681px) 100vw, 1681px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/9.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/9.webp 1681w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/9-300x45.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/9-1024x154.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/9-768x115.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/9-1536x230.webp 1536w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/9-380x57.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/9-800x120.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/9-1160x174.webp 1160w\" ><figcaption id=\"caption-attachment-6898\" class=\"wp-caption-text\">[Image 9]<\/figcaption><\/figure>\n<figure id=\"attachment_6899\" aria-describedby=\"caption-attachment-6899\" style=\"width: 1665px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6899 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABoEAAAG4AQMAAACw2dyBAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAHBJREFUeNrtwYEAAAAAw6D5Ux\/hAlUBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMA3aP8AAcvWPHoAAAAASUVORK5CYII=\"  alt=\"\"  width=\"1665\"  height=\"440\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1665px) 100vw, 1665px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/10.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/10.webp 1665w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/10-300x79.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/10-1024x271.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/10-768x203.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/10-1536x406.webp 1536w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/10-380x100.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/10-800x211.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/10-1160x307.webp 1160w\" ><figcaption id=\"caption-attachment-6899\" class=\"wp-caption-text\">[Image 10]<\/figcaption><\/figure><figure id=\"attachment_6900\" aria-describedby=\"caption-attachment-6900\" style=\"width: 983px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"size-full wp-image-6900 pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9cAAAMdAQMAAACryhe4AAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAHZJREFUeNrtwTEBAAAAwqD1T+1rCKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIA3ghsAARnElH4AAAAASUVORK5CYII=\"  alt=\"\"  width=\"983\"  height=\"797\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 983px) 100vw, 983px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/11.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/11.webp 983w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/11-300x243.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/11-768x623.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/11-380x308.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/11-800x649.webp 800w\" ><figcaption id=\"caption-attachment-6900\" class=\"wp-caption-text\">[Image 11]<\/figcaption><\/figure><figure id=\"attachment_6901\" aria-describedby=\"caption-attachment-6901\" style=\"width: 1465px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6901 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABbkAAAMlAQMAAABkeGz4AAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAKdJREFUeNrtwTEBAAAAwqD1T20Hb6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC4DUXbAAGYDjJ4AAAAAElFTkSuQmCC\"  alt=\"\"  width=\"1465\"  height=\"805\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1465px) 100vw, 1465px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/12.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/12.webp 1465w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/12-300x165.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/12-1024x563.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/12-768x422.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/12-380x209.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/12-800x440.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/12-1160x637.webp 1160w\" ><figcaption id=\"caption-attachment-6901\" class=\"wp-caption-text\">[Image 12]<\/figcaption><\/figure><figure id=\"attachment_6902\" aria-describedby=\"caption-attachment-6902\" style=\"width: 1220px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6902 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABMQAAANjAQMAAAB\/QFRhAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAJhJREFUeNrtwTEBAAAAwqD1T20MH6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4GwmsAAHB7BCRAAAAAElFTkSuQmCC\"  alt=\"\"  width=\"1220\"  height=\"867\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1220px) 100vw, 1220px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/13.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/13.webp 1220w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/13-300x213.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/13-1024x728.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/13-768x546.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/13-380x270.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/13-800x569.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/13-1160x824.webp 1160w\" ><figcaption id=\"caption-attachment-6902\" class=\"wp-caption-text\">[Image 13]<\/figcaption><\/figure><figure id=\"attachment_6903\" aria-describedby=\"caption-attachment-6903\" style=\"width: 1511px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6903 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABecAAAKuAQMAAAARpTWsAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAJVJREFUeNrtwTEBAAAAwqD1T20Gf6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB4Df0zAAG3PJU2AAAAAElFTkSuQmCC\"  alt=\"\"  width=\"1511\"  height=\"686\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1511px) 100vw, 1511px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/14.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/14.webp 1511w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/14-300x136.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/14-1024x465.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/14-768x349.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/14-380x173.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/14-800x363.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/14-1160x527.webp 1160w\" ><figcaption id=\"caption-attachment-6903\" class=\"wp-caption-text\">[Image 14]<\/figcaption><\/figure>In the final steps, I have created two files in helper i.e., authHelper.go and tokenHelper.go in which authHelper.go contains two functions. The first function, CheckUserType, determines whether or not the user type matches the role. The second function, MatchUserTypeToUid, determines whether the user id matches the context uid. And tokenHelper.go contains functions to generate, validate and update JWT tokens (Refer to Images 15 &#8211; 19). This is how you can create your JWT Authentication App in Golang using Gin Web Framework. And finally, to test it you can use the Postman Application to test your application.<\/p>\n<figure id=\"attachment_6904\" aria-describedby=\"caption-attachment-6904\" style=\"width: 1240px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6904 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABNgAAANDAQMAAABFfjAxAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAJVJREFUeNrtwQENAAAAwqD3T20PBxQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMC\/AfzjAAGp80PnAAAAAElFTkSuQmCC\"  alt=\"\"  width=\"1240\"  height=\"835\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1240px) 100vw, 1240px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/15.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/15.webp 1240w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/15-300x202.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/15-1024x690.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/15-768x517.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/15-380x256.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/15-800x539.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/15-1160x781.webp 1160w\" ><figcaption id=\"caption-attachment-6904\" class=\"wp-caption-text\">[Image 15]<\/figcaption><\/figure><figure id=\"attachment_6905\" aria-describedby=\"caption-attachment-6905\" style=\"width: 1503px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6905 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABd8AAAMqAQMAAABJ16oaAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAKtJREFUeNrtwTEBAAAAwqD1T20KP6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+BpWIAABQI3njwAAAABJRU5ErkJggg==\"  alt=\"\"  width=\"1503\"  height=\"810\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1503px) 100vw, 1503px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/16.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/16.webp 1503w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/16-300x162.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/16-1024x552.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/16-768x414.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/16-380x205.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/16-800x431.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/16-1160x625.webp 1160w\" ><figcaption id=\"caption-attachment-6905\" class=\"wp-caption-text\">[Image 16]<\/figcaption><\/figure><figure id=\"attachment_6906\" aria-describedby=\"caption-attachment-6906\" style=\"width: 1586px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6906 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABjIAAAKpAQMAAAAseicYAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAJpJREFUeNrtwQEBAAAAgiD\/r25IQAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC8GFCYAAQhM+KwAAAAASUVORK5CYII=\"  alt=\"\"  width=\"1586\"  height=\"681\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1586px) 100vw, 1586px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/17.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/17.webp 1586w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/17-300x129.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/17-1024x440.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/17-768x330.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/17-1536x660.webp 1536w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/17-380x163.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/17-800x344.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/17-1160x498.webp 1160w\" ><figcaption id=\"caption-attachment-6906\" class=\"wp-caption-text\">[Image 17]<\/figcaption><\/figure><figure id=\"attachment_6907\" aria-describedby=\"caption-attachment-6907\" style=\"width: 1285px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6907 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABQUAAAKkAQMAAACDKcuGAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAIFJREFUeNrtwTEBAAAAwqD1T20MH6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPgar1wABXSJVwgAAAABJRU5ErkJggg==\"  alt=\"\"  width=\"1285\"  height=\"676\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1285px) 100vw, 1285px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/18.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/18.webp 1285w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/18-300x158.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/18-1024x539.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/18-768x404.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/18-380x200.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/18-800x421.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/18-1160x610.webp 1160w\" ><figcaption id=\"caption-attachment-6907\" class=\"wp-caption-text\">[Image 18]<\/figcaption><\/figure><figure id=\"attachment_6908\" aria-describedby=\"caption-attachment-6908\" style=\"width: 1346px\" class=\"wp-caption aligncenter\"><img  loading=\"lazy\"  decoding=\"async\"  class=\"wp-image-6908 size-full pk-lazyload\"  src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAABUIAAANBAQMAAAAfsVbaAAAAA1BMVEUAAP+KeNJXAAAAAXRSTlMAQObYZgAAAAlwSFlzAAAOxAAADsQBlSsOGwAAAKBJREFUeNrtwQENAAAAwqD3T20PBxQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwLsBKUgAAUWPPwIAAAAASUVORK5CYII=\"  alt=\"\"  width=\"1346\"  height=\"833\"  data-pk-sizes=\"auto\"  data-ls-sizes=\"auto, (max-width: 1346px) 100vw, 1346px\"  data-pk-src=\"https:\/\/www.ardorsys.com\/blog\/wp-content\/uploads\/2023\/01\/19.webp\"  data-pk-srcset=\"https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/19.webp 1346w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/19-300x186.webp 300w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/19-1024x634.webp 1024w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/19-768x475.webp 768w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/19-380x235.webp 380w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/19-800x495.webp 800w, https:\/\/avfockc25ltq.cdn.shift8web.com\/blog\/wp-content\/uploads\/2023\/01\/19-1160x718.webp 1160w\" ><figcaption id=\"caption-attachment-6908\" class=\"wp-caption-text\">[Image 19]<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"Do you know, How to create a JWT Authentication Application in Golang using Gin Web Framework? This blog will cover an explanation regarding some concepts that are required to create a JWT Authentication App in Golang\n","protected":false},"author":1,"featured_media":6913,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[175],"tags":[180,176],"class_list":{"0":"post-6870","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-go","8":"tag-go","9":"tag-golang"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/posts\/6870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/comments?post=6870"}],"version-history":[{"count":1,"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/posts\/6870\/revisions"}],"predecessor-version":[{"id":7152,"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/posts\/6870\/revisions\/7152"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/media\/6913"}],"wp:attachment":[{"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/media?parent=6870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/categories?post=6870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ardorsys.com\/blog\/wp-json\/wp\/v2\/tags?post=6870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}