Terminating a User Session (Expiring a Token)
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
The latest Enterprise Library information can be found at the Enterprise Library site. |
An example of when you may want to expire a token is when a user logs out to make sure that the token cannot be used by an attacker. You can also use the approach described here to expire a user principal or a user identity.
Typical Goals
In this scenario, the goal is to make sure that the token corresponding to a user identity is expired.
Solution
Call the ExpireIdentity method on the security cache object.
QuickStart
For an extended example of how to use the ExpireIdentity method to expire a token corresponding to a user identity, see Walkthrough: Terminate a User Session.
Using ExpireIdentity
The following code shows how to use the ExpireIdentity method.
ISecurityCacheProvider cache = SecurityCacheFactory.GetSecurityCacheProvider("Caching Store Provider");
// Cache the identity.
IToken token = cache.SaveIdentity(new GenericIdentity("Username"));
// Expire the identity.
cache.ExpireIdentity(token);
'Usage
SecurityCacheFactory.GetSecurityCacheProvider("Caching Store Provider")
' Cache the identity.
Dim token As IToken = cache.SaveIdentity(New GenericIdentity("Username"))
' Expire the identity.
cache.ExpireIdentity(token)
Usage Notes
Alternately, you can use the ExpirePrincipal or ExpireProfile methods to remove the principal or profile information associated with a token from the cache.
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
The latest Enterprise Library information can be found at the Enterprise Library site. |