Giter VIP home page Giter VIP logo

fusionauth-netcore-client's Introduction

FusionAuth .NET Core Client

semver 2.0.0 compliant

If you're integrating FusionAuth with a .NET Core application, this library will speed up your development time.

Here's a small Example showing how to use this client: Example.cs

For additional information and documentation on FusionAuth refer to https://fusionauth.io.

https://www.nuget.org/packages/FusionAuth.Client/

Refer to the FusionAuth API documentation for request and response formats.

Supported Frameworks

  • .NET Standard 2.0, 2.1
  • .NET Core 2.1, 3.1
  • .NET 5
  • .NET 6
  • .NET 7 (tested with rc.1)

Tests

There are some tests. Most require a running FusionAuth instance.

To run them:

  • cd fusionauth-netcore-client-test/fusionauth-netcore-client-test
  • dotnet build && dotnet test # or, to run only a few
  • dotnet build && dotnet test --filter CorrectlyD

Testing locally

If you want to test a build of this library locally, you can use this answer from SO after compiling it.

Pull this repo and update usermanager.csproj. Replace <PackageReference Include="FusionAuth.Client" Version="1.42.0" /> with a path to your complied .csproj file.

Here's what my usermanager.csproj <ItemGroup> looked like during testing:

<ItemGroup>
  <ProjectReference Include="/path/to/fusionauth-netcore-client/fusionauth-netcore-client/fusionauth-netcore-client.csproj" />
  <PackageReference Include="JSON.Net" Version="1.0.18" />
</ItemGroup>

Questions and support

If you have a question or support issue regarding this client library, we'd love to hear from you.

If you have a paid edition with support included, please open a ticket in your account portal. Learn more about paid editions here.

Otherwise, please post your question in the community forum.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/FusionAuth/fusionauth-netcore-client.

If you find an issue with syntax, etc - this is likely a bug in the template. Feel free to submit a PR against the Client Builder project.

License

The code is available as open source under the terms of the Apache v2.0 License.

Upgrade Policy

This library is built automatically to keep track of the FusionAuth API, and may also receive updates with bug fixes, security patches, tests, code samples, or documentation changes.

These releases may also update dependencies, language engines, and operating systems, as we'll follow the deprecation and sunsetting policies of the underlying technologies that it uses.

This means that after a dependency (e.g. language, framework, or operating system) is deprecated by its maintainer, this library will also be deprecated by us, and will eventually be updated to use a newer version.

fusionauth-netcore-client's People

Contributors

asimmon avatar epbensimpson avatar eprenaud avatar fusionandy avatar lukevp avatar matthew-altman avatar mooreds avatar robfusion avatar robotdan avatar trex avatar tyduptyler13 avatar vcampitelli avatar voidmain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fusionauth-netcore-client's Issues

DeactivateUsersByIdsAsync should default to using a POST body

When calling client.DeactivateUsersByIdsAsync, FusionAuth will default to sending this request using queryParams as in

DELETE /api/user/bulk?userId={userId}&userId={userId}&userId={userId}&userId={userId}&userId={userId}&userId={userId}&userId={userId}&userId={userId}

It should default to sending this request using a POST body as in:

DELETE /api/user/bulk

with the following example POST body:

{
  "dryRun": true,
  "hardDelete": false,
  "userIds": [
    "5c1dc1a8-2fc8-4ae0-9372-e994be0f4341",
    "dbf59ee1-2d24-4ea0-b977-2b6e2a5350bf",
    "3e74294d-7de7-45a4-9592-4a198ddbdc73",
    "cfaf34a0-aa66-4d3a-af14-6dbc5f9fb577",
    "a2eb9268-e6f1-45f4-8eaa-50c0154983fe",
    "b1b42d6b-3b44-47fb-bb32-26e0c71c62d3",
    "8c91cb08-27df-4725-b3a8-98631bc8d9af",
    "54df878b-c0a1-4951-a63a-3cf2f97edd17",
    "946b3deb-25a5-4155-b137-bb5202d2ac98"
  ]
}

This change will allow for larger requests.

Related documentation and API:

Internal: original reporting issue

Patch_Application_Test sporadically fails.

When run alone it works fine. When run with collection of tests, fails randomly. I think this has to do with the fact that test are run async and this test for some settings in an application that is created my many tests.

CancelAction method returning field error

I'm having an issue with canceling action using .net core client. (version 1.10.0). (we have v1.10.1 FusionAuth)

The user action I'm trying to delete is Failed Login Attempt action which blocks the user from logging in.

The response I get for calling CancelAction is

StatusCode 400

Field Error
Code [missing]action
Your request is missing the Action information as JSON in the entity-body.

Below is the code that

 var actionRequest = new ActionRequest()
                        {
                            broadcast = false,
                            action = new ActionData()
                            {
                                action = userActionResponse.successResponse.userAction,
                                userActionId = userActionResponse.successResponse.userAction.id,
                                actionerUserId = userId,
                                actioneeUserId = userId,
                                option = userActionLog.option,
                                applicationIds = userActionLog.applicationIds,
                                log = userActionLog,
                                actionee = user.successResponse.user,
                                actioner = user.successResponse.user,//actioner.successResponse.user,
                                expiry = userActionLog.expiry,
                                notifyUser = false,
                                comment = "Admin user has removed the login prevention user action",
                                emailUser = false,
                                reason = userActionReasonResponse.successResponse.userActionReason,
                                reasonId = userActionReasonResponse.successResponse.userActionReason.id
                            }
                        };
                        var deleteStatus = client.CancelAction(userActionLog.id, actionRequest);

I've tried calling the API using Postman and that seems to cancel the action fine so I'm guessing it's more to do with the .net core client. (or possibly the object I'm sending)

Could you please take a look at this issue? Thanks

Support for CancellationToken

Hello!

I've been using this library, specifically the async bits, and I've found that none of them take a CancellationToken so that when a request is cancelled (e.g. user closes the tab in ASP.NET Core) the work being done by the library can be cancelled as well.

Without this, once the FusionAuth client starts processing a request, it will complete the work anyway, eating up server resources for unneeded results.

Is this something that's feasible to be added to this library?

The "global" parameter does not work when logging out

Howdy ๐Ÿ‘‹

When I try to logout a user with the logout method, I receive an HTTP 400 error when I pass the global parameter.

This code returns an HTTP 200 as expected

await _client.LogoutAsync(null, token);

This code returns an HTTP 400

await _client.LogoutAsync(true, token);

The details of the error is

message: Invalid
code: [couldNotConvert]global

In example application, response returns status codes, not more full featured objects

Here's the relevant section of the example code
https://github.com/FusionAuth/fusionauth-netcore-client/blob/master/fusionauth-netcore-client-test/fusionauth-netcore-client-test/test/io/fusionauth/Example.cs

  public User GetUserByEmail(string email) {
      var response = client.RetrieveUserByEmail("[email protected]");

      if (response.WasSuccessful()) {
        var user = response.successResponse.user;
        return user;
      }
      if (response.errorResponse != null) {
        // Error Handling
        var errors = response.errorResponse;
        return null;
      }
      if (response.exception != null) {
        // Exception Handling
        var exception = response.exception;
        return null;
      }
      return null;
    }

However, if you serialize the response object, you see that the status code is returned, not the exception or errorResponse objects.

using Newtonsoft.Json;
//...
string json = JsonConvert.SerializeObject(response);

If I pass the wrong API key, I get this response when I print the JSON:

{"statusCode":401}

And if I pass an email address which does not exist in my fusion auth databse, I get this message:

{"statusCode":404}

So, I'd suggest either wrapping these error codes in the error objects provided, or changing the example app code to be:

   else if (response.statusCode != 200)
            {
                // Exception Handling
                var statusCode = response.statusCode;
                return null;
            }

Here's my software versions:

FA: 1.15.5
FusionAuth.Client (from .csproj): 1.15.7
Target .NET framework: netcoreapp3.1

Unable to access two factor secret once the new user is registered

Hello,

I'm using FusionAuth to securize my application but I have a problem when registering a user.
When I'm registering a user I'm generating a secret through the API and store it in the corresponding property.

var secretResponse = await _client.GenerateTwoFactorSecretAsync();
if (!secretResponse.WasSuccessful()) throw new Exception("Couldn't generate secret");
var data = new Dictionary<string, object>
{
  { "SecretBase32Encoded", secretResponse.successResponse.secretBase32Encoded }
};
var faUser = new User{
  username = username,
  email = email,
  password = password,
  firstName = fName,
  lastName = lName,
  fullName = $"{fName} {lName}",
  id = newUserId,
  twoFactorEnabled = true,
  twoFactorSecret = secretResponse.successResponse.secretBase32Encoded,
  data = data
};

The registration is going well but when I try to access the secret by getting the user through this then the secret is null.

var userResponse = await _client.RetrieveUserByLoginIdAsync(request.loginId)
if (!userResponse.WasSuccessful())
  throw new Exception("Couldn't retrieve user");
userResponse.successResponse.user.twoFactorSecret // IS NULL

For now I'm found a work around by storing the secret into the user data but I was curious to know if there was a better solution.

Thanks again and best regards

Importing a user without a password

About half of our users don't have passwords set as they are authenticated via third party ID providers such as Google. While importing users from an existing system, I'm not setting anything for password and salt fields, which is causing the import to throw You must specify the [user.password] property for each user. error (using the FA's .net client). What would I set for password and salt in this case? Thank you!

Remove dep on NewtonSoft JSON and use System.Text.Json instead

Description

See this comment #13 (comment)

Thanks to @ukevp for this suggestion:

Another standardization thing you might consider is your current use of newtonsoft.json. The history of that library is pretty interesting. It's one of the top libraries in the .net ecosystem. The original developer, James King, wrote the library independently, but later was hired by Microsoft. He works on the team that built System.Text.Json, which is the official successor, included in ASP.NET Core, and is faster than the old library. So you may consider taking a dependency on that library instead, it is compatible with all the versions that this library is targeting as well. I'm not sure what effort it would be to migrate to it though so that would be up to you if it was worth the effort to do that now.

Here's the library: https://www.nuget.org/packages/System.Text.Json

I think this is a nice-to-have, and I don't know the level of effort to do this - we have some custom configuration currently that we'd have to re-work into the new method.

Why fields instead of properties?

This issue partially relates to #21: "It's very clear you guys are Java developers. Lowercase properties, reverse-domain namespaces. To a .Net developer, this feels really gross to work with."

Recommendation:

  • Models and API Client should use properties for public members

Issues with Patch commands

I think there is an issue with the Patch commands. In the client for example in the patchRegistration method it is expecting an IDictionary<string, object> for the request parameter but the Rest API according to the documentation is expecting a JSON which seems to be the RegistrationRequest type.

From what I can see the issue comes from the Client Builder in the _macros.ftl file. In that file is this code

[#elseif language == "csharp"] [#local convertedType = convertType(param.javaType, language)/] [#if api.method == "patch" && param.javaType?ends_with("Request")] [#local convertedType = "IDictionary<string, object>"/] [/#if] [#local result = result + [convertedType + " " + param.name]/]

This changes what appears to be the correct type in the builder json files to an IDictonary. I think this may need to be removed.

Exception "The format of value 'xxx' is invalid." when api key contains character "="

We generated a new API key and it happens to have the character "=" at the end. When i try to make an API call using the client i get this exception before the api call is even made:

The format of value '{my api key here}' is invalid.
   at System.Net.Http.Headers.HttpHeaderParser.ParseValue(String value, Object storeValue, Int32& index)
   at System.Net.Http.Headers.HttpHeaders.ParseAndAddValue(HeaderDescriptor descriptor, HeaderStoreItemInfo info, String value)
   at System.Net.Http.Headers.HttpHeaders.Add(HeaderDescriptor descriptor, String value)
   at System.Net.Http.Headers.HttpHeaders.Add(String name, String value)
   at io.fusionauth.DefaultRESTClient.baseRequest()
   at io.fusionauth.DefaultRESTClient.goAsync[T]()
   at io.fusionauth.FusionAuthClient.RetrieveUserAsync(Nullable`1 userId)

I tested the call using the generated api key using Postman and it works.

Exemple code to reproduce the error :

var fusionAuthClient = new FusionAuthClient("MyApiKeyHere=", fusionAuthOptions.ApiUrl, fusionAuthOptions.TenantId);
var response = fusionAuthClient.RetrieveUserAsync(Guid.Empty);

Cannot import a certificate

When calling _client.ImportKeyAsync with a certificate, I receive an HTTP 400 indicating that I should not set a 'type' to import a certificate (which I did not).

The issue is that, in C#, enum are just ints and are therefore not nullable. The default value is the enum associated with the 0 value. A PR is underway to fix this issue.

No JSON Response Body when Login with 2FA

No JSON Response Body when Login with 2FA

Description

I have enabled 2FA for one of the test users.
Now when I try to perform the login using the FusionAuthClient.Login(LoginRequest) method, all I see is the response with code 242 but no twoFactorId

Expected behavior

After performing the Login, I should get the twoFactorId for performing the 2FA

Screenshots

image

Platform

  • Server: IIS Express, .Net Core
  • OS: Windows 10
  • Browser + version: Microsoft Edge (Insider)

Additional context

As seen in the screenshot, the statusCode is 242 but there are no additional data provided.

Patch doesn't output correct JSON

Is there any description available on how to use these PATCH function(s)?

Not sure if I should report any issues here, but when calling a method like PatchApplication from the Netcore client, the JSON isn't wrapped correctly with application { }.
According to the API (https://fusionauth.io/docs/v1/tech/apis/applications#update-an-application), it should be the same like the PUT request:

When using the PATCH method, use the same request body documentation that is provided for the PUT request.

The client code only passes the keys/values, but doesn't wrap it in the correct request body:

public ClientResponse<ApplicationResponse> PatchApplication(Guid? applicationId, Dictionary<string, object> request) {
      return buildClient()
          .withUri("/api/application")
          .withUriSegment(applicationId)
          .withJSONBody(request)
          .withMethod("Patch")
          .go<ApplicationResponse>();
    }

Calling this method with the following:

var request = new Dictionary<string, object> {
  { "passwordlessConfiguration", false },
  { "registrationConfiguration", true }
};
client.PatchApplication(applicationId, request);

Will result in the following incorrect JSON:

{
  "passwordlessConfiguration": {
    "enabled": false
  },
  "registrationConfiguration": {
    "enabled": true
  }
}

The correct expected JSON should be:

{
  "application": {
    "passwordlessConfiguration": {
      "enabled": false
    },
    "registrationConfiguration": {
      "enabled": true
    }
  }
}

Issues with Patch support

When Patch support was added it looks like we broke compatibility with the lowest version of .NET.

We are currently supporting netcoreapp2.0, netcoreapp2.1, netcoreapp2.2, netstandard2.0 - I don't know if that is the problem or not, but it looks like the PatchAsync method is not available in our current dependency version of of System.Net.Http.

The project wasn't building due to some syntax errors and this dependency issue. Perhaps we have an issue in our build and release - I don't know how it would have been packed and published as is.

I think the PatchSync wasn't added until 2.1
https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.patchasync?view=netcore-2.1

We'll either have to upgrade our min target or add a poly fill, or remove Patch support in this client.
https://stackoverflow.com/questions/26218764/patch-async-requests-with-windows-web-http-httpclient-class/26218765#26218765

We need to ensure we all have IJ Rider or other C# editor installed so we can review changes for syntax errors and compile issues, etc.

Incorrect handling of URL Parameters

I'm trying to call IFusionAuthAsyncClient.SearchUsersByIdsAsync(List<string> ids) but if say i give the id's a list containing:
["1a4a9247-2b9d-45d2-ae1e-4714756b5a58","5a1505df-677e-44e3-9c09-d858087eac7b"]

This results in an exception:

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
   at async Task<IEnumerable<UserDto>> HeroBalancer.Repo.Stores.FusionAuth.FusionAuthUserStore.ReadByIds(Guid[] ids) in /build/src/Repo/Stores/FusionAuth/FusionAuthUserStore.cs:line 73

In FusionAuth, there is a very unhelpful error message which doesnt tell me much about the issue:
java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

Eventually, i find in our Nginx-Ingress-Controller logs, the request that was actually made:

2020-06-03 11:33:32 | 10.244.1.219 - - [03/Jun/2020:09:33:32 +0000] "GET /api/user/search?ids=System.Collections.Generic.List%601[System.String] HTTP/1.1" 400 1985 "-" "-" 367 0.003 [default-fusionauth-80] [] 10.244.0.159:9011 1985 0.004 400 f6eaaa076541fc2a1d196711554fb795

Here you can see the ids parameter has been serialized incorrectly. According to the API documentation at https://fusionauth.io/docs/v1/tech/apis/users#search-for-users
this should be serialised as so:
ids=1a4a9247-2b9d-45d2-ae1e-4714756b5a58&ids=5a1505df-677e-44e3-9c09-d858087eac7b

Patch Registration Issue

Hi,

I'm having an issue Patching a Registration.

{ "registration":{ "applicationId": "9d830621-2853-404f-9e11-47167fb643cf", "data": { "MMConnector" : { "value1" : "abc", "value2" : "test" } } } }

I'm using the above JSON in the call and after the call to the registration with the PATCH method the registration no longer has a Username, Language or Roles.

As far as I know the Patch should only update the values provided and to remove a value you need to pass that in the JSON and set it to null.

The same process seems to work OK on Patching an Application from what I can tell. So what is going wrong with the patching of the Registration?

Missing fields in token from login user response.

Hello.

When calling the API directly from Postman on the login endpoint, the token in the response has some additional fields compared to the token one receives via using the library. The important one for us is the "aud" parameter. Is there a way to include the "aud" parameter in the Jwt token in the successResponse of the client.

GenerateEmailVerificationIdAsync Does not generate an Email VerificationId and does not correspond to Documentation

/// <summary>
/// Generate a new Email Verification Id to be used with the Verify Email API. This API will not attempt to send an
/// email to the User. This API may be used to collect the verificationId for use with a third party system.
/// This is an asynchronous method.
/// </summary>
/// <param name="email"> The email address of the user that needs a new verification email.</param>
/// <returns>
/// When successful, the response will contain the log of the action. If there was a validation error or any
/// other type of error, this will return the Errors object in the response. Additionally, if FusionAuth could not be
/// contacted because it is down or experiencing a failure, the response will contain an Exception, which could be an
/// IOException.
/// </returns>
Task<ClientResponse<VerifyEmailResponse>> GenerateEmailVerificationIdAsync(string email);

JsonSerializationException in FusionAuthSyncClient.RetrieveTenants()

I have a serialization error when i call FusionAuthSyncClient.RetrieveTenants().
I use the latest version of the nuget package (1.29.1) on the API version 1.30.1.

I have investigated the problem and tested the same code but on the API version 1.29.4 and it works perfectly.
Is it possible the response of this endpoint had changed in version 1.30 and the client was not updated?

Here is the exception:

Newtonsoft.Json.JsonSerializationException: Could not convert string 'audit-log.create' to dictionary key type 'io.fusionauth.domain.event.EventType'. Create a TypeConverter to convert from the string to the key type object. Path 'tenants[0].eventConfiguration.events['audit-log.create']', line 1, position 1083.
---> Newtonsoft.Json.JsonSerializationException: Error converting value "audit-log.create" to type 'io.fusionauth.domain.event.EventType'. Path 'tenants[0].eventConfiguration.events['audit-log.create']', line 1, position 1083.
---> System.ArgumentException: Requested value 'audit-log.create' was not found.
at Newtonsoft.Json.Utilities.EnumUtils.ParseEnum(Type enumType, NamingStrategy namingStrategy, String value, Boolean disallowNumber)

Query string parameters are not URL encoded

Query string parameters are not being URL encoded, this will cause issues with various API calls e.g. RetrieveUserByEmailAsync if the email contains a + - when the API decodes this the + will be decoded as a space instead.

Lack of License

This repository lacks a license, so does the NuGet package. It is not possible to legally use this code. Would you please add a license (preferably MIT or Apache2) ?

Naming Conventions do not match .Net standards

It's very clear you guys are Java developers. Lowercase properties, reverse-domain namespaces. To a .Net developer, this feels really gross to work with.

My recommendations are:

  • Namespace should be FusionAuth instead of io.fusionauth
  • Public properties should be PascalCase, and not camelCase.
    • In this case, all JSON serialization will be broken, so to fix that the JsonSerializerSettings.ContractResolver must be set to new CamelCasePropertyNamesContractResolver()
  • In DefaultRESTClient, you override the default JsonConvert serializer settings with your own settings. This actually caused us problems because your handling of DateTimeOffset is different to our own API's (and only now by searching the source code, i found why we were experiencing issues). Please instead store your own instance of JsonSerializerSettings with your customizations, and reference this when serializing/deserializing JSON. I tend to make a helper class for this, so you can still keep the "JsonConvert" style. For an example, see here: https://github.com/kennyvv/Alex/blob/master/src/Alex.ResourcePackLib/Json/MCJsonConvert.cs

FusionAuthClient return 401 unauthorized when using a proxy url for Authority

401 unauthorized when using .net client with a proxy url

I am using nuget version 1.45
https://www.nuget.org/packages/FusionAuth.Client/

We did follow documentation for the proxy
https://fusionauth.io/docs/v1/tech/admin-guide/proxy-setup

In our case proxy is doing
https://accounts-demo.landr.com/ <--> https://landr-dev2.fusionauth.io/

When using with proxy url as Authority

                var apiKey = "xxxxxxxxxx";
                var authority = "https://accounts.zzzz.com/";
                var tenantId = "yyyyyyyyyyyy";

                var client = new FusionAuthClient(apiKey, authority, tenantId);
                var fusionAuthTenants = await client.RetrieveTenantsAsync();     

Result Status : 401

Nothing visible in the logs

When using with FusionAuth url as Authority

                var apiKey = "xxxxxxxxxx";
                var authority = "https://zzzz.fusionauth.io/";
                 var tenantId = "yyyyyyyyyyyy";

                var client = new FusionAuthClient(apiKey, authority, tenantId);
                var fusionAuthTenants = await client.RetrieveTenantsAsync();     

Result Status : 200

I received the list of the tenants and can start using the APi properly

Even after adding the TenanId we still have the issue .

Unable to deserialise SAMLv2 IdentityProvider

Hello ๐Ÿ‘‹

When I call _client.RetrieveIdentityProviderAsync or _client.RetrieveIdentityProvidersAsync, no SAMLv2IdentityProvider is returned. I tracked down the error to a typo in IdentityProviderConverter.

I'll push a PR to fix it in a few minutes.

ForgotPassword flow returning 401

I posted about it here, but I am pretty sure this is an issue: https://fusionauth.io/community/forum/topic/920/duplicate-email-verification-emails-being-sent-and-forgot-password-401

Ignoring the part about duplicate emails being sent (that might still be something on my end), but the forgot password issue seems legit.

                FusionAuthClient client = new FusionAuthClient(_authSettings.ApiKey, _authSettings.Host, _authSettings.TenantId);
                
                ForgotPasswordRequest forgotReq = new ForgotPasswordRequest();
                forgotReq.applicationId = new Guid(_authSettings.ApplicationId);
                forgotReq.email = model.Email;
                forgotReq.username = model.Email;

                ClientResponse<ForgotPasswordResponse> forgotResp = await client.ForgotPasswordAsync(forgotReq);

This comes back with a 401 response, indicating the apikey is incorrect, however the same key is used in all other calls through the library and do not give 401. I have tried multiple configurations on the application and tenant level with no luck. I verified all values are correct in the settings.

How to use the SearchRequest?

Hi,

First thanks for the work on this project :)

I have a question about how to use the SearchRequest (for users) with the elastic search engine,
I have an API Key scopped to a tenant and I want to retrieve all the users of the tenant. I've seen that there was a SearchUsersByQuery method on the client and I assume it was what I wanted. But I'm unable to understand how to create the SearchRequest object.

Here is what I've tried so far :

            var searchRequest = new SearchRequest();
            var userSearchCriteria = new UserSearchCriteria
            {
                query = $"email:*"
            };

            searchRequest.search = userSearchCriteria;
            var response = _client.SearchUsersByQuery(searchRequest);

And also

            var searchRequest = new SearchRequest();
            var userSearchCriteria = new UserSearchCriteria
            {
                query = $"*"
            };

            searchRequest.search = userSearchCriteria;
            var response = _client.SearchUsersByQuery(searchRequest);

But I've got an error with "InvalidSearchJSONException"

Can you please help me understand how to use the SearchRequest to build queries?

Thanks a lot

DateTimeOffsetConverter is throwing InvalidCastException

I ran into a System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Int64'. in DateTimeOffsetConverter.cs.

This happens if the passed in objectType is of type System.DateTimeOffset and the value is of type string e.g. 2020-10-29T21:31:02.9306779Z. With these constraints, it makes sense why it would throw an InvalidCastException as it is trying to convert the value to a long but it being a string, it actually can't.

When determining whether a type can be converted, it checks if the type is a DateTimeOffsetor not. So, I don't think if when actually converting the value, casting it directly to a long is the right way. Maybe it needs to be parsed first using DateTimeOffset.Parse() instead?

Side note: This bug is in a way only related to FA core library because DateTimeOffsetConverter is registered as one of the default custom JsonConverters hence this gets called whenever aDateTimeOffset needs to be converted from JSON.

Performance Optimization

In .net core, HttpClient is meant to be a singleton with the same lifecycle as an endpoint.

This is the canonical guide for the issues this causes, but it is significant and can make .net core software really unstable as time goes on. It also prevents connection pooling, which means lower performance for users of this library.
https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/

It appears like the call chain in FusionAuthClient for all methods is to call buildClient() which calls buildAnonymousClient which creates a new instance of DefaultRESTClient for every request. Is this something you would consider improving on? I'm not super clear on if this library is code generated from another, I would be willing to help with this but not sure the best way to make this change.

Issue with changing password validation rule

Version that we are using 1.10.0 for Fusion Auth .net core client and 1.10.1 for FusionAuth

We've created a tenant with password validation rule of one special character and then changed the password validation rule.

image

When we change the password validation rule in FusionAuth UI (to enable more rules) for that tenant, it works fine. However, RetrieveTenant method in the .net core client returns status code 200 with error response.

Below is the error response that we get

tenant.eventConfiguration.events['user.delete'] Could not convert string 'user.delete' to dictionary key type 'io.fusionauth.domain.event.EventType'. Create a TypeConverter to convert from the string to the key type object. Path 'tenant.eventConfiguration.events['user.delete']', line 1, position 557.

I've tried to retrieve tenant with Postman and this works fine.

Update to include .net standard 2.0

For libraries it's preferred that they target .net standard rather than .net core. If they target .net standard, they can be used in full framework apps above 4.7.1 and in universal apps, but if they target .net core they must run in the .net core runtime.

Can't Access All JWT Properties

When working with the ClientResponse returned from the ValidateJWTAsync function, you cannot access all properties, as some are in the Non-Public members section under a variable called "otherClaims". For example, you cannot access the "roles" array. see image below for layout of successResponse property at time of issue discovery. In this case, otherClaims[3] contains the roles.

image

SAMLv2IdPInitiated response is not being serialized.

In the IdentityProviderConverter, SAMLv2IdPInitiated is not being serialized. This needs to be added:

if (json["type"].Value<string>() == "SAMLv2IdPInitiated")
{
     return json.ToObject<SAMLv2IdPInitiatedIdentityProvider>(serializer);
}

Login doesn't contain the User Object if Email is not verified

Login doesn't contain the User Object if Email is not verified

Description

I have added Users whose Emails have not been verified.
Now when trying to Login, the API is not returning the User.
Rather just the StatusCode 212
The previous version was working perfectly fine but with the latest change, it's not.

Expected behavior

After performing the Login, I should get the User Object and statusCode 212

Screenshots

image

Platform

  • Server: IIS Express, .Net Core
  • OS: Windows 10
  • Browser + version: Microsoft Edge (Insider)
  • FusionAuth version 1.10.1

Additional context

As seen in the screenshot, the statusCode is 212 but there are no additional data provided.
In the earlier version, this issue was not there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.