public void OnActionExecuting(ActionExecutingContext filterContext) { var token = filterContext.RequestContext.HttpContext.Request.QueryString.Get("authToken"); var tokenData = new TokenData(); if (!JwtTokenValidator.Validate(ConfigurationManager.AppSettings["ADAppClientId"], token, ref tokenData)) { filterContext.Result = new ViewResult { ViewName = "401" }; } }
public ActionResult Details(string authToken) { TokenData tokenData = new TokenData(); if (JwtTokenValidator.Validate(authAudience, authToken, ref tokenData)) { return(View(tokenData)); } else { return(View("Error")); } }
public void JwtToken_Should_Be_Validated() { var response = _openIdClient.RequestClientCredentialsTokenAsync(new ClientCredentialsTokenRequest { Address = "/connect/token", ClientId = "client", ClientSecret = "secret", Scope = "api1" }).Result; string token = response.AccessToken; var validator = new JwtTokenValidator(Options.Create <JwtTokenOptions>(new JwtTokenOptions() { Authority = "https://server" }), _openIdClient); var p = validator.Validate(token).Result; Assert.NotNull(p.FindFirst("iss")); }