adding secure middleware for token validation