Golang HTTP User Authentication Yabi Series 1 | Golang Web Development | WebAssembly Auth System

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello guys welcome back to the channel this is tutor series number 21 here in maharagan's code okay so we will continue with our discussion guys regarding this um golang web development we are still in this uh series guest because this topic is really really huge and uh we need to segregate something like right now we are about to start a small project but this project is very useful for us this is a uh it is a complete comp uh is a complete users authentication system that we need to create guys so we can reuse every time we have some project uh this kind of thing is uh we already settled because once we have done this and finish this and then up to we need to down upload this and share it with you guys there in our github to so that you can reuse this package so we will try to implement this user's authentication system like what i mean is like there is a login system and then there is authentication there and if the username and password all these things we are using uh mysql database for this tutorial series guys uh we will call this project as um a yabi project so this is what we call for um it's a key in our local dialect it's a key is a key like a house key or something the description will be provided later or in our thumbnails as well okay so we were about to do this because uh once we have done our we have done this project guys every time we have a new project we have this uh ready-made or kind of a generic but not very elegant uh shall we say hell again okay yeah uh whatever it is guys uh we need to have our own uh authentication system here in um code uh we're using mysql and of course the golang programming language here in martin's code so let's dive into this uh tutorial guys okay guys welcome back to the channel okay uh we will continue on uh in our project guys we need to download the official mysql driver for uh this golang programming language so this is the official github for this uh mysql driver guys so we can just use this and install to our yabi project to our authentication uh project guys so there are some examples here on how to install as well of course we know already how to go get this go get this thing okay hello and this is how we call this uh mysql uh driver here and then we can pass on these um what they call these um all the steps guys so these are very uh basic here when once we call this uh database connection so okay so uh we also need this uh samp uh it's up to you guys whatever you are using as long that we have either my mysql database or a mariadb this is the open source uh mysql database guys so right now this this is a mariadb but you can also uh they are all the same guys so this is the community version for the mysql they call it the maria dvd maria db okay so if you are not yet installed right now as of this recording uh we have this uh mysql uh eight so the latest version is right now is uh mysql8 and uh to capture our time guys so if you if if you want if your os is like a windows or for example is my one it's a windows one so windows 10 so i already downloaded this and then i already installed these are all the default databases here as you can see that the version here is a version 10 for the mariadb for mariadb and then the php version 8. so these are so far is the latest as of this recording guys so you can just download uh based on your os there and then we will about to install this as well to use the mysql database for our connectivity here and then we will uh about to create our sample database here like uh this one right now we don't have a database yet so we can create our own database later part and then we will be uh creating uh a yabi project maybe from here at the moment temporarily we will put everything here the yabi new or what they call this yabby project the package so we are about to create a new package here called the yabi so okay guys this is our uh project here and our last discussion guys uh we are also about to use the of course uh what they call this webassembly okay or in short is a wasam so in our previous discussion we have done this login uh for our testing for this awesome okay so we are about to create a new one as well but uh later i've just created this uh yabi new package here and then we will create a new folder i mean the file name called the modal user for example guys this is our model here and then we will um this this one is just we have we are putting inside in our local project here guys so uh later part when we have completely done this uh yabby uh project our authentication system in golang with of course on mysql database we will upload this and then we will publish this in our github so that it's easy for us to download and use this or we can just reuse every time we have a new project so we can use this uh uh authentication that we have done here here in mark's code so we have just uh named this as a package yabi okay and then uh this is our constant uh i we need to specify the constant guys okay uh this is our yabi user so every time we will use this our own this is the table name guys okay don't forget this is a user table is the exact uh table name or the yobi okay just uh put like this guys here be user table okay this one will merge um right now we are doing this in our uh we will insert a new table whatever you have the existing database there we will insert this yabi underscore user table name so this is the table name guys and then we need to define define uh what they call this uh user here okay oh just uh put like that first type user struct probably this is our table structure guys so we need to we need to have always this id of course then we can specify at least in 64 here in 64 is uh enough guys uh we can also use a big in but uh the one is uh the one is too big i think you have some billions of users but this one you can also have a billions ready guys so that one is um and this one is uh quite decent enough for us anyway so unless you're your application congratulations you're very success successful uh what they call this uh application guys so like you are the next big thing okay don't forget the harlequins code guys just kidding guys but uh anyways this one is uh this one is uh uh nobody knows guys okay nobody knows just uh believe okay okay just uh when right now we are doing something guys like we sideways a bit okay so we are i'm defining now uh whatever this uh field name okay so we are doing it from scratch guys okay um this one is a very raw project that we are we are exploring and then of course we have started guys we can reuse this in our next big thing okay so i just create first these are all the very generic kind of thing guys okay uh we need this like the first name some countries don't have the first name last name they can this one it's like it's like a u.s style guys uh you have some first name last name but this one is very common okay so every application that is like this okay so but uh just fill up whatever it is the format in your country okay so first name okay so first name we can also have this optional one guys they call it the middle name okay this one is a extra field here but for u.s or western countries or whatever guys um do you know what i'm talking about we're also following this okay uh you can just uh leave this blank as usual guys okay we need to i think we need to speed up keep talking okay these are all string middle name i think we need the last name as well okay and then make sure that you have this json format here guys later okay uh make sure you have this um json because uh later when we retrieve or select statement or we need to fill up data all these things guys will be will be used this uh this truck here okay so uh some countries we also have suffix guys these are all extra extra fish guys okay just kidding okay don't be so serious guys okay just uh just have fun learning okay and here in martin school is super admin uh maybe super user okay we will try this and then we will see this as a boolean here and then we will do this um a super user okay guys so uh this one we will need this i will explain later on guys this topic is suffix is a extra fish again guys it's an optional middle name as well but you can reuse this for whatever purpose or reason uh your application needed okay so this is super user is uh we need to use this as what they call uh as a super admin guys um what i mean is we can create a separate function for this tool like a cli kind of thing uh or a special function we will create later part that one is up in an advanced uh topic guys so but right now we just uh set up everything here uh whatever is our structure guys so is uh admin um okay this admin as well uh the super user can see everything or whatever the privileges or the these super admin also can create uh localized admin this uh is admin is a localized admin guy so for us for example if in your application uh you have some of course a higher privilege account to create the internal or whatever who is the admin or administrator in that department or that user you can specify the super admin can specify or create an account for a localized administrator uh for this kind of thing guys so we will be um this one is a additional one guys um but it's up to you you can reuse this or not we just want to put all these things this information to structuralize our yabi authentication system here so we will be creating this and of course in the future enhancement guys so okay so we need to have also last login okay this we need to specify time that time guys okay um json that we need name this as a last login okay so it automatically will be imported the time there so we need to have also the date join date join okay time the time as well so we will be uh dealing with this uh date join here as well so when the user register imagine guys right now we are doing this um what they call this login okay imagine that [Music] okay there's some hair right there okay sorry uh sometimes we we keep talking and uh sometimes we forget this is the life of uh okay oh never mind okay boolean and then we need to use this json and then uh this one is active or not the user is active this one they join when you have them you have some users registration of course in your website or your sas application or something we always encounter with the user's registration login uh really i really like to have our own authentication system guys we don't heavily rely on like facebook authentication or google authentication or something but it's good to have but we are really under mercy for those uh when the there's some changes uh this is my opinion only guys okay i don't want to be bound to some certain changes there then probably our application may maybe break or something but we do not know so we need to maintain always and then check if it is still working or not but if we have our own uh very own login system now 100 sure that we sure that we that we are in a totally full control uh full control of our uh authentication system guys so but of course this one is uh the securities of courses um we will secure everything here guys okay so don't don't worry uh later part that one is in our just a overview for you so we have done our uh this one is our users uh user model guys um we don't want to use um what they call this the common orm there like uh there's so many kinds of uh orm there guys uh like gorm or other kind of frameworks there um i really like to have our own like um we we will we will reduce all those uh what they call this we will reduce some of the dependencies guys so we don't rely heavily on other frameworks because uh i i came from there or something but we don't want to be bound too much on the dependencies to a certain framework we will do it in our own game so um here in parliament we will uh start our own here yeah it's not like this one the mysql mysql database i mean the mysql official driver will be using this we don't rely on such orm there again we don't want to we don't want to be bound too much on the other dependencies so we will reduce as much as possible guys okay so this is our user models uh collection here uh this one is a user model collect collections okay just uh just a quick information guys to collect i mean two users model collections for the users or the users basic information okay like that you can and this one is now we have done this model here uh what we're going to do is we need to create our own database first guys and then we will create this table first uh at the moment we will create manually first guys uh because we don't have the the code first to create the you create the table but in our future uh thing we will be having this kind of uh what you call this mysql here guys so you need to create another database here uh shall we say we will create the maharlikans um harlequin's code okay this is our database name uh ensure that you use um the collision here guys is a utf uh general c general um this one utf general ci um we will choose this because uh uh this is um we will this is the battle tested guys uh for us because uh when we encounter some ascii codes or something like that in the user key in like other languages like arabic languages or the spanish languages language or spanish language spanning spanish language or japanese or chinese language these are all non english alphabet guys so we will have some problem when we insert or manipulate our database or the tables there so when we keep those information then this utm general collision will be it can accept uh can accept those data guys so right now we will uh create a one table first this one we will uh we will count 13 fields so we will be uh making these guys so 13 fields so we will have this yeah be here yeah we 13 users oh 13 13 fields okay so these are quite a lot guys so we need to fill up slowly here so i need to have the id but uh later apart guys i will uh we will be dealing with this okay so default is nothing here these are all our primary kind of thing here guys so this one auto make sure to if you are not new to mysql guys you can uh just just acquire this but for those beginners one um just take this if you want the auto increment of course we need to use the auto increment here so again we need to have some uh and these are all the fields guys at the right side here the right side pane uh all the json kind of thing here these are all the standard code guys okay so and the mysql database will be uh mapped to this uh json field here this is the actual uh username okay so this is the actual username exact field name okay so we will follow this because later we when we use this user struct here this is our model from the database uh it should match exactly whatever the the name here guys okay so we just name this as uh maybe this user name um we will put later packet maybe 75 something okay so so to capture our time guys uh i already fill up fill up everything here the all the columns here and then the specific field type the user name is a varchar 75 of course this collision is automatically pre-populated because when we create this database mohawkins code we already specify the default collision for all the tables there for the entire database so every time you create a string string fields here like the barcode then it will be automatically uh pre-populate for you all these utf uh general ci collision okay guys so uh this one i put this as an index i don't want to be bound with also with another one what they call this uh too much uh linking guys uh we don't encourage that one here because uh it will uh slow down our database um this is my opinion guys okay uh we don't rely on linking too much on our database index is a very good because we but we don't want don't put too much index in our table as well because this one is uh it will be um what you call this is not a good idea also guys when you want to call this when you index everything here because it will consume a lot of hard disk space and of course the memory as well for the mysql uh database so what we're going to do is we need to index all those uh very useful and uh very frequently when we do the select statement okay so like these are the username of course the id is automatically the primary one and then we will be dealing with that is active as well so this one is our old boolean type and when you see this is a tiny integer here so okay we will pass drag a bit uh okay the username would be 75 128 so this is our initial um length guys for each field here maybe when during this period we will be tentatively we will the handle we will set by this uh configuration here okay so when we uh we have done this yabi user so assuming that you have any existing database guys um later part we will do the exact table structure here when you do when you use this yabby um what you call this a yabby user so okay so you will be this yabby user's authentication in your project uh right now it's very raw guys uh just uh hang on hang on for a while okay so we have done uh make sure that uh all the json files here the the right side um information here in our struct is uh we have uh totally match whatever everything the field name here ensure that all match and of course if you specify the first name for example guys um this is the string uh in your golang is a whole string here there in mysql it interprets as a bar card or text text is a long strings guys or long string also have and then uh these are all the strings guys okay so the time and the date time is like our last login here and then the date join um these are all the required information guys because the knowledge and we don't set this as null so we set this uh null no for the username password and the email and the rest all optional guys because when we deal with the registration initial registration for your site we only create for username password email address and then a confirm password and then that's all that's all on it guys so these are all optional fields but when the user successfully activate the user's account then when they go to the dashboard after they successfully log in for the first time then we will be prompting with the rest of the information that we need to collect for the user like this first name the middle name and then the last name and so on and so forth you may be wondering why there is less information here um in our next discussion guys uh in a future discussion here in uh this uh yabi uh users here um we will have some separate or that one is your own configuration guys like additional information for the user like the user's profile so um this one is for the rbu certainly okay so when you have some extra information uh that one you can create your own table there but this is the master users list for your entire site so this is a the generic thing so everybody can handle all these things but your own customization you can split it with another another table of your own like a user's profile but the id there as you only link up with the user's id from this yabi user then you can then you can have as many uh customized customization like uh like like the about or the user's website or those social media links that you want to collect also but you can handle that with another table called like for example is a user's profile okay so but all the registration that we have doing now uh this one is a generic kind of thing so you will understand uh further guys when we go along and go deeper with this uh yabby series here the authentication series um user's authentication series into here in and scone so we will have done this and then we will create uh with our uh go run main that go guys hold on power uh what i'm going to do in our next discussion guys when we run our 127 and then we will see the login here this is our login system guys so we will use the the yabi system there so we have some sign up here uh we need to create that one as well so we need to create those username password email address and then agree with our terms of course we are using the webassembly here as well so in our next discussion guys we will we're about to create uh users sign up first because we don't have uh authentication yet because we our table here is totally empty so we will start with the registration okay so we will be dealing with the registration here we will create a new page called sign up or the registration page okay guys so okay guys that's all for today's the discussion uh we will continue on no worries this uh this also uh as we go along is a huge topic as well guys maybe you know this one is because this one is a complete user system it's a generic kind of thing uh we will uh dealing this with this um our own project so that you guys out there you can you can reuse the project every time you you have a new golang project for your web development there so you can start this or you can play along or you can follow along with these series here in harlequin's code so see you guys in my next picture series here we will continue we will be continuing these markings codes most especially this new sub what we call this some topic here uh we have a some small project we call it a yabby project for these users a complete authentication system so thank you so much guys for watching my video see you in my next teacher series here in american cold may god bless us all thank you and [Music] bye-bye
Info
Channel: Maharlikans Code
Views: 357
Rating: undefined out of 5
Keywords: Life As Software Developer, go, golang web development series 21, golang web development course, web development with go, golang tutorial, learn to create web applications using golang, building scalable web apps in golang, golang good for web development, golang http user authentication, golang http authentication, golang user registration, golang authentication microservice, golang session authentication, golang webassembly, golang mysql, golang mysql tutorial, golang sql
Id: QRzez1hNRj4
Channel Id: undefined
Length: 32min 57sec (1977 seconds)
Published: Fri Dec 18 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.