/
SafeSessionAuthenticationModule.cs
37 lines (35 loc) · 1.18 KB
/
SafeSessionAuthenticationModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.IdentityModel.Services;
namespace IMP.Shared
{
public class SafeSessionAuthenticationModule : SessionAuthenticationModule
{
#region private member functions
protected override void OnAuthenticateRequest(object sender, EventArgs eventArgs)
{
try
{
base.OnAuthenticateRequest(sender, eventArgs);
}
catch (InvalidOperationException ex)
{
if (ex.InnerException is System.Security.Cryptography.CryptographicException && ex.Message.StartsWith("ID1073: ")) //Key not valid for use in specified state.
{
//Změna app pool identity, zapamatované přihlášení je neplatné
this.SignOut();
return;
}
throw;
}
catch (FederatedAuthenticationSessionEndingException)
{
this.SignOut();
}
catch (System.IdentityModel.Tokens.SecurityTokenException)
{
this.SignOut();
}
}
#endregion
}
}