CitadelOnTheMove / agt

Citadel Application Generation Tool
Other
8 stars 5 forks source link

ServiceStack Basic Authentication Failure #55

Closed yashary closed 10 years ago

yashary commented 10 years ago

I'm trying to utilize the basic authentication of ServiceStack but even after passing the correct credentials, I'm getting the error: [Authenticate: 6/16/2014 4:00:22 AM]: [REQUEST: {UserName:john,Password:test}] ServiceStack.HttpError: Invalid BasicAuth credentials at ServiceStack.Auth.BasicAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, Authenticate request) at ServiceStack.Auth.AuthenticateService.Authenticate(Authenticate request, String provider, IAuthSession session, IAuthProvider oAuthConfig) at ServiceStack.Auth.AuthenticateService.Post(Authenticate request) at ServiceStack.Auth.AuthenticateService.Get(Authenticate request) at lambda_method(Closure , Object , Object ) at ServiceStack.Host.ServiceRunner`1.Execute(IRequest request, Object instance, TRequest requestDto)

The lines of code in my AppHost.cs class Configure function is as follows: // Register AuthFeature with custom user session and Basic auth provider Plugins.Add(new AuthFeature( () => new AuthUserSession(), new AuthProvider[] { new BasicAuthProvider() } ));

Plugins.Add(new RegistrationFeature());

// register storage for user sessions container.Register(new MemoryCacheClient()); container.Register(c => new SessionFactory(c.Resolve()));

var userRep = new InMemoryAuthRepository(); container.Register(userRep);

//Add a user for testing purposes string hash; string salt; new SaltedHash().GetHashAndSaltString("test", out hash, out salt); userRep.CreateUserAuth(new UserAuth { Id = 1, DisplayName = "DisplayName", Email = "as@if.com", UserName = "john", FirstName = "FirstName", LastName = "LastName", PasswordHash = hash, Salt = salt, }, "test");

And the URL that I'm utilizing for authentication is: http://localhost:63743/auth?Username=john&Password=test

Please let me know what can be the root cause of this behavior?