Have you used statamic to restrict some content for authenticated users?

I guess it's easy for pages rendered and served by statamic.

But what about content served by other apps on the same server?

Let's say I run an app on my server with python:

python -m SimpleHTTPServer 8000

Now I want my registered users to be able to access the content served by this app.

With Apache or nginx, this can be accomplished with a reverse proxy and HTTP basic authentication.

The server will intercept HTTP requests, modify the header before it reaches the python app, get the response from the python app, and then modify the header again before it comes back to the user.

The server will check if the user has authenticated with HTTP basic auth.

The problem is that it's difficult to register new users with Apache or nginx, and HTTP basic authentication does not allow for easy login/logout that users have come to expect.

How would you approach this with statamic and PHP? Have you done this before?

Thanks!