71 lines
2.0 KiB
Python
71 lines
2.0 KiB
Python
"""Sigl Access Key Model.
|
|
|
|
Simple Grocery List (Sigl) | sigl.app
|
|
Copyright (c) 2022 Asymworks, LLC. All Rights Reserved.
|
|
"""
|
|
|
|
from dataclasses import dataclass
|
|
from datetime import datetime
|
|
|
|
__all__ = ('AccessKey', 'AccessToken')
|
|
|
|
|
|
@dataclass
|
|
class AccessKey:
|
|
"""Sigl Access Key Class.
|
|
|
|
The Access Key represents a client or group of clients authorized to
|
|
interact with their specific Sigl shopping lists and products. Access Keys
|
|
are generally not revoked or deleted and remain for the lifetime of the
|
|
server.
|
|
|
|
When an Access Key is created, client details including the IP address and
|
|
User Agent string are logged for future auditing purposes. The IP address
|
|
may also be used for throttling.
|
|
"""
|
|
key: str = None
|
|
clientId: str = None
|
|
clientIP: str = None
|
|
userAgent: str = None
|
|
|
|
# Key Suspension/Revocation
|
|
suspended: bool = False
|
|
revoked: bool = False
|
|
|
|
# Timestamps
|
|
createdAt: datetime = datetime.utcnow()
|
|
suspendedAt: datetime = None
|
|
revokedAt: datetime = None
|
|
restoredAt: datetime = None
|
|
|
|
# Populated by ORM
|
|
# tokens: List['AccessToken'] = None
|
|
|
|
|
|
@dataclass
|
|
class AccessToken:
|
|
"""Sigl Access Token Class.
|
|
|
|
The Access Token represents authorization for a client (identified by an
|
|
Access Key) to interact with the Sigl server. The token string, issue time,
|
|
and expiry time must match the client-provided JWT for access to be granted.
|
|
Access Tokens are short-lived tokens expected to expire or be revoked, and
|
|
new tokens requested by the client.
|
|
|
|
When an Access Key is created, client details including the IP address and
|
|
User Agent string are logged for future auditing purposes.
|
|
"""
|
|
token: str = None
|
|
accessKey: str = None
|
|
clientIP: str = None
|
|
userAgent: str = None
|
|
|
|
# Key Suspension/Revocation
|
|
expired: bool = False
|
|
revoked: bool = False
|
|
|
|
# Timestamps
|
|
issuedAt: datetime = datetime.utcnow()
|
|
expiresAt: datetime = None
|
|
revokedAt: datetime = None
|