{"id":19745160,"url":"https://github.com/castle/castle-dotnet","last_synced_at":"2025-06-29T07:37:25.365Z","repository":{"id":34299341,"uuid":"173712303","full_name":"castle/castle-dotnet","owner":"castle","description":"C# / .NET bindings for Castle","archived":false,"fork":false,"pushed_at":"2024-05-15T15:58:57.000Z","size":134,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":13,"default_branch":"develop","last_synced_at":"2025-05-27T12:18:01.380Z","etag":null,"topics":["csharp","dotnet","fraud-detection","fraud-prevention","sdk"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/castle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-04T09:16:23.000Z","updated_at":"2024-05-15T15:54:45.000Z","dependencies_parsed_at":"2024-05-14T11:31:55.144Z","dependency_job_id":"8d63adf3-551b-4e72-be47-2646d67d31cf","html_url":"https://github.com/castle/castle-dotnet","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/castle/castle-dotnet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castle%2Fcastle-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castle%2Fcastle-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castle%2Fcastle-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castle%2Fcastle-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/castle","download_url":"https://codeload.github.com/castle/castle-dotnet/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/castle%2Fcastle-dotnet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262558454,"owners_count":23328534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","fraud-detection","fraud-prevention","sdk"],"created_at":"2024-11-12T02:04:28.867Z","updated_at":"2025-06-29T07:37:25.347Z","avatar_url":"https://github.com/castle.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# .NET SDK for Castle\n\n[![Build status](https://ci.appveyor.com/api/projects/status/rf0304hhym6k7d7s/branch/master?svg=true)](https://ci.appveyor.com/project/DevTools/castle-dotnet)\n[![NuGet](https://img.shields.io/nuget/v/castle.sdk.svg)](https://www.nuget.org/packages/Castle.Sdk/)\n[![Coverage Status](https://coveralls.io/repos/github/castle/castle-dotnet/badge.svg?branch=master)](https://coveralls.io/github/castle/castle-dotnet?branch=master)\n\nSupporting **.NET 6.0**, **.NET 5.0**, **.NET Core 3.0**, **.NET Standard 2.0** and **.NET Framework 4.6.1+**. Refer to Microsoft's [documentation](https://docs.microsoft.com/en-us/dotnet/standard/net-standard) for compatibility information.\n\n**[Castle](https://castle.io) analyzes user behavior in web and mobile apps to stop fraud before it happens.**\n\n## Usage\n\nSee the [documentation](https://docs.castle.io) for how to use this SDK with the Castle APIs\n\n## Installation\n\nInstall the `Castle.Sdk` nuget.\n\n### Command line\n\n    nuget install Castle.Sdk\n\n### Packet Manager Console\n\n    install-package Castle.Sdk\n\n### Visual Studio\n\n1. Go to Tools -\u003e Package Manager -\u003e Manage NuGet Packages for Solution...\n2. Click the Browse tab and search for `Castle.Sdk`\n3. Click the `Castle.Sdk` package in the search results, select version and what projects to apply it to on the right side, and click Install\n\n## Configuration\n\nGo to the settings page of your Castle account and find your **API Secret**. Use it to create a new instance of the `CastleClient` class.\n\n```csharp\nvar client = new CastleClient(\"YOUR SECRET\");\n```\n\nIt's a good idea to set up your `CastleClient` instance using an IoC container.\n\n### asp\u0026#46;net core\n\n```csharp\npublic void ConfigureServices(IServiceCollection services)\n{\n    ...\n\n    services.AddSingleton(new CastleClient(new CastleConfiguration(\"YOUR SECRET\")));\n}\n```\n\nThe `CastleConfiguration` object has a number of properties that control the SDK.\n\n| Property          | Default               | Description                                                                                                                                                             |\n| ----------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| ApiSecret         |                       | Secret used to authenticate with the Castle Api. **_Required_**                                                                                                         |\n| FailoverStrategy  | Allow                 | The response action to return in case of a failover in an Authenticate request.                                                                                         |\n| Timeout           | 1000                  | Timeout for requests, in milliseconds.                                                                                                                                  |\n| BaseUrl           | https://api.castle.io | Base Castle Api url.                                                                                                                                                    |\n| LogLevel          | Error                 | The log level applied by the injected `ICastleLogger` implementation.                                                                                                   |\n| AllowList         |                       | List of headers that should be passed intact to the API. A list of recommended .headers can be retrieved from the static property `Castle.Headers.AllowList` in the SDK |\n| DenyList          |                       | List of header that should _not_ be passed intact to the API.                                                                                                           |\n| DoNotTrack        | false                 | If true, no requests are actually sent to the Caste Api, and Authenticate returns a failover response.                                                                  |\n| Logger            |                       | Your own logger implementation.                                                                                                                                         |\n| IpHeaders         |                       | IP Headers to look for a client IP address                                                                                                                              |\n| TrustedProxies    |                       | Trusted public proxies list                                                                                                                                             |\n| TrustedProxyDepth | 0                     | Number of trusted proxies used in the chain                                                                                                                             |\n| TrustProxyChain   | false                 | Is trusting all of the proxy IPs in X-Forwarded-For enabled                                                                                                             |\n\n## Logging\n\nThe SDK allows customized logging by way of implementing the `ICastleLogger` interface and passing in an instance as part of the `CastleConfiguration`. Exactly what gets logged can be controlled by setting the `LogLevel` property of `CastleConfiguration`.\n\n```csharp\nvar client = new CastleClient(new CastleConfiguration(\"secret\") {\n    Logger = new MyLogger()\n});\n```\n\n### Logger example\n\n```csharp\npublic class DebugLogger : ICastleLogger\n{\n    public void Info(string message)\n    {\n        Debug.WriteLine($\"INFO: {message}\");\n    }\n\n    public void Warn(string message)\n    {\n        Debug.WriteLine($\"WARNING: {message}\");\n    }\n\n    public void Error(string message)\n    {\n        Debug.WriteLine($\"ERROR: {message}\");\n    }\n}\n```\n\n##### ASP\u0026#46;NET MVC 5\n\n```csharp\npublic class HomeController : Controller\n{\n    public ActionResult Index()\n    {\n        var actionRequest = new ActionRequest()\n        {\n            Context = Castle.Context.FromHttpRequest(Request)\n            ...\n```\n\n##### ASP\u0026#46;NET Core\n\n```csharp\npublic class IndexModel : PageModel\n{\n    public void OnGet()\n    {\n        var actionRequest = new ActionRequest()\n        {\n            Context = Castle.Context.FromHttpRequest(Request)\n            ...\n```\n\n## Troubleshooting\n\n### Can't find System.Runtime.InteropServices.RuntimeInformation\n\nYou target .NET Framework and get an exception on startup.\n\n`System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.`\n\nThe Castle SDK has a dependency on [Sentry.PlatformAbstractions](https://www.nuget.org/packages/Sentry.PlatformAbstractions/), which in turn uses `System.Runtime.InteropServices.RuntimeInformation`, version 4.3.0.\n\n#### Solution\n\nFind the binding redirect for `System.Runtime.InteropServices.RuntimeInformation` in `web.config` and either remove the entire `dependentAssembly` element, or update `newVersion` to 4.3.0.\n\n# Demo application\n\nThere is a sample application using ASP\u0026#46;NET Core Razor Pages and this SDK [here](https://github.com/castle/dotnet-example).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcastle%2Fcastle-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcastle%2Fcastle-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcastle%2Fcastle-dotnet/lists"}