ServiceStack AuthProvider PreAuthenticate infinite loop

asked8 years ago
last updated8 years ago
viewed124 times
Up Vote0Down Vote

I'm attempting to write a simple custom AuthProvider for authentication by API key on the URL. I have based my code on the BasicAuthProvider.

I am finding, however, that running the code from the BasicAuthProvider, before I make any changes at all, the method gets recursively called each time the method is called:

public void PreAuthenticate(IRequest req, IResponse res)
    {
        SessionFeature.AddSessionIdToRequestFilter(req, res, null); 

        var userPass = req.GetBasicAuthUserAndPassword();
        if (userPass != null)
        {
            var authService = req.TryResolve<AuthenticateService>();
            authService.Request = req;

            //** Post calls PreAuthenticate again **//

            var response = authService.Post(new Authenticate
            {
                provider = Name,
                UserName = userPass.Value.Key,
                Password = userPass.Value.Value
            });
        }
    }

Could anyone shed any light on why this might be?

Thanks.