4

I want to use a custom auth provider, but I don't see how I can make the standard Auth stuff handle more that user and password as parameters.

Can this be done?

LiteWait
  • 584
  • 4
  • 21
  • 42

1 Answers1

3

Depends what you want to do, if you want to create your own Custom auth provider by inheriting from CredentialsAuthProvider, you can access different request params via the IHttpRequest object:

public virtual bool TryAuthenticate(IServiceBase authService, 
    string userName, string password)
{
    var httpReq = authService.RequestContext.Get<IHttpRequest>();
    var fromQueryString = httpRequest.QueryString["CustomField"];
    var fromPostData = httpRequest.FormData["CustomField"];
    var fromEither = httpRequest.GetParam("CustomField"); //Ext method
}

Here are some other related questions and answers that show different ways to customize ServiceStack's built-in Auth:

Community
  • 1
  • 1
mythz
  • 141,670
  • 29
  • 246
  • 390
  • 1
    Thanks Demis. I may just ditch the Custom Auth altogether. My needs are pretty unique and the concept of user/password doesn't real make sense to my model and shoe-horning CustomAuth in seems like a hack. Real problem is I have been struggling with keep a session token every "session-required" service needs to pass. First thought was cookie (seems insecure), next up was Authentication header which seems like I am putting too heavy a requirement on the client (and locks me in to http), so likely I am going to add the token as an interface to every DTO. – LiteWait Sep 27 '12 at 21:44