Skip to main content

Auth Service Data Models

User

Represents a registered user. Maps to the users table.

FieldTypeDB ColumnDescription
idIntegeridPrimary Key
emailString(128)emailUnique email address (required, indexed)
nameString(128)nameUser's display name
phoneString(128)phonePhone number
loginString(128)loginAlternative login identifier
hashedpasswordString(128)hashedpasswordBcrypt hash of password
readonlyBooleanreadonlyUser has read-only access
administratorBooleanadministratorAdmin privileges
mapString(128)mapPreferred map layer
latitudeFloatlatitudeDefault map center latitude
longitudeFloatlongitudeDefault map center longitude
zoomIntegerzoomDefault map zoom level
totpkeyString(128)totpkeyTOTP secret key for 2FA
_disabledIntegerdisabled0 = Active, 1 = Disabled
expirationtimeDateTimeexpirationtimeAccount expiration time
devicelimitIntegerdevicelimitMax devices (-1 = unlimited)
userlimitIntegeruserlimitMax sub-users
devicereadonlyBooleandevicereadonlyDevices are read-only
limitcommandsBooleanlimitcommandsCommands are limited
fixedemailBooleanfixedemailEmail cannot be changed
attributesString(4000)attributesJSON metadata
email_verifiedBooleanemail_verifiedIs email verified?
verification_tokenString(128)verification_tokenToken for email verification (indexed)
verification_token_expiresDateTimeverification_token_expiresToken expiration time
two_factor_typeString(20)two_factor_type'none', 'totp', or 'email'
backup_codesString(4000)backup_codesJSON list of hashed backup codes

Computed Properties

PropertyTypeDescription
disabledBooleanDerived from _disabled column
is_activeBooleanTrue if not disabled AND not expired
has_totpBooleanTrue if totpkey is set

Methods

MethodReturnsDescription
get_attributes()dictParses attributes JSON, returns {} on error
to_dict()dictReturns user data safe for API responses

to_dict() Output

{
"id": 1,
"email": "user@example.com",
"name": "John Doe",
"phone": "+1234567890",
"administrator": false,
"disabled": false,
"readonly": false,
"deviceReadonly": false,
"limitCommands": false,
"expirationTime": "2025-12-31T23:59:59+00:00",
"attributes": {}
}

Keystore

Stores the RSA key pair for signing JWTs. Maps to the keystore table.

FieldTypeDescription
idIntegerPrimary Key
publickeyBytesRSA Public Key (PEM format)
privatekeyBytesRSA Private Key (PEM format)

Note: There should be exactly one row in this table. The keys are used for RS256 JWT signing and verification.