Skip to content

Commit

Permalink
Update the readme and config
Browse files Browse the repository at this point in the history
  • Loading branch information
marysieek committed Sep 30, 2020
1 parent e30f251 commit fb8130b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void ConfigureServices(IServiceCollection services)
The `CastleConfiguration` object has a number of properties that control the SDK.

Property | Default | Description
--- | --- | ---
--- | --- | ---
ApiSecret | | Secret used to authenticate with the Castle Api. ***Required***
FailoverStrategy | Allow | The response action to return in case of a failover in an Authenticate request.
Timeout | 1000 | Timeout for requests, in milliseconds.
Expand All @@ -62,6 +62,10 @@ AllowList | | List of headers that should be passed intact to the API. A list of
DenyList | | List of header that should *not* be passed intact to the API.
DoNotTrack | false | If true, no requests are actually sent to the Caste Api, and Authenticate returns a failover response.
Logger | | Your own logger implementation.
IpHeaders | | IP Headers to look for a client IP address
TrustedProxies | | Trusted public proxies list
TrustedProxyDepth | 0 | Number of trusted proxies used in the chain
TrustProxyChain | false | Is trusting all of the proxy IPs in X-Forwarded-For enabled

## Logging
The 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`.
Expand Down Expand Up @@ -144,7 +148,7 @@ var verdict = await castleClient.Authenticate(new ActionRequest()

#### Response format

| Property | Description
| Property | Description
| --- | ---
| Action | The recommended action for the given event.
| UserId | The `UserId` of the end user that was provided in the request.
Expand Down Expand Up @@ -175,7 +179,7 @@ If no failover strategy is set (i.e. `None`), a `Castle.Infrastructure.Exception
| Option | Description
| --- | ---
| Ip | The IP address of the request. Note that this needs to be the original request IP, not the IP of an internal proxy, such as nginx.
| ClientId | The client ID, generated by the `c.js` integration on the front end. Commonly found in the `__cid` cookie in `Request.Cookies`, or in some cases the `X-CASTLE-CLIENT-ID` header.
| ClientId | The client ID, generated by the `c.js` integration on the front end. Commonly found in the `__cid` cookie in `Request.Cookies`, or in some cases the `X-CASTLE-CLIENT-ID` header.
| Headers | Headers mapped from the the original request (most likely `Request.Headers`).

You can call `Castle.Context.FromHttpRequest(request)` to get a ready-made `RequestContext` instance from your current request.
Expand All @@ -186,7 +190,7 @@ public class HomeController : Controller
{
public ActionResult Index()
{
var actionRequest = new ActionRequest()
var actionRequest = new ActionRequest()
{
Context = Castle.Context.FromHttpRequest(Request)
...
Expand All @@ -202,7 +206,7 @@ public class IndexModel : PageModel
{
Context = Castle.Context.FromHttpRequest(Request)
...
```
```



Expand Down
4 changes: 2 additions & 2 deletions src/Castle.Sdk/Config/CastleConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public CastleConfiguration(string apiSecret)
/// <summary>
/// Number of trusted proxies used in the chain
/// </summary>
public int TrustedProxyDepth { get; set; }
public int TrustedProxyDepth { get; set; } = 0;

/// <summary>
/// Is trusting all of the proxy IPs in X-Forwarded-For enabled
/// </summary>
public bool TrustProxyChain { get; set; }
public bool TrustProxyChain { get; set; } = false;

/// <summary>
/// If true, no requests are actually sent to the Castle Api, and Authenticate returns a failover response
Expand Down

0 comments on commit fb8130b

Please sign in to comment.