Skip to content

Commit

Permalink
Merge pull request #20 from flo0705/main
Browse files Browse the repository at this point in the history
make serializer configurable
  • Loading branch information
lvermeulen authored Sep 2, 2020
2 parents ac977cc + fc02f70 commit 44a74df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Keycloak.Net/KeycloakClient.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Keycloak.Net
{
public partial class KeycloakClient
{
private static readonly ISerializer s_serializer = new NewtonsoftJsonSerializer(new JsonSerializerSettings
private ISerializer _serializer = new NewtonsoftJsonSerializer(new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore
Expand Down Expand Up @@ -39,9 +39,14 @@ public KeycloakClient(string url, Func<string> getToken)
_getToken = getToken;
}

public void SetSerializer(ISerializer serializer)
{
_serializer = serializer ?? throw new ArgumentNullException(nameof(serializer));
}

private IFlurlRequest GetBaseUrl(string authenticationRealm) => new Url(_url)
.AppendPathSegment("/auth")
.ConfigureRequest(settings => settings.JsonSerializer = s_serializer)
.ConfigureRequest(settings => settings.JsonSerializer = _serializer)
.WithAuthentication(_getToken, _url, authenticationRealm, _userName, _password);
}
}
2 changes: 1 addition & 1 deletion src/Keycloak.Net/RolesById/KeycloakClient.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task<bool> RemoveRolesFromCompositeAsync(string realm, string roleI
{
var response = await GetBaseUrl(realm)
.AppendPathSegment($"/admin/realms/{realm}/roles-by-id/{roleId}/composites")
.SendJsonAsync(HttpMethod.Delete, new CapturedJsonContent(s_serializer.Serialize(roles)))
.SendJsonAsync(HttpMethod.Delete, new CapturedJsonContent(_serializer.Serialize(roles)))
.ConfigureAwait(false);
return response.IsSuccessStatusCode;
}
Expand Down

0 comments on commit 44a74df

Please sign in to comment.