How to create a login with different permission levels?

Asked

Viewed 3,092 times

2

How to create a login with different permission levels? Is it necessary to create a table in the database to log in? I have read about formsauthentication, cookies and etc, but still do not understand very well.

  • First we need to narrow down the technology. I have already answered several questions about authentication methods here in the OS, namely: ASP.NET Identity, ASP.NET Membership and Forms Authentication. Which one would you like to know about?

  • I think Membership seems to be the simplest way to start. I’m a little lost in the midst of these many possibilities of logging in and etc. If it’s not too much trouble, you could explain the 3?

1 answer

2


I’ll explain two: ASP.NET Membership and ASP.NET Identity.

ASP.NET Membership

It’s a standard data architecture designed to handle the users of an application. In this case it is assumed that your application will have its own user base, and some other systems of logins of other sites can be integrated. You can work with Forms Authentication, which is another Microsoft standard, much simpler, but aimed at the user authentication process itself.

There is a (very) simple implementation of logins and passwords called Simple Membership where there is no need to write code. Here is a tutorial on how to do.

If you want to implement something more customized, have some answers of mine in which I teach in detail how to do:

ASP.NET Identity

Membership being limited to working with new methods of authentication and permission, Identity was created, which basically brings some news such as working with Claims and more sophisticated methods of user identification.

Some of my answers about:

  • Thanks! I think Membership can supply my needs. Just one question. Is a table necessary to store the roles? or just add this field in the user table, for example?

  • Better leave it in a separate table, and you associate which users belong to which roles.

  • 1

    I get it. I’ll implement it here, thanks for the help.

  • One last question. I made a table with the fields idrole(Primary key), namerole and idusuario(foreign key) Is this table enough? Or do you think I should add something else?

  • @Ryansantos Don’t use UsuarioId in the Role definition. A Role can contain multiple users. It is not a Role per User.

  • I realized this at the time I posted! Haha I will correct. But you think this table is enough?

  • I don’t know. I usually just put Id and Name.

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.