I want to refactor my Ruby on Rails application and split it into 2 parts.
Currently, it's a monolithic app that incorporates user registration/authentication, resource management, report sending by mail and rich UI. Usually, a page of the application is a container with widgets; every widget fetches data from the server using some internal API that feeds client with data in JSON format. These widgets are too many and their API is a significant part of the app. I want to extract that API into a separate application. The main application will continue to serve user requests at www.app.com address, and API will be available at api.app.com
Question: how to protect API app and prevent unauthorized access? The main app uses sessions (with cookies). Now, these sessions are being validated when a request to API is processed. Since it will be a new app living on another server, I'm not sure I could validate those sessions. So what's the option? Using JWT tokens or? Could you share examples from your experience please?