-- PostgreSQL database dump
--
-\restrict WmWKbaDQfA4nBBtkMPZrgKfs3IuS4Rt4OGUXi43GEHyNlWwmMPGfl4UdQKiKmxj
+\restrict JPaknCY0oEioIF0KZXsQxd9k8J4KAoFZnnVs2RpIewZuAAWn2sRSbNubLxxk2P2
-- Dumped from database version 17.7 (Debian 17.7-0+deb13u1)
-- Dumped by pg_dump version 17.7 (Debian 17.7-0+deb13u1)
deleted_at timestamp with time zone,
deleted_by text,
uid text NOT NULL,
- can_impersonate boolean DEFAULT false NOT NULL
+ can_impersonate boolean DEFAULT false NOT NULL,
+ last_used_at timestamp with time zone
);
-- PostgreSQL database dump complete
--
-\unrestrict WmWKbaDQfA4nBBtkMPZrgKfs3IuS4Rt4OGUXi43GEHyNlWwmMPGfl4UdQKiKmxj
+\unrestrict JPaknCY0oEioIF0KZXsQxd9k8J4KAoFZnnVs2RpIewZuAAWn2sRSbNubLxxk2P2
if key:
log.debug("Successfully authenticated %s" % key)
+ # Log as used
+ await key.used()
+
return key
async def get_key(self, key):
# Permissions
can_impersonate: bool = False
+
+ # Used At
+ used_at: datetime.datetime | None = None
+
+ async def used(self):
+ """
+ Called when the API key has been used
+ """
+ self.used_at = sqlmodel.func.current_timestamp()