forms-authentication

Accepting ASP.NET Forms Authentication cookies in an OWIN-hosted SignalR implementation?

ⅰ亾dé卋堺 提交于 2019-12-05 07:17:28
I've got an self-hosted SignalR instance, using OWIN. I'd like to implement authorization. My users will already have logged into an ASP.NET MVC application, using Forms Authentication. Since the two applications will be available at the same URL, the cookies will be shared between the two. How do I accept a Forms Authentication cookie in a self-hosted SignalR application? Clarification: I'm talking about a browser accessing a self-hosted SignalR hub using the same credentials that were used to log into a separate (but related, and installed on the same host) IIS application. So, the question

MVC 4 Forms Authentication not working with [Authorize]

青春壹個敷衍的年華 提交于 2019-12-05 06:16:43
I'm learning MVC4 right now, and I am following the Pro ASP NET MVC4 4th edition book to create a Sports Store project. I have always developed in webforms, and I am trying to figure out how the forms authentication is working in MVC4. Here is what I have achieved: Web.Config <authentication mode="Forms"> <forms loginUrl="~/Account/Login" timeout="2880"/> </authentication> AccountController login Action: [HttpPost] public ActionResult Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { if (authProvider.Authenticate(model.UserName, model.Password)) { return Redirect

FormsAuthenticationTicket expires too soon

百般思念 提交于 2019-12-05 04:08:33
This is my function that is called when a login is successful. (I am very new to this FormAuthentication thing) public static void CreateLoginCookie(User u) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(u.Id.ToString(), true, 9*60); string encryptedTicket = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) { Expires = DateTime.Now.AddHours(9) }; HttpContext.Current.Response.Cookies.Add(cookie); } In the web.config I have <authentication mode="Forms"> <forms loginUrl="~/Default/Login" timeout="540"

How do I stop ASP.net forms authentication / session from renewing in setInterval ajax web service call?

眉间皱痕 提交于 2019-12-05 02:47:03
I have a control that i've written that has a javascript component and a web service component. The problem i'm having is that the javascript is set to do: setInterval(this._checkAlertsHandler, this._messageCheckInterval * 1000); This calls a function which makes a webservice call like so: Alert.SiteAlertService.GetAlerts(this._receivedAlertsHandler, this._errorReceivedAlertsHandler); So this is using the web service javascript proxy methods to access the web service. The issue is that our application has forms authentication and a timeout value, so if the user is idle for too long it will log

User.Identity.IsAuthenticated vs WebSecurity.IsAuthenticated

末鹿安然 提交于 2019-12-05 02:37:21
In an MVC4 app, in a controller logic I want to check if the user is logged in. Should I use: User.Identity.IsAuthenticated Or: WebSecurity.IsAuthenticated As far as I know WebSecurity is just a wrapper. Should I use it or User.Identity has different functionality ? As far as I know WebSecurity is just a wrapper. That's correct, both are the same. Let's have a look at how the WebSecurity.IsAuthenticated property is implemented: public static bool IsAuthenticated { get { return Request.IsAuthenticated; } } and now let's look at how the the WebSecurity.Request static property is implemented:

ASP Website does not seem to use machineKey in Web.Config for FormsAuthentication.Decrypt

安稳与你 提交于 2019-12-05 01:57:16
问题 I want to pass the authentication cookie from my ASP.Net MVC 5 (.Net 4.5.1, hosted locally on iisexpress, run from Visual Studio) to my WCF Service (.Net 4.5.1, hosted locally on WcfSvcHost, run from same Visual Studio Solution) and decrypt it there. I have configured both to use the same machinekey (Web.config for ASP, App.config for WCF): <machineKey validationKey=

System.Web.Security.FormsAuthentication.Encrypt returns null

↘锁芯ラ 提交于 2019-12-05 01:17:49
I'm trying to encrypt some userData to create my own custom IPrincipal and IIdentity objects using Forms authentication - I've serialized an object representing my logged in user to Json and created my FormsAuthentication ticket like so: string user_item = GetJsonOfLoggedinUser();/*get JSON representation of my logged in user*/ System.Web.Security.FormsAuthenticationTicket ticket = new System.Web.Security.FormsAuthenticationTicket(1, WAM.Utilities.SessionHelper.LoggedInEmployee.F_NAME + " " + WAM.Utilities.SessionHelper.LoggedInEmployee.L_NAME, DateTime.Now, DateTime.Now.AddMinutes(30), false,

How do I customize the Forms Authentication cookie name?

可紊 提交于 2019-12-05 00:32:08
I have 2 websites running on localhost in different ports. As browsers do not differentiate port numbers when sending cookies, my forms authentication ticket from one site is being sent to the other How do I solve this? I thought that a good solution would be to change the forms authentication ticket or one of the websites but I don't know how to do this. In your web.config: <authentication mode="Forms"> <forms name="{WhateverCookieNameYouWant}" loginUrl="LogOn.aspx" /> </authentication> 来源: https://stackoverflow.com/questions/3631617/how-do-i-customize-the-forms-authentication-cookie-name

Best practice to maintain a user id (MVC)

安稳与你 提交于 2019-12-04 23:08:50
问题 I use FormsAuthentication, but I've added a custom MemberShipProvider to validate against a custom User Table. All tables containing "user data" have a idUser column, so I need to maintain the user id in order to present the user with his data. Previously I've used a session variable (ASP.NET Webform), but as I am rewriting the webapplication to MVC, I'd like to ask what is generally considered as the best approach for this. Is session variable still the best place to hold the idUser, or

Spring Security - Authentication not working even the credentials are correct

笑着哭i 提交于 2019-12-04 22:04:27
I am using spring security in my application where I am intercepting some URLs for authentication. Although URL "/securedMapping1" is prompting for user to login by displaying login page, the login, however, is not working. Even if I give the correct credentials, I am going back to login page with "Bad credentials" error by invoking URL for failed authentication i.e, authentication-failure-url="/login?error=true" is called every time regardless of correct/incorrect credentials. Could anyone help me figure out whats going wrong? Below is the code from important files: Web.xml <?xml version="1.0