forms-authentication

ServiceStack API and ASP MVC Authentication in two ways

南笙酒味 提交于 2019-12-03 07:56:17
问题 I'm having trouble solving architecture of an ASP MVC application that servers html pages and web services through ServiceStack. The application lives in the base url eg "http://myapplication.com" and SS lives in "http://myapplication.com/api" because it is the easiest way to configure both. In general everything works fine, but when I reached the part of the authorization and authentication, is where I'm stuck. For one, I need the application handle cookies as ASP normally do

Why are my forms authentication tickets expiring so fast?

☆樱花仙子☆ 提交于 2019-12-03 07:16:31
I'm using forms authentication in an ASP.NET application. I configure the FormsAuthenticationTicket to expire in 1 year but it actually expires after 1 hour or so. I can't figure out why. Here is all the code involved in the login process: public static bool Login(int id) { try { string securityToken = UserHelper.AuthenticateUser(id); DateTime expiryDate = DateTime.Now.AddYears(1); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, id.ToString(), DateTime.Now, expiryDate, true, securityToken, FormsAuthentication.FormsCookiePath); string encryptedTicket = FormsAuthentication

Impersonate a membership user in ASP.NET

拟墨画扇 提交于 2019-12-03 06:53:12
In a generic asp.net website with Membership , Roles and hashed passwords enabled, I would like to provide the administrators with impersonation so that they may browse the website as that user would. The website should function as if that user is logged on and then be able to revert to their own login. What is the best approach to achieve this? An example use-case: A website with two types of users: 'Buyer' and 'Admin'. The website provides a 'Purchase' button to buy something specifically provided to the user by the admins. i.e only that buyer can use the purchase button and make a payment.

MVC session expiring but not authentication

萝らか妹 提交于 2019-12-03 06:30:57
I'm developing a C# MVC application and I can't seem to get the Authentication and Session timeouts to synchronize. I have a basic Forms Authentication setup and some limited session values. I set the Authentication timeout less than the session (28 minutes vs 30) but running against the development web server, the session will be wiped on a restart of the server but the authentication sticks around. I'm assuming that the authentication is being stored in a cookie that obviously survives the server restart. <authentication mode="Forms" > <forms loginUrl="~/Account/Login" timeout="28" /> <

FormsAuthentication: Is it secure?

╄→гoц情女王★ 提交于 2019-12-03 05:45:52
问题 Using FormsAuthentication build into asp.net it's very quick and easy to create a login system that creates a cookie for authenticated users: FormsAuthentication.SetAuthCookie(uniqueUsername, false); Paired with some code in the Web.Config file: <authentication mode="Forms"> <forms loginUrl="Login.aspx" timeout="30" defaultUrl="Dashboard.aspx" protection="All" /> </authentication> <authorization> <deny users="?" /> </authorization> This will bounce all requests back to Login.aspx until the

Problem creating persistent authentication cookie: ASP.NET MVC

懵懂的女人 提交于 2019-12-03 05:43:59
OK, here's my code to create an authentication cookie: // get user's role List<UserType> roles = rc.rolesRepository.GetUserRoles(rc.userLoginRepository.GetUserID(userName)); List<string> rolesList = (from r in roles select r.ToString()).ToList(); string[] rolesArr = rolesList.ToArray(); // create encryption cookie FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1, userName, DateTime.Now, DateTime.Now.AddDays(90), createPersistentCookie, String.Join(";",rolesArr) //user's roles ); // add cookie to response stream string encryptedTicket = FormsAuthentication.Encrypt

How can I authenticate against Active Directory in Nancy?

不羁岁月 提交于 2019-12-03 05:13:54
问题 It's an outdated article, but http://msdn.microsoft.com/en-us/library/ff650308.aspx#paght000026_step3 illustrates what I want to do. I've chosen Nancy as my web framework because of it's simplicity and low-ceremony approach. So, I need a way to authenticate against Active Directory using Nancy. In ASP.NET, it looks like you can just switch between a db-based membership provider and Active Directory just by some settings in your web.config file. I don't need that specifically, but the ability

Asp.Net Core - simplest possible forms authentication

与世无争的帅哥 提交于 2019-12-03 04:48:25
问题 I have this old MVC5 application that uses forms authentication in the simplest possible form. There is only one account stored in web.config, there are no roles etc. <authentication mode="Forms"> <forms loginUrl="~/Login/Index" timeout="30"> <credentials passwordFormat="Clear"> <user name="some-user" password="some-password" /> </credentials> </forms> </authentication> The login routine just calls FormsAuthentication.Authenticate(name, password); And that's it. Is there something similar (in

How secure is basic forms authentication in asp.net?

自古美人都是妖i 提交于 2019-12-03 04:47:45
Imagine that you have a simple site with only 2 pages: login.aspx and secret.aspx. Your site is secured using nothing but ASP.net forms authentication and an ASP.net Login server control on login.aspx. The details are as follows: The site is configured to use the SqlMembershipProvider The site denies all anonymous users Cookies are disabled The are obviously many things to consider regarding security but I am more interested in the zero code out of box experience that comes with the .net framework. If, for the sake of this question, the only attack points are the username/password textboxes in

Setting up Forms Authentication for multiple Web Apps in MVC 5 based on OWIN

那年仲夏 提交于 2019-12-03 04:42:37
I am in process of setting up my 1st MVC Web App. I know I need to provide a Forms Based Authentication model as well as I know I will be reusing it for multiple other internal web apps as well. All the documentation for MVC 5 Authentication, which I believe is all based on OWIN stuff, have it "baked" into a single web app using EF Code First no less. What I am trying is to have an another Web App that I strip everything out of except for the Account stuff and then try to "point" my web apps Authentication to that and have it return a "token", I'm guessing, of my Authenticated User and his/her