automatically expire API keys
Categories
(Location :: General, enhancement, P2)
Tracking
(Not tracked)
People
(Reporter: willkg, Unassigned)
Details
In MLS, we have a different types of API keys and one of those types needs to auto-expire in 3 months. Currently, there's no way to do that.
We need the following:
- a way to set some API keys to expire on a specified date
- a way to denote which API keys are active and which are not
- an automated way to deactivate API keys that have expired on a daily basis
For that, I think we need at least an "expires_on" datetime field and a "active" boolean field. We need something to auto-expire API keys once a day--probably a scheduled celery task. Or something along those lines.
This bug covers figuring that out and building it.
Reporter | ||
Comment 1•5 years ago
|
||
ckolos says we delete keys from the table that are no longer active. Given that, we don't need to add an "active" boolean field.
So then the requirements are this:
- add a way to set some API keys to expire on a specified date
- an automated way to delete API keys that have expired daily
Seems like we can add an "expires_on" date field to the table that's either NULL or a valid date. Then we can add a task that deletes API keys that have expired. Plus it should log the expiration in a easy-to-reconstruct manner.
ckolos: Does this look correct? Should we add an "eventlog" table with a log of what keys got deleted when? Do we want notifications somewhere? Is there anything else we should be thinking about when doing this?
Reporter | ||
Updated•5 years ago
|
I agree with the requirements set in #c1.
Reporter | ||
Comment 3•5 years ago
|
||
I never moved further with this. In the weekly meetings, it was clear that the current system was preferred to making changes. Further, the requirements set in comment #1 don't cover possible performance issues from deleting keys from the table. So I think that plan is bunk.
Comment 4•5 years ago
|
||
We had a recent discussion (June 22, 2020) about this. We've had some issues with API keys that we thought were disabled that were still enabled, and we continue to get API key requests. There is additional metadata, such as human-readable names, that are useful when exploring the data or creating dashboards.
The consensus is moving toward expanding the API key model and adding an API key dashboard.
Possible model additions:
- License type: Commercial Project, Public Interest Project, Mozilla
- Firefox: True if used in a Firefox deployment, by Mozilla or a Linux distribution
- Organization: Human-readable name of the licensing organization
- Comment: Administrator comment
- Created / Modified: creation and modification dates, nullable for historical keys
- Expiration: date the key should no longer be valid
- Abandoned: True if we believe the key is no longer in use
My thoughts about an API key dashboard are heavily influenced by the Django admin, which provides:
- A web-based UI for browsing, filtering, creating, and updating items
- Defaults and form validation
This could be hosted in a way that is only accessible to administrators, for example requiring the VPN and an LDAP-backed login. Other nice features would be embedded usage graphs, such as those generated by Grafana.
Comment 5•5 years ago
|
||
Moved to GitHub issues:
- Issue 1375 - Create basic administration / configuration website
- Issue 1376 - Expand data model for API keys
- Issue 1377 - Automatically expire API keys
Description
•