Error logging in with CredentialProvider. Source array not long enough

Getting the following stack trace when trying to to login

System.ArgumentException: Source array was not long enough. Check the source index, length, and the array's lower bounds. (Parameter 'sourceArray')
   at System.Array.CopyImpl(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
   at ServiceStack.Auth.SaltedHash.ComputeHash(Byte[] Data, Byte[] Salt) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/SaltedHash.cs:line 38
   at ServiceStack.Auth.SaltedHash.VerifyHash(Byte[] Data, Byte[] Hash, Byte[] Salt) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/SaltedHash.cs:line 67
   at ServiceStack.Auth.SaltedHash.VerifyHashString(String Data, String Hash, String Salt) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/SaltedHash.cs:line 86
   at ServiceStack.Auth.AuthProviderExtensions.VerifyPassword(IUserAuth userAuth, String providedPassword, Boolean& needsRehash) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/AuthProviderExtensions.cs:line 172
   at ServiceStack.Auth.OrmLiteAuthRepositoryBase`2.TryAuthenticateAsync(String userName, String password, CancellationToken token) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack.Server/Auth/OrmLiteAuthRepositoryAsync.cs:line 262
   at ServiceStack.Auth.CredentialsAuthProvider.TryAuthenticateAsync(IServiceBase authService, String userName, String password, CancellationToken token) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/CredentialsAuthProvider.cs:line 86
   at ServiceStack.Auth.CredentialsAuthProvider.TryAuthenticateAsync(IServiceBase authService, String userName, String password, CancellationToken token) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/CredentialsAuthProvider.cs:line 97
   at ServiceStack.Auth.CredentialsAuthProvider.AuthenticateAsync(IServiceBase authService, IAuthSession session, String userName, String password, String referrerUrl, CancellationToken token) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/CredentialsAuthProvider.cs:line 152
   at ServiceStack.Auth.CredentialsAuthProvider.AuthenticateAsync(IServiceBase authService, IAuthSession session, Authenticate request, CancellationToken token) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/CredentialsAuthProvider.cs:line 123
   at ServiceStack.Auth.AuthenticateService.AuthenticateAsync(Authenticate request, String provider, IAuthSession session, IAuthProvider oAuthConfig, CancellationToken token) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/AuthenticateService.cs:line 486
   at ServiceStack.Auth.AuthenticateService.PostAsync(Authenticate request) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Auth/AuthenticateService.cs:line 287
   at ServiceStack.Host.ServiceRunner`1.ExecuteAsync(IRequest req, Object instance, TRequest requestDto) in /home/runner/work/ServiceStack/ServiceStack/ServiceStack/src/ServiceStack/Host/ServiceRunner.cs:line 149

I haven’t changed anything with the .NET 8 angular template except configure it to use OrmLite

Any ideas where to look?

The Exception is thrown trying to verify the Users password, I’m assuming either the User wasn’t configured with a Password or no password was provided, in which case it might be a serialization issue where the Password wasn’t sent correctly.

Tracked it down. The following was interfering with the auth process

OrmLiteConfig.OnDbNullFilter = fieldDef => 
                fieldDef.FieldType == typeof(string)
                    ? ""
                    : null;

Removing this fixed it

1 Like