1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

add redis password authentication support, closes #82

This commit is contained in:
checktheroads
2020-10-10 21:13:28 -07:00
parent 14ec5da505
commit ba1a91c93f
11 changed files with 157 additions and 136 deletions

View File

@@ -1,10 +1,10 @@
"""Validation model for Redis cache config."""
# Standard Library
from typing import Union
from typing import Union, Optional
# Third Party
from pydantic import Field, StrictInt, StrictStr, StrictBool, IPvAnyAddress
from pydantic import SecretStr, StrictInt, StrictStr, StrictBool, IPvAnyAddress
# Project
from hyperglass.models import HyperglassModel
@@ -13,26 +13,25 @@ from hyperglass.models import HyperglassModel
class Cache(HyperglassModel):
"""Validation model for params.cache."""
host: Union[IPvAnyAddress, StrictStr] = Field(
"localhost", title="Host", description="Redis server IP address or hostname."
)
port: StrictInt = Field(6379, title="Port", description="Redis server TCP port.")
database: StrictInt = Field(
1, title="Database ID", description="Redis server database ID."
)
timeout: StrictInt = Field(
120,
title="Timeout",
description="Time in seconds query output will be kept in the Redis cache.",
)
show_text: StrictBool = Field(
True,
title="Show Text",
description="Show the cache text in the hyperglass UI.",
)
host: Union[IPvAnyAddress, StrictStr] = "localhost"
port: StrictInt = 6379
database: StrictInt = 1
password: Optional[SecretStr]
timeout: StrictInt = 120
show_text: StrictBool = True
class Config:
"""Pydantic model configuration."""
title = "Cache"
description = "Redis server & cache timeout configuration."
fields = {
"host": {"description": "Redis server IP address or hostname."},
"port": {"description": "Redis server TCP port."},
"database": {"description": "Redis server database ID."},
"password": {"description": "Redis authentication password."},
"timeout": {
"description": "Time in seconds query output will be kept in the Redis cache."
},
"show_test": {description: "Show the cache text in the hyperglass UI."},
}