Тёмный
No video :(

Adding Roles to the API - A TimCo Retail Manager Video 

IAmTimCorey
Подписаться 419 тыс.
Просмотров 16 тыс.
50% 1

In this video, we are going to be limiting who can do what by adding in user roles. This will prevent just anyone from using our register and it will allow us to further lock down the endpoints we just created to only administrators.
** TimCo source code now at: www.iamtimcore...
Full Courses: www.iamtimcore...
Mailing List: signup.iamtimc...
One-off tutorials are awesome but they aren't the only thing you should be doing to learn C#. Another vital part of learning is learning how to put it all together. This interactive course is all about putting the pieces together. You can watch each video on its own or you can watch them in order and see a bigger picture. The choice is yours.
This course focuses on real-world development. As such, we are simulating that we work for TimCo Enterprise Solutions on a brand new product, the TimCo Retail Manager. Just like in the real world, we are starting out with one set of requirements but know that over time they will change.

Опубликовано:

 

26 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 67   
@andresbeltran5779
@andresbeltran5779 Год назад
Great video, i learn a little more about roles and permissions, thx
@IAmTimCorey
@IAmTimCorey Год назад
Glad it was helpful!
@torrvic1156
@torrvic1156 3 месяца назад
Thank you so much for valuable advices Mr. Corey! Didn’t knew how to differentiate this roles requirements before with operators like OR or AND regards to authorisation.
@IAmTimCorey
@IAmTimCorey 3 месяца назад
I am glad it was helpful.
@benthornhill9106
@benthornhill9106 3 года назад
Great video! Thanks for taking the time to teach basic principles as you go along.
@IAmTimCorey
@IAmTimCorey 3 года назад
Glad it was helpful!
@stinefelt
@stinefelt 3 года назад
The role overview I can't say thanks enough, I was having some issues with Roles. Not anymore. ;)
@IAmTimCorey
@IAmTimCorey 3 года назад
Glad it helped!
@villesipola
@villesipola 4 года назад
What a great video! Powerful and yet simple to use stuff with those roles. Without knowing what topics there are yet to be covered in the rest of the episodes in this series, i hope there will be a episode where those plain typed roles get converted to enums for ease of use. Thanks Tim! Let the binge watching continue =>
@IAmTimCorey
@IAmTimCorey 4 года назад
Glad you enjoyed it!
@harag9
@harag9 5 лет назад
As always you are Tim Corey, and as always, another great episode. Thanks Tim!
@IAmTimCorey
@IAmTimCorey 5 лет назад
Thank you!
@ilkansuslu1814
@ilkansuslu1814 5 лет назад
Great Content. Hey Tim can you make a video "What have we done so far?(TimCo Retail Manager Video Serie)"
@IAmTimCorey
@IAmTimCorey 5 лет назад
I can add that to the suggestion list. Thanks!
@ale-cx8vp
@ale-cx8vp 5 лет назад
Thank you Tim, an incredibly useful tutorial. To my mind, getting rid of magic strings could be pretty worthwhile.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Thanks for the input.
@harag9
@harag9 5 лет назад
@@IAmTimCorey I agree, would love to see a better solution without all the magic strings, I see loads of typos happening...
@andywalter7426
@andywalter7426 5 лет назад
One suggestion i have when you eventually do the web views in aspnet core is to use server side blazor. Since that is for sure being released in production later in september 2019.
@99MrX99
@99MrX99 5 лет назад
Also would really like it, if we would use blazor for that.
@IAmTimCorey
@IAmTimCorey 5 лет назад
That suggestion is on the list. I'm considering where to put it. Thanks!
@SuperDre74
@SuperDre74 4 года назад
Thanx for the informative video
@IAmTimCorey
@IAmTimCorey 4 года назад
You are welcome.
@simon_smale
@simon_smale 4 года назад
Awesome content as always. Please show how to remove the magic strings. I like the enum idea. I think one role per thing and then one user has many roles. Can you make these more granular like permissions. A user can have read or write or different levels of admin?
@IAmTimCorey
@IAmTimCorey 4 года назад
You can remove these strings but I typically find that it isn't necessary if you are doing your permissions correctly. Roles should be rather big categories, not really specific. For those you want to take what you already know and dial it in even further (so identify which users can write and then do a check for that rather than creating a role for that).
@drambooi7169
@drambooi7169 3 года назад
Hi Tim - amazing video as always! A question: instead of using a GUID for the role ID, could you just assign an ID like '1', '2', '3' etc.?
@IAmTimCorey
@IAmTimCorey 3 года назад
The RoleID, UserID, and other items in the security database come from the Microsoft Identity system. That is how they are designed. Changing from a GUID to an int would require overriding how that entire system works, and I don't want to get into that.
@kayyelle
@kayyelle 5 лет назад
Thank you Tim for the informative video. Could you kindly show us how not to use the magic string for the role name ? Just a thought ... is it possible to create the user role authorization part as a reusable component ? Because when other new projects, need the user role authorization function, instead of keep repeating ourselves by creating the code for user authorization, we can reuse by plugging in the user role component, do a few configurations and we are good to go.
@IAmTimCorey
@IAmTimCorey 5 лет назад
Thanks for the vote. As for creating a reusable component, it already is. The part that isn't reusable is what changes per project.
@kayyelle
@kayyelle 5 лет назад
@@IAmTimCorey Thank you for your reply. Oh, I didn't know that. Always learning something new from you (^_^)v
@hchoi84
@hchoi84 3 года назад
Hi Tim! First of all, thank you for all the contents. I've been following you on RU-vid as well as courses on your site. Gave me more than enough to do this year during the pandemic. To my question, I've been using Claims and this is my first time seeing Roles in action. Roles seem to be easier to implement compared to Claims (I would create policy on startup.cs and use that throughout the project). I also searched your RU-vid channel with the keyword "Claims" and didn't see anything. I'm curious if you may have any information on the difference between Claims and Roles; security, small vs large project, flexibility, etc.
@IAmTimCorey
@IAmTimCorey 3 года назад
I haven't covered the differences but I will add that to the suggestion list.
@scottsaccenti
@scottsaccenti 5 лет назад
I've caught up! Now I have to wait like everybody else for the next drop :)
@IAmTimCorey
@IAmTimCorey 5 лет назад
Nice work catching up.
@johanhansson2531
@johanhansson2531 3 года назад
Hi Tim! I have a short question, why aren't you using the EF database instead of making your own? If i want to register a user in WPF UI... first i have to add user to EF database and then fetch the ID and then insert into User-table in TRM database. Is that correct or I missing something?
@IAmTimCorey
@IAmTimCorey 3 года назад
Two reasons - first, I like separating my security from my data. That allows me to be more granular with my database permissions. Second, I prefer not to use EF, especially not in production. It takes a lot to get right. I prefer to dial things in more closely with Dapper/SSDT so that I have the best possible performance.
@elchureee
@elchureee 4 года назад
Great content!!
@IAmTimCorey
@IAmTimCorey 4 года назад
Thanks!
@mohamaddjelouah9332
@mohamaddjelouah9332 5 лет назад
thank u tim keep up ue the best
@IAmTimCorey
@IAmTimCorey 5 лет назад
Thank you!
@efimov90
@efimov90 4 года назад
IAmTimCorey, actually commit description isn't enought descriptive, because in this commit you delete ValuesController. So maybe it will be better to separate this into separate commit?
@IAmTimCorey
@IAmTimCorey 4 года назад
Probably. I shortcut these a lot because of being on video.
@mihaimyh
@mihaimyh 5 лет назад
How about claims/policies? Isn't that a better implementation?
@IAmTimCorey
@IAmTimCorey 5 лет назад
Claims can be more granular but I don't think we need that complexity here. Roles are a great way to go to keep things simple and easy to manage.
@onyebuchiboss
@onyebuchiboss 4 года назад
Hi Tim, I hope you havent forgotten, but when we started this App, you manually copy and pasted the user Id from the EF user table into the User table of the SSDT table. Do you intend on making that process automated at some point?
@IAmTimCorey
@IAmTimCorey 4 года назад
You will see an update for that this week in the .NET Core upgrade. We will clean it up a bit but it is the start of what you are asking for.
@StudentCompanion
@StudentCompanion 5 лет назад
Thanks Tim, great tutorial as always. Can this same method of [Authorize] of Roles be used with a WinForm application with no Controllers like a WPF application? What's the simplest way to achieve this with a winForm? Thanks.
@IAmTimCorey
@IAmTimCorey 5 лет назад
That comes from ASP.NET. There might be a way to add something for authorization into WinForms directly, but I've not done it. Your best bet would be to do like we are doing and add an API in the middle and handle the authorization there.
@StudentCompanion
@StudentCompanion 5 лет назад
@@IAmTimCorey ok. Thanks
@andywalter7426
@andywalter7426 5 лет назад
I have a question. Do you know if its possible to do authorization and rules if a person chose to use sql lite instead of sql server. Because since this is a web site and it has to be hosted on azure, then they would have to use sql server which the cheapest option is 5 dollars per database. If a company does not have the money for that and wanted to use sql lite, hopefully that is possible. Otherwise, they would be forced to create their own security system and have the data in sql lite.
@IAmTimCorey
@IAmTimCorey 5 лет назад
The new .NET Core templates allow you to choose SQLite as your database as an alternative to SQL Server so yes, you can do that. However, I would caution you on the pricing issue. If a company does not have $5/month to spend on data, they don't really have the money to have data. Just because SQLite is free doesn't mean it is truly free. You now need to make sure you are doing regular backups and maintenance on it. You also need to make sure you update the SQLite version whenever a security fix comes out. Basically, you should be doing a few hours of "extra" work each month in exchange for using the "free" SQLite. Using SQL hosted by Microsoft offloads a lot of that work onto Microsoft. You are paying $5/month for better redundancy, better server security, and better maintenance. Just ignoring all of that work with your SQLite database is an option but then you are risking your company's data. That's a pretty big factor in data breaches and in catastrophic issues at companies - they ignored the regular maintenance of their data.
@timothywestern6488
@timothywestern6488 5 лет назад
There is also Still SQL Server on Premise, but you pay a yearly license Fee I think. MS May be trying to Phase this out Soon though.
@objectaware5296
@objectaware5296 5 лет назад
I noticed the [Route] attribute decorating the actions but I don't see the routes.MapMvcAttributesRoutes(); in RouteContig.
@IAmTimCorey
@IAmTimCorey 5 лет назад
It is in the WebApiConfig.cs file (actually MapHttpAttributeRoutes).
@musings2134
@musings2134 4 года назад
Hey Tim, this is really important to me. Could you please explain how could we do this if we are you using Entity Framework? I am thinking , may be create an action filter to do so? How would you do it?
@IAmTimCorey
@IAmTimCorey 4 года назад
I assume you mean Entity Framework. That is what the Identity server uses Entity Framework and that is what I am using. We do more Entity Framework specific work later on in the series.
@musings2134
@musings2134 4 года назад
@@IAmTimCorey Oh I am sorry! I meant " if we are NOT using Entity Framework?" I love the way asp.net identity lets you neatly manage role based authorizations by just adding an annotation at the top of your controller method. But what if you are not using entity framework? What if you are using ADO.NET with ASP.NET Core API? How do you manage Role Based Authorization? I am thinking may be a CustomActionFilter could do the trick?
@moch.ikhsanafandi4395
@moch.ikhsanafandi4395 5 лет назад
thank you sir, do you have crud .NET Framework video? im learning from my co worker code. but i need basics on how crud, mvc and ajax/jquery works. we have existing db using stored procedure for transactional. currently, its all way above my head haha
@IAmTimCorey
@IAmTimCorey 5 лет назад
Sure, I have a few. Start with this one though: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Et2khGnrIqc.html
@RonitGhosh
@RonitGhosh 5 лет назад
How many more videos do you plan to have in this course?
@IAmTimCorey
@IAmTimCorey 5 лет назад
I don't have a total in mind. I plan on continuing to grow and morph this project. There may be a time when we start over but I doubt it. The goal here is to create a real-world simulation of a business application. When you get hired into a job, you usually start working on an existing, complex system. That's hard to find tutorials on. This application is that tutorial. You can practice starting in the middle and getting up to speed.
@gustavobreunig3369
@gustavobreunig3369 5 лет назад
Thank you Tim. Where can I find the code of Authorize class helper?
@IAmTimCorey
@IAmTimCorey 5 лет назад
Authorize is built into C#. It isn't something I built.
@gustavobreunig3369
@gustavobreunig3369 5 лет назад
@@IAmTimCorey ok. Thank you
@chetanagarwal461
@chetanagarwal461 5 лет назад
How to do the same thing with .net core API with mongodb ?
@IAmTimCorey
@IAmTimCorey 5 лет назад
You can't use the Microsoft authentication system with MongoDB.
@harag9
@harag9 5 лет назад
@@IAmTimCorey Q) Is the MS Authentication system only available in EF? If not what else?
@IAmTimCorey
@IAmTimCorey 5 лет назад
In theory, you can rip out the EF and use your own data access. In practice, it is a paid to do and not worth the effort.
Далее
Whoa
01:00
Просмотров 24 млн
СМАЗАЛ ДВЕРЬ
00:31
Просмотров 188 тыс.
СЕРЕГА ПИРАТ - TEAM SPIRIT
02:37
Просмотров 227 тыс.
Turns out REST APIs weren't the answer (and that's OK!)
10:38
Managing User Roles - A TimCo Retail Manager Video
1:12:42
Getting User Data - A TimCo Retail Manager Video
1:13:38
Generics: The most intimidating TypeScript feature
18:19
Early Refactoring in C# - A TimCo Retail Manager Video
40:41
Whoa
01:00
Просмотров 24 млн