I am using the Azure Active Directory v2.0 endpoints for authentication into my application. My application then requests an access token and passes that onto my service stack api. I have written code, via custom request filter, that validates the access token. What I want to do, is convert this custom request filter into an auth plugin. All it needs to do is validate the token and populate the session.
Here is my global request handler code. How would I go about converting that into a custom auth provider.
public class CustomRequestAttribute : RequestFilterAttribute
{
public override void Execute(IRequest req, IResponse res, object requestDto)
{
var authenticationHeader = req.Headers[HttpHeaders.Authorization];
var token = authenticationHeader.Substring(7);
JwtSecurityToken jwt;
try
{
JwtValidator.ValidateJwtToken(token);
} catch (SecurityTokenException e)
{
throw e;
}
}
}
I will worry about authorization piece later, as the roles and permissions are going to be coming from some place other than Azure Active Directory.