StatEngine / stat-engine

A Real-Time Open Source Data Analytics and Visualization Platform for Public Safety
https://statengine.io
GNU General Public License v3.0
8 stars 5 forks source link

Api guard (redo) #505

Closed larskendall closed 1 month ago

larskendall commented 4 years ago

There was already a PR for this (#420), but I switched the branch over to my own fork for more proper git usage, so I had to create a new PR. Everything is essentially the same as before, except the branch has been rebased onto the latest version of master, and I made some tweaks to make things work nicely with the new subscription banner.

Overview

When a department's subscription expires, they should no longer be able to access any subscriber endpoints or any pages in the app which access subscriber endpoints.

GitHub Issues

Changes

Screenshots / Videos

Subscription Canceled

Since most endpoints fail now with an invalid subscription, we can't load any app pages behind the error dialog. It might be nicer to make a special page for this in the future, but I think this works ok for now.

Screen Shot 2019-12-03 at 6 11 16 AM

Subscription Not Found

This is an unlikely condition, but it's technically a possibility so I went ahead and handled it just in case to avoid any potential confusion. I think it would only happen if someone tried to login immediately after the subscription was created in Chargebee, before the webhook was hit, or if their subscription data got nulled out for some other reason.

Screen Shot 2019-12-03 at 6 16 53 AM

Steps to Test

To disable the grace period, you can comment out line 178 of auth.service.js.

To test the "not found" error, just null out the department's subscription column in the database.

Steps to Deploy