mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-19 13:03:44 +00:00
* verify aad tenants, primarily needed in multi-tenant deployments * add logging and fix trailing slash for issuer * handle call_if* not supporting additional argument callbacks * add logging * include new datatype in webhook docs * fix pytypes unit tests Co-authored-by: Brian Caswell <bmc@shmoo.com>
35 lines
1023 B
Python
35 lines
1023 B
Python
#!/usr/bin/env python
|
|
#
|
|
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
from typing import Optional, Tuple
|
|
|
|
from onefuzztypes.events import EventInstanceConfigUpdated
|
|
from onefuzztypes.models import InstanceConfig as BASE_CONFIG
|
|
from pydantic import Field
|
|
|
|
from .azure.creds import get_instance_name
|
|
from .events import send_event
|
|
from .orm import ORMMixin
|
|
|
|
|
|
class InstanceConfig(BASE_CONFIG, ORMMixin):
|
|
instance_name: str = Field(default_factory=get_instance_name)
|
|
|
|
@classmethod
|
|
def key_fields(cls) -> Tuple[str, Optional[str]]:
|
|
return ("instance_name", None)
|
|
|
|
@classmethod
|
|
def fetch(cls) -> "InstanceConfig":
|
|
entry = cls.get(get_instance_name())
|
|
if entry is None:
|
|
entry = cls(allowed_aad_tenants=[])
|
|
entry.save()
|
|
return entry
|
|
|
|
def save(self, new: bool = False, require_etag: bool = False) -> None:
|
|
super().save(new=new, require_etag=require_etag)
|
|
send_event(EventInstanceConfigUpdated(config=self))
|