latest changes incl grocery list

This commit is contained in:
Joren de Graaf
2026-10-22 10:27:11 +02:00
parent aadadff69e
commit 712af2839d
12 changed files with 413 additions and 1 deletions
@@ -0,0 +1,25 @@
"""Issue a separate, revocable read-only MCP credential."""
import hashlib
import secrets
from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand, CommandError
from fireworks_detect.models import McpAccessToken
class Command(BaseCommand):
help = "Issue a BoomCast MCP token for an existing user with both review view permissions."
def add_arguments(self, parser):
parser.add_argument("username")
parser.add_argument("--name", default="MCP client")
def handle(self, *args, **options):
user = get_user_model().objects.filter(username=options["username"], is_active=True).first()
if user is None or not (user.has_perm("fireworks_detect.view_event") and user.has_perm("fireworks_detect.view_pendingevent")):
raise CommandError("Active user with view_event and view_pendingevent permissions required")
token = "bmcp_" + secrets.token_urlsafe(36)
McpAccessToken.objects.create(user=user, name=options["name"], token_hash=hashlib.sha256(token.encode()).hexdigest())
self.stdout.write("Store this token securely; it is shown only once:")
self.stdout.write(token)