ServiceStack.net implementing CustomAuthProvider with additional parameters? -
im trying implement customauthprovider in servicestack.net. need extend past username/password 3rd parameter. (lets call apikey) accept post application/json
public override bool tryauthenticate(servicestack.serviceinterface.iservicebase authservice, string username, string password) { if (string.isnullorempty(username) || string.isnullorempty(password)) return false; var httpreq = authservice.requestcontext.get<ihttprequest>(); string apikey = httpreq.getparam("apikey"); if (string.isnullorempty(apikey)) return false; var engine = helpers.dbhelper.getengine(); return engine.account.validateapikey(username, password, apikey); }
and payload looks like
{ "username"="my.user", "password"="$thepassword!1", "apikey"="theapikey" }
the username , password tryauthenticate() apikey null. above works fine if i'm posting form. i'm sure i've missed or have wrong idea of how this. i'm new servicestack have been on examples , articles better part of week. :( advice appreciated.
note: i'm using advance rest client chrome extension test.
could add apikey parameter part of querystring (http://localhost:1337/api/auth/credentials?apikey=theapikey
)?
i believe authservce accepts auth object request's inputstream deserialized auth object. ignore apikey
parameter. don't believe can reread inputstream of request in tryauthenticat override pull out apikey
.
if add apikey querystring can pull out in tryauthenticate override.
var req = authservice.requestcontext.get<ihttprequest>(); var apikey = req.querystring["apikey"];
you write own service accepts object username, password , apikey
. validate apikey , call authservice passing in username , password parameters.
Comments
Post a Comment