0

I am building one of my first MVC projects. Now I have come to the stage where I am developing the login!

I never used FormsAuthentication, and I am new to this.. But how "stupid"/insecure is it to do this if the user is valid:

 FormsAuthentication.Initialize();
 FormsAuthentication.SetAuthCookie("NameOnCookie", false);

And then I do this, in the top of my controller:

[Authorize(Users = "NameOnCookie")]

Is it dumb, or is it a secure way to work?! If it is a wrong way to work, give me directions!

And if its insecure why? How can you crack it?

Thanks!

2
  • "NameOnCookie" being a specific username? Commented Dec 8, 2011 at 23:23
  • NameOnCoockie Just a name I set if the User is Valid or not, thats the thought..... Commented Dec 8, 2011 at 23:26

1 Answer 1

1

The Users property of AuthorizeAttribute specifies which users are allowed to call your action, so if you're specifically wanting a user with the exact username "NameOnCookie" to be authorized, your solution will work (assuming that you only called SetAuthCookie after a proper authentication took place).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.