From 0361c3ac449f183476f7aee31439417d9f7f8012 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sun, 13 Jun 2021 19:42:09 +0200 Subject: pppoe: T3621: validate that both username and password are set A validator is missing checking that if authentication is used on a PPPoE interface, both username and password are set. --- python/vyos/configverify.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'python/vyos/configverify.py') diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index 0ff45da2a..ee0fd94f7 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -122,6 +122,19 @@ def verify_mirror(config): raise ConfigError(f'Can not mirror "{direction}" traffic back ' \ 'the originating interface!') +def verify_authentication(config): + """ + Common helper function used by interface implementations to perform + recurring validation of authentication for either PPPoE or WWAN interfaces. + + If authentication CLI option is defined, both username and password must + be set! + """ + if 'authentication' not in config: + return + if not {'user', 'password'} <= set(config['authentication']): + raise ConfigError('Authentication requires both username and ' \ + 'password to be set!') def verify_address(config): """ -- cgit v1.2.3