UserTokenManager Class

Generic SQL Token generator class that can be used to generate, store and validation user tokens for use in APIs.

Methods can create tokens, store them and then can be validated based on existance and timeout status. Service cleans up expired tokens as part of operations.

Works with SQL Server but can be customized

System.Object
   Westwind.Utilities.Data.Security.UserTokenManager

Class Members

MemberDescription
Constructor
CreateNewToken Adds a new token record into the db and returns the new token id. Parameters map to the modifiable user token table fields, so you can provide initial values.
public string CreateNewToken(string userId, string referenceId, string tokenIdentifier, string scope, string data)
CreateUserTokenSqlTable Creates the UserToken Sql Server table in the specified connection. Uses the current 'Tablename' property to determine the table Default implementation creates table for SQL Server
public bool CreateUserTokenSqlTable()
DeleteExpiredTokens Deletes a token by its token id
public bool DeleteExpiredTokens()
DeleteToken Deletes a token by its token id
public bool DeleteToken(string userTokenId)
DeleteTokenForUserId Deletes a token by its token id
public bool DeleteTokenForUserId(string userId)
GetToken Retrieves the full token based on the id
public UserToken GetToken(string tokenId, bool checkForExpiration, bool renewLease)
GetTokenByTokenIdentifier Returns a token based on a Token Identifier. This is useful in non-Web auth scenarios where you can check for the token being validated based on a token identifier. Expired tokens are not returned…
public UserToken GetTokenByTokenIdentifier(string tokenIdentifier, bool dontRemoveTokenIdentifier)
IsTokenValid Check to see if a token is valid
public bool IsTokenValid(string tokenId, bool renewLease)
IsUserTokenTable Check to see if hte user token table exists
public bool IsUserTokenTable()
SetError
public void SetError()
AllowMultipleTokensPerUser If true won't check if a token already exists for a given user. If false only one token per user is allowed.
ErrorMessage
Tablename
TokenServerConnectionString Sql Connection String (Sql Server)
TokenTimeoutSeconds The duration that a token is valid for in seconds
Namespace: Westwind.Utilities.Data.Security

Assembly: Westwind.Utilities.Data.dll