Class UserAuthorizationCache
Represents in-memory cache of the user's authorization/authentication records. Allows to find a user by one of his identities.
Implements
Inherited Members
Namespace: Nevatech.Vsb.Repository.Security
Assembly: Nevatech.Vsb.Repository.dll
Syntax
public sealed class UserAuthorizationCache : IDisposable
Constructors
UserAuthorizationCache()
Initializes an empty instance.
Declaration
public UserAuthorizationCache()
Properties
Current
Gets singleton instance of the cache.
Declaration
public static UserAuthorizationCache Current { get; }
Property Value
Type | Description |
---|---|
UserAuthorizationCache |
ExpirationInterval
Gets or sets the time period indicating how long user's authorization info will be stored in the cache. Default is 20 minutes.
Declaration
public TimeSpan ExpirationInterval { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
FederationClaimIssuer
Gets or sets the optional issuer of the claim used to authenticate user in Federation scenario. If it is set then claim's issuer is validated and identity match is performed by the claim value only. If it is not set then identity match is performed by the claim value and issuer.
Declaration
public string FederationClaimIssuer { get; set; }
Property Value
Type | Description |
---|---|
String |
FederationClaimType
Gets or sets the claim type of the claim used to authenticate user in Federation scenario.
Declaration
public string FederationClaimType { get; set; }
Property Value
Type | Description |
---|---|
String |
IgnoredGroups
Gets collection of Windows groups SIDs that are not accepted for Windows group user authentication and should not be matched.
Declaration
public HashSet<string> IgnoredGroups { get; }
Property Value
Type | Description |
---|---|
HashSet<String> |
MinimumItemsToPurge
Gets or sets the minimum number of items stored in the cache that triggers cache clean up that removes expired items. Default is 100 items.
Declaration
public int MinimumItemsToPurge { get; set; }
Property Value
Type | Description |
---|---|
Int32 |
Methods
Authenticate(String, String, Boolean)
Validates provided user name and password and returns flag indicating that they belong to an active (not disabled) user.
Declaration
public bool Authenticate(string userName, string password, bool portalUser)
Parameters
Type | Name | Description |
---|---|---|
String | userName | User name that needs to be validated. |
String | password | Password that needs to be validated. |
Boolean | portalUser | True if the user being authenticated is Sentinet Developer Portal user, false otherwise. |
Returns
Type | Description |
---|---|
Boolean | True, if credentials belong to an active (not disabled) user. False, otherwise. |
Authorize(ClaimsPrincipal, String, Boolean)
Validates that user is authorized to access Repository Service and adds claims to his identity indicating his access level.
Declaration
public bool Authorize(ClaimsPrincipal principal, string clientAddress, bool portalUser)
Parameters
Type | Name | Description |
---|---|---|
ClaimsPrincipal | principal | User's principal that needs to be authorized. |
String | clientAddress | IP address of the caller. |
Boolean | portalUser | True if the user being authenticated is Sentinet Developer Portal user, false otherwise. |
Returns
Type | Description |
---|---|
Boolean | True, if user is authorized to access Repository Service. False, otherwise. |
Dispose()
Releases internal resources.
Declaration
public void Dispose()
FindByFederatedClaim(ClaimsIdentity)
Finds user authorization information by a claim issued by a federated identity provider.
Declaration
public UserAuthorizationInfo FindByFederatedClaim(ClaimsIdentity claimsIdentity)
Parameters
Type | Name | Description |
---|---|---|
ClaimsIdentity | claimsIdentity | The claims identity for which to find the authorization info. |
Returns
Type | Description |
---|---|
UserAuthorizationInfo | The Nevatech.Vsb.Repository.Security.UserAuthorizationCache.AuthorizationInfo instance if found or null. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the specified |
FindByUserName(String)
Finds user authorization information by name.
Declaration
public UserAuthorizationInfo FindByUserName(string userName)
Parameters
Type | Name | Description |
---|---|---|
String | userName | The name of the user for which to find the authorization info. |
Returns
Type | Description |
---|---|
UserAuthorizationInfo | The Nevatech.Vsb.Repository.Security.UserAuthorizationCache.AuthorizationInfo instance if found or null. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if the specified |