public override async Task Invoke(IOwinContext context) { var token = GetTokenFromRequest(context.Request); if (string.IsNullOrWhiteSpace(token) == false) { var claims = await _tokenHandler.ClaimsFromToken(token); var identity = await _tokenHandler.IdentityFromClaims(claims); if (string.IsNullOrWhiteSpace(identity) == false) { var user = await _authenticator.UserFromIdentity(identity); if (user != null) { context.Authentication.User = PrincipleFromUser(user); } } } await Next.Invoke(context); }