Config
authkeys.config
Configuration: one TOML .cfg file read with anycfg.
The system file is /etc/authkeys.cfg (or the path given with --config or
AUTHKEYS_CONFIG). Its tables are [cache], [globals], [serve] and one
[source.<name>] per key source; ${env.NAME} is replaced from the
environment. A user's ~/.ssh/authkeys.cfg delegation file is read as TOML with
no includes and no interpolation: its author is the user it delegates for.
Unknown keys and values of the wrong type are logged as one WARNING naming the
key (never the value) and ignored; a file that does not parse is a
:class:~authkeys.exceptions.ConfigError.
CONFIG_ENV = 'AUTHKEYS_CONFIG'
module-attribute
LOGGER = logging.getLogger('authkeys')
module-attribute
SYSTEM_CONFIG = Path('/etc/authkeys.cfg')
module-attribute
USER_CONFIG = Path('.ssh/authkeys.cfg')
module-attribute
__all__ = ['CONFIG_ENV', 'SYSTEM_CONFIG', 'USER_CONFIG', 'CacheSettings', 'Delegation', 'GlobalSettings', 'Settings', 'SourceSettings', 'chosen_path', 'duho_loader', 'load_settings', 'parse_delegation', 'read_document', 'typed', 'warn_unknown']
module-attribute
CacheSettings(backend='memory', expire=300, negative_expire=None, expired_on_error=False, max_stale=None, options=dict())
dataclass
The [cache] table. options holds the backend's own keys.
backend = 'memory'
class-attribute
instance-attribute
expire = 300
class-attribute
instance-attribute
expired_on_error = False
class-attribute
instance-attribute
max_stale = None
class-attribute
instance-attribute
negative_expire = None
class-attribute
instance-attribute
options = field(default_factory=dict)
class-attribute
instance-attribute
Delegation(users=None, groups=list())
dataclass
A user's [authorized] table: users is None when unset.
groups = field(default_factory=list)
class-attribute
instance-attribute
users = None
class-attribute
instance-attribute
GlobalSettings(usermap='authkeys.usermaps.none', groupmembers='authkeys.groupmembers.system_groupmembers')
dataclass
The [globals] table: dotted paths of the usermap and group resolver.
groupmembers = 'authkeys.groupmembers.system_groupmembers'
class-attribute
instance-attribute
usermap = 'authkeys.usermaps.none'
class-attribute
instance-attribute
Settings(cache=CacheSettings(), globals=GlobalSettings(), sources=dict(), serve=dict(), path=None)
dataclass
A whole configuration, as :func:load_settings reads it.
cache = field(default_factory=CacheSettings)
class-attribute
instance-attribute
globals = field(default_factory=GlobalSettings)
class-attribute
instance-attribute
path = None
class-attribute
instance-attribute
serve = field(default_factory=dict)
class-attribute
instance-attribute
sources = field(default_factory=dict)
class-attribute
instance-attribute
from_mapping(data, *, path=None)
classmethod
Build settings from a loaded document, warning about what it ignores.
Source code in src/authkeys/config.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
SourceSettings(name, backend, enabled=True, cached=True, sanitize=None, expire=None, options=dict())
dataclass
One [source.<name>] table. options holds the backend's own keys.
backend
instance-attribute
cached = True
class-attribute
instance-attribute
enabled = True
class-attribute
instance-attribute
expire = None
class-attribute
instance-attribute
name
instance-attribute
options = field(default_factory=dict)
class-attribute
instance-attribute
sanitize = None
class-attribute
instance-attribute
chosen_path(argument)
The configuration file in force: --config, else AUTHKEYS_CONFIG
(empty means none), else :data:SYSTEM_CONFIG.
Source code in src/authkeys/config.py
252 253 254 255 256 257 258 259 260 | |
duho_loader(path, source='default')
_config_loader_ for the CLI: the document, or {} when it is broken.
duho cannot report a loader's exception as an exit status, so a file that does not parse is reported by the command itself when it loads its settings.
Source code in src/authkeys/config.py
240 241 242 243 244 245 246 247 248 249 | |
load_settings(path)
Load and validate the configuration at path.
None is an empty configuration. A missing file logs one WARNING and is an
empty configuration too ("no keys" stays a valid answer for sshd); a file that
does not parse raises :class:ConfigError.
Source code in src/authkeys/config.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | |
parse_delegation(text, *, where='authkeys.cfg')
Parse a delegation file's text: TOML only, no includes, no interpolation.
Raises :class:ConfigError naming the position, not the text.
Source code in src/authkeys/config.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | |
read_document(path)
Read a system configuration file with anycfg; ConfigError if it fails.
TOML unless its first line names another format (#!yaml); ${env.NAME}
is replaced from the environment, an unset variable giving an empty value.
Source code in src/authkeys/config.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
typed(table, key, types, default, where)
Return table[key] when it has one of types, else default.
A present value of another type logs one WARNING naming where.key and the
expected type, not the value (it may be a secret). bool is not an int.
Source code in src/authkeys/config.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
warn_unknown(table, known, where)
Log one WARNING per key of table that is not in known.
Source code in src/authkeys/config.py
91 92 93 94 95 96 | |