Crowdhandler.NETsdk
1.0.9
dotnet add package Crowdhandler.NETsdk --version 1.0.9
NuGet\Install-Package Crowdhandler.NETsdk -Version 1.0.9
<PackageReference Include="Crowdhandler.NETsdk" Version="1.0.9" />
paket add Crowdhandler.NETsdk --version 1.0.9
#r "nuget: Crowdhandler.NETsdk, 1.0.9"
// Install Crowdhandler.NETsdk as a Cake Addin
#addin nuget:?package=Crowdhandler.NETsdk&version=1.0.9
// Install Crowdhandler.NETsdk as a Cake Tool
#tool nuget:?package=Crowdhandler.NETsdk&version=1.0.9
Crowdhandler .NET SDK
The Crowdhandler .NET SDK provides a simple and efficient way to integrate the Crowdhandler API into your .NET projects.
GateKeeper Class
The GateKeeper class is the core of the Crowdhandler .NET SDK, containing a generic validation API that can be dropped into other projects.
Properties
- string ApiEndpoint: The Crowdhandler API URL.
- string PublicApiKey: The Crowdhandler public API Key.
- string PrivateApiKey: The Crowdhandler private API Key.
- string WaitingRoomEndpoint: The Crowdhandler Waiting room URL.
- string Exclusions: The Crowdhandler Exclusions regular expression.
- string APIRequestTimeout: The Crowdhandler API Request Timeout in seconds.
- string RoomCacheTTL: The Crowdhandler RoomCache Time To Live in seconds.
Constructor
GateKeeper(String publicKey, String privateKey, String apiEndpoint, String waitingRoomEndpoint, String exclusions, String apiRequestTimeout, String roomCacheTTL, String safetyNetSlug)
Initializes a new instance of the GateKeeper class with the provided keys and endpoints. If any value is not provided, it will use the default value or the corresponding configuration value.
Methods
Validate
public virtual ValidateResult Validate(Uri url, String CookieJSON = "", RoomConfig room = null)
Parameters:
- string url: The URL to test.
- CookieJSON: A JSON formatted string containing validation information. If not provided, validation is attempted against parameters provided in the URL query string. Found in cookie named "crowdhandler set by the SDK."
- RoomConfig room: A set of Crowdhandler room configurations. If not provided, these are fetched using your API key via HTTP.
Returns: A ValidateResult object containing the result of the validation and additional data.
ValidateResult Struct
- string Action: The action to be taken ("allow" or "redirect").
- string redirectUrl: The URL to redirect to if the action is "redirect".
- string targetUrl: The target URL for validation.
- bool setCookie: A boolean indicating if a cookie should be set.
- string cookieValue: The value of the cookie to be set.
- string code: The Crowdhandler code.
- string token: The Crowdhandler token.
- bool expired: A boolean indicating if the signature is expired.
ValidateSignature (cookie)
This method validates a signature when only cookie data is available.
public virtual ValidateSignatureResponse ValidateSignature(List<CookieSignature> CandidateSignatures, CookieData cookie, String token, RoomConfig room)
Parameters:
- List<CookieSignature> CandidateSignatures: A list of candidate signatures to validate.
- CookieData cookie: The cookie data to validate. Found in cookie named "crowdhandler" set by the SDK.
- string token: The token to use for validation.
- RoomConfig room: The room configuration to use for validation.
Returns: A ValidateSignatureResponse object with the validation result.
ValidateSignature (url)
This method validates a signature when when URL parameters are available..
public virtual ValidateSignatureResponse ValidateSignature(String Signature, DateTime requested, String token, RoomConfig room)
Parameters:
- string Signature: The signature to validate.
- DateTime requested: The requested timestamp.
- string token: The token to use for validation.
- RoomConfig room: The room configuration to use for validation.
Returns: A ValidateSignatureResponse object with the validation result.
ValidateSignatureResponse Struct
- bool success: Indicates whether the signature is valid or not.
- bool expired: Indicates whether the signature has expired or not.
GetCookieData
This method converts a JSON object into a structured CookieData object.
public virtual CookieData getCookieData(String JSONCookieData)
Parameters:
- string JSONCookieData: The JSON string representing the cookie data. Found in cookie name "crowdhandler" set by the SDK.
Returns:
A CookieData object or null if the input is null or empty.
MatchRoom
This method checks if the provided host and URL path match any of the rooms in the provided room configuration.
public virtual RoomConfig MatchRoom(string host, string path, List<RoomConfig> rooms)
Parameters:
- string host: The hostname.
- string path: The URL path and query string.
- List<RoomConfig> rooms: The list of room configurations.
Returns:
First matched RoomConfig, or null if one could not be found.
IsRoomMatch
This method checks if the provided host and URL path match any of the rooms found via the Crowdhandler API.
public virtual RoomConfig IsRoomMatch(string host, string path)
Parameters:
- string string host: The hostname.
- string path: The URL path and query string.
Returns:
First matched RoomConfig, or null if one could not be found.
GetConfigValue
This method looks up an application configuration value from Web.config or App.config.
protected virtual String getConfigValue(String settingName, Boolean required)
Parameters:
- string settingName: The config value name to look up.
- bool required: The config value name to look up.
Returns:
Config value as a string.
getRoomConfig
This method retrieves a list of room configurations using the GetApiClient method.
public virtual List<RoomConfig> getRoomConfig()
Returns:
Config value as a string.
A List<RoomConfig> containing the room configurations.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5
- Newtonsoft.Json (>= 13.0.1)
- System.Net.Http (>= 4.3.4)
- System.Runtime.Caching (>= 5.0.0)
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.1)
- System.Configuration.ConfigurationManager (>= 6.0.1)
- System.Net.Http (>= 4.3.4)
- System.Runtime.Caching (>= 5.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Crowdhandler.NETsdk:
Package | Downloads |
---|---|
Crowdhandler.MVCSDK
Protect your MVC applications with Crowdhandler |
GitHub repositories
This package is not used by any popular GitHub repositories.