feat: expand onion service api
This commit is contained in:
parent
c1b385ed99
commit
e5976c4739
11 changed files with 646 additions and 348 deletions
|
@ -1,3 +1,4 @@
|
|||
from datetime import datetime
|
||||
from typing import Optional, TypedDict
|
||||
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
@ -10,9 +11,16 @@ from app.util.onion import onion_hostname
|
|||
|
||||
|
||||
class OnionDict(TypedDict):
|
||||
Id: int
|
||||
Added: str
|
||||
CertExpiry: str
|
||||
CertSans: str
|
||||
Description: str
|
||||
DomainName: str
|
||||
GroupId: int
|
||||
GroupName: str
|
||||
Id: int
|
||||
OnionName: str
|
||||
Updated: str
|
||||
|
||||
|
||||
class Onion(AbstractConfiguration):
|
||||
|
@ -26,14 +34,14 @@ class Onion(AbstractConfiguration):
|
|||
resource_id=self.onion_name
|
||||
)
|
||||
|
||||
group_id = db.Column(db.Integer(), db.ForeignKey("group.id"), nullable=False)
|
||||
domain_name = db.Column(db.String(255), nullable=False)
|
||||
|
||||
onion_public_key = db.Column(db.LargeBinary, nullable=False)
|
||||
onion_private_key = db.Column(db.LargeBinary, nullable=False)
|
||||
|
||||
tls_public_key = db.Column(db.LargeBinary, nullable=False)
|
||||
tls_private_key = db.Column(db.LargeBinary, nullable=False)
|
||||
group_id: Mapped[int] = mapped_column(db.ForeignKey("group.id"))
|
||||
domain_name: Mapped[str]
|
||||
cert_expiry: Mapped[datetime] = mapped_column(db.DateTime(timezone=True))
|
||||
cert_sans: Mapped[str]
|
||||
onion_public_key: Mapped[bytes]
|
||||
onion_private_key: Mapped[bytes]
|
||||
tls_public_key: Mapped[bytes]
|
||||
tls_private_key: Mapped[bytes]
|
||||
|
||||
group = db.relationship("Group", back_populates="onions")
|
||||
|
||||
|
@ -43,9 +51,16 @@ class Onion(AbstractConfiguration):
|
|||
|
||||
def to_dict(self) -> OnionDict:
|
||||
return {
|
||||
"Added": self.added.isoformat(),
|
||||
"Id": self.id,
|
||||
"CertExpiry": self.cert_expiry.isoformat(),
|
||||
"CertSans": self.cert_sans,
|
||||
"Description": self.description,
|
||||
"DomainName": self.domain_name,
|
||||
"GroupId": self.group_id,
|
||||
"GroupName": self.group.group_name,
|
||||
"OnionName": self.onion_name,
|
||||
"Updated": self.updated.isoformat(),
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue