Skip to content

Commit

Permalink
Add Verify SSL config (#103)
Browse files Browse the repository at this point in the history
* first pass

* reverting strawberryshake changes

Co-authored-by: Nathanael Shim <[email protected]>
  • Loading branch information
nateshim-indico and Nathanael Shim authored Oct 20, 2022
1 parent acc5141 commit 71f4d93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion IndicoV2.StrawberryShake/IndicoStrawberryShakeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class IndicoStrawberryShakeClient
{
private readonly ServiceProvider _services;

public IndicoStrawberryShakeClient(Uri baseUri, Uri graphQlEndpoint, string token)
public IndicoStrawberryShakeClient(Uri baseUri, Uri graphQlEndpoint, string token, bool verify)
{
var serviceCollection = new ServiceCollection();
serviceCollection
Expand Down
15 changes: 10 additions & 5 deletions IndicoV2/IndicoClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,42 @@ public class IndicoClient : IIndicoClient
private const string _defaultUrl = "https://app.indico.io";

internal readonly string _apiToken;

private Indico.IndicoClient _legacyClient;

internal Uri BaseUri { get; }
private readonly Uri _graphQl = new Uri("graph/api/graphql", UriKind.Relative);
private readonly Uri _graphQl = new Uri("graph/api/graphql", UriKind.Relative);

internal readonly bool _verifySsl;

internal Indico.IndicoClient LegacyClient =>
_legacyClient ?? (_legacyClient =
new Indico.IndicoClient(new IndicoConfig(host: BaseUri.Host, apiToken: _apiToken)));
new Indico.IndicoClient(new IndicoConfig(host: BaseUri.Host, apiToken: _apiToken, verify: _verifySsl)));

private IndicoStrawberryShakeClient _indicoStrawberryShakeClient;

internal IndicoStrawberryShakeClient IndicoStrawberryShakeClient =>
_indicoStrawberryShakeClient
?? (_indicoStrawberryShakeClient = new IndicoStrawberryShakeClient(BaseUri, _graphQl, _apiToken));
?? (_indicoStrawberryShakeClient = new IndicoStrawberryShakeClient(BaseUri, _graphQl, _apiToken, _verifySsl));

/// <summary>
/// Creates IndicoClient for <inheritdoc cref="_defaultUrl"/>
/// </summary>
/// <param name="apiToken">Authentication token (You can generate one at <c>https://app.indico.io/auth/account</c>)</param>
public IndicoClient(string apiToken) : this(apiToken, new Uri(_defaultUrl))
public IndicoClient(string apiToken, bool verify = true) : this(apiToken, new Uri(_defaultUrl), verify)
{ }

/// <summary>
/// Creates IndicoClient
/// </summary>
/// <param name="apiToken">Authentication token (You can generate one at <c>https://app.indico.io/auth/account</c>)</param>
/// <param name="baseUri">indico.io base address (Default values is <c>https://app.indico.io</c>)</param>
public IndicoClient(string apiToken, Uri baseUri)
/// <param name="verify">verify the host's SSL certificate (Default value is <c>true</c>)</param>
public IndicoClient(string apiToken, Uri baseUri, bool verify = true)
{
_apiToken = apiToken ?? throw new ArgumentNullException(nameof(apiToken));
BaseUri = baseUri ?? throw new ArgumentNullException(nameof(baseUri));
_verifySsl = verify;
}
}
}

0 comments on commit 71f4d93

Please sign in to comment.