authentication - How to do token based auth using ServiceStack -
how implement following scenario using servicestack?
initial request goes http://localhost/auth
having authorization header defined this:
authorization: basic skdjflsdkfj=
the iauthprovider implementation validates against user store , returns session token response body (json).
the client uses token resends against subsequent requests http://localhost/json/reply/orders
using authorization header this:
authorization: basictoken <tokenfromprevioussuccessfullogin>
using authenticateattribute
want flag service use authentication.
how should implement validation of token subsequent requests? how should implement iauthprovider
provide token? how register providers etc.? using requestfilters or using authfeature
?
servicestack's jwt authprovider , api key authprovider both use token based authentication.
otherwise basicauth provider simple class extracts username , password basicauth header , evaluates it:
public override object authenticate(...) { var httpreq = authservice.requestcontext.get<ihttprequest>(); var basicauth = httpreq.getbasicauthuserandpassword(); if (basicauth == null) throw httperror.unauthorized("invalid basicauth credentials"); var username = basicauth.value.key; var password = basicauth.value.value; return authenticate(authservice, session, username, password, request.continue); }
if want provide enhanced behavior, inherit class check authorization: basictoken
header, if exists use otherwise call base.authenticate(...)
method perform initial validation.
Comments
Post a Comment