Loosing roles between two pages ?

博客给出了基于CSLA的应用在Global.asax中的代码,该代码在每个请求时对当前线程进行授权。若会话过期但用户仍有授权Cookie,会强迫用户重新登录,这种情况在IIS回收应用等多种场景下可能发生。

I use this in Global.asax for my CSLA based app:

Private Sub Global_AcquireRequestState(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.AcquireRequestState

     If Not Session("CSLA-Principal") Is Nothing Then
      Thread.CurrentPrincipal = CType(Session("CSLA-Principal"), MyUser)
      HttpContext.Current.User = CType(Session("CSLA-Principal"), MyUser)
    Else
      If Thread.CurrentPrincipal.Identity.IsAuthenticated = True Then
        Web.Security.FormsAuthentication.SignOut()
        Server.Transfer(Request.ApplicationPath + "/Login.aspx")
      End If
    End If

  End Sub

The code after the Else handles the case where the session died but the user
still has an authenticated cookie!
Can happen many ways - IIS recycles the app, etc.

以上代码每个Request都对当前的Thread进行授权,如果发现Session已经过期,但用户仍然有一个被授权的Cookie,则强迫用户重新登录。
这种事情在很多情况下都会发生....

转载于:https://www.cnblogs.com/coollzh/archive/2004/03/31/4713.html

### GitHub Two-Factor Authentication Setup and Configuration For securing accounts, GitHub offers the option to enable two-factor authentication (2FA). This adds an additional layer of security by requiring not only a password but also a second form of verification when signing in. To configure two-factor authentication using GitHub Mobile: - Begin by logging into the GitHub account through either web browser or directly within the GitHub Mobile application. - Navigate to the settings section from the user profile menu. Within this area, select "Security," followed by choosing "Two-factor authentication" as highlighted options[^1]. - Follow on-screen instructions provided by GitHub which will guide through setting up 2FA. During this process, choose between receiving codes via SMS text message or generating them with an authenticator app like Google Authenticator or Microsoft Authenticator; notably, GitHub Mobile can serve as such an authenticator app too. - Once configured, each sign-in attempt requires entering both the password and a code generated by the chosen method. It is advisable to save recovery codes offered during setup securely since these are essential should access be lost to one's phone or if it malfunctions. ```bash # Example command unrelated to 2FA setup but demonstrating use of wget for downloading software packages wget https://download.redis.io/releases/redis-6.2.6.tar.gz ``` --related questions-- 1. How does enabling two-factor authentication improve account security? 2. What steps must users follow after losing their mobile device used for GitHub’s two-factor authentication? 3. Can other applications besides GitHub Mobile function as authenticators for GitHub’s two-factor authentication? 4. In what ways do recovery codes play a role in regaining access to a secured GitHub account post-enabling two-factor authentication?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值